Exemplo n.º 1
0
    def __init__(self, parent, controller, background_img):
        tk.Frame.__init__(self, parent)
        self.COLOR_BUTTON_BACKGROUND = "#0C4323"
        self.controller = controller

        self.frame = tk.Frame(self, relief="solid", height=60)
        self.frame.pack(side="left", fill="both", expand=True)

        self.bg_image = background_img

        background_label = tk.Label(self.frame, image=self.bg_image)
        background_label.place(x=0, y=0, relwidth=1, relheight=1)

        self.imgBtnBack = tk.PhotoImage(file='images/btnBack.png')
        self.btnHome = tk.Button(self.frame,
                                 relief="solid",
                                 bd=0,
                                 highlightthickness=0,
                                 image=controller.imgBtnBack,
                                 bg=self.COLOR_BUTTON_BACKGROUND,
                                 command=lambda: self.go_start_page())

        self.imgBtnUp = tk.PhotoImage(file='images/btnUp.png')
        self.imgBtnDown = tk.PhotoImage(file='images/btnDown.png')

        if platform.system() == "Linux":
            wpi.wiringPiSetup()
            wpi.pinMode(4, 1)
Exemplo n.º 2
0
def main():
    wpi.wiringPiSetup()
    args = parse_args()

    # Get requested state from user
    requested_state = args.state
    # Get actual current state
    current_state = lights_are_actually_on()

    if current_state == requested_state:
        print(f"Lights are already {current_state}; exiting", file=sys.stderr)
        return False

    physical_pin_number = 11
    # Set pin to "write" mode
    wpi.pinMode(physical_pin_number, 1)
    # Perform the write
    wpi.digitalWrite(
        ODROID_N2_PIN_MAP[physical_pin_number]["wpi_num"],
        1 if requested_state == "on" else 0,
    )
    # Wait a bit; it takes the LED driver a few tenths to activate
    time.sleep(0.5)

    # Now the lights _should_ be on, but let's make sure
    current_state = lights_are_actually_on()
    if current_state != requested_state:
        print(
            f"ERROR: Changed state of pin {physical_pin_number} to {requested_state}, "
            f"but lights did not go {requested_state}",
            file=sys.stderr,
        )
        sys.exit(1)
    return True
Exemplo n.º 3
0
 def init_spray(self):
     self.spray_on_check = False
     if super().is_linux_system():
         wpi.wiringPiSetup()
         # wpi.pinMode(ConfigValue.SPRAY_WPI_NUM, 1)
         # wpi.pinMode(ConfigValue.VALVE_WPI_NUM, 1)
         wpi.digitalWrite(ConfigValue.SPRAY_WPI_NUM, 0)
         wpi.digitalWrite(ConfigValue.VALVE_WPI_NUM, 0)
Exemplo n.º 4
0
    def __init__(self):
        super().__init__("door_status")
        self.publisher = self.create_publisher(Int8, "door_status", 10)
        timer = 0.5

        wpi.wiringPiSetup()
        wpi.pinMode(27, 0)
        wpi.pullUpDnControl(27, 2)
        self.timer = self.create_timer(timer, self.measure)
        self.i = 0
Exemplo n.º 5
0
    def __init__(self):
        self.ser = serial.Serial("/dev/ttyS1", 115200)
        wpi.wiringPiSetup()
        self.curtime = 0
        self.out_valve_start_time = None
        self.cur_spray_on = None

        try:
            if self.ser.isOpen() == False:
                self.ser.open()
        except KeyboardInterrupt():  # ctrl + c in terminal.
            if self.ser != None:
                self.ser.close()
                print("program interrupted by the user")
#!/usr/bin/env python
import time
import odroid_wiringpi as wpi
import rospy
from std_msgs.msg import Float32

if __name__ == '__main__':
    wpi.wiringPiSetup()
    # ROS setup
    pub = rospy.Publisher('voltage', Float32)
    rospy.init_node('battery_voltage_indicator', anonymous=True)
    rate = rospy.Rate(1)
    while not rospy.is_shutdown():
        battery = wpi.analogRead(1)  # Read ADC.AIN1 (physical port #37)
        pub.publish((battery * (1.8 / 1024)) *
                    11.0034)  # Convert bit to actual voltage
        rate.sleep()
Exemplo n.º 7
0
 def init_WPI(self):
     if super().is_linux_system():
         wpi.wiringPiSetup()
         wpi.pinMode(ConfigValue.SPRAY_WPI_NUM, 1)
         wpi.pinMode(ConfigValue.VALVE_WPI_NUM, 1)
         wpi.digitalWrite(ConfigValue.SPRAY_WPI_NUM, 0)
Exemplo n.º 8
0
Arquivo: tank.py Projeto: jstreamer/t1
import socket
import sys
import time
import threading
import odroid_wiringpi as wiringpi

OUTPUT = 1
left_motor_speed_pin = 23
wiringpi.wiringPiSetup()
wiringpi.pinMode(left_motor_speed_pin, OUTPUT)
wiringpi.softPwmCreate(left_motor_speed_pin, 0, 100)

left_truck_speed = 0
right_truck_speed = 0
left_truck_operational = True
pulse_delay = 0.01


def left_truck_movement_loop():
    print("Starting left track")
    while left_truck_operational:
        if left_truck_speed == 0:
            wiringpi.softPwmWrite(left_motor_speed_pin, 0)
            continue
        wiringpi.softPwmWrite(left_motor_speed_pin, left_truck_speed)


left_truck = threading.Thread(target=left_truck_movement_loop)
left_truck.start()

# Create a TCP/IP socket
Exemplo n.º 9
0
def init():
    gpio.wiringPiSetup()
    gpio.pinMode(8, 1)
    gpio.pinMode(9, 1)
    gpio.pinMode(7, 1)
    gpio.pinMode(0, 1)
Exemplo n.º 10
0
def setup_gpio() -> None:
    wp.wiringPiSetup()
    wp.pinMode(AC_OK, IN)
    wp.pinMode(BATT_OK, IN)
    wp.pinMode(POWER_LATCH, OUT)
    wp.digitalWrite(POWER_LATCH, 1)