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)
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
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
#!/usr/bin/env python import odroid_wiringpi as wpi import time wpi.wiringPiSetup() wpi.pinMode(4, 1) while True: # wpi.digitalWrite(4, 1) # time.sleep(5) wpi.digitalWrite(4, 0) time.sleep(5)
import odroid_wiringpi as wpi import time wpi.wiringPiSetup() wpi.pinMode(0, 1) while True: wpi.digitalWrite(0, 1) time.sleep(5) wpi.digitalWrite(0, 0) time.sleep(2)
import odroid_wiringpi as wpi import time wpi.wiringPiSetup() wpi.pinMode(10, 1) while True: wpi.digitalWrite(10, 1) time.sleep(30)
def __init__(self, alarmPin, alarmDuration): self.tones = [650, 900] self.toneDuration = [0.4, 0.6] self.duration = alarmDuration self.pin = alarmPin wpi.pinMode(self.pin, 1)
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)
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
#!/usr/bin/env python import odroid_wiringpi as wpi import time import telnetService wpi.wiringPiSetup() wpi.pinMode(15, 1) wpi.pinMode(10, 1) wpi.pinMode(9, 1) wpi.pinMode(7, 1) wpi.pinMode(4, 1) wpi.pinMode(23, 1) wpi.pinMode(6, 1) def fire_gpio(_gpio, _timewait): wpi.digitalWrite(_gpio, 1) time.sleep(_timewait) #To jest czas wyzwalania w sekundach wpi.digitalWrite(_gpio, 0) ts = telnetService.TelnetService('admin') while True: p = ts.get_vlc_video_time('192.168.10.211', '23', 2) print(p) if (p == 22): print("22s - Lampa naftowa") fire_gpio(10, 5)
def init(): gpio.wiringPiSetup() gpio.pinMode(8, 1) gpio.pinMode(9, 1) gpio.pinMode(7, 1) gpio.pinMode(0, 1)
import odroid_wiringpi as wiringpi # wiringpi.wiringPiSetupGpio() # # PIN_TO_PWM = 33 # # # wiringpi.softPwmWrite(PIN_TO_PWM, 10) # wiringpi.delay(2000) OUTPUT = 1 PIN_TO_PWM = 23 wiringpi.wiringPiSetup() wiringpi.pinMode(PIN_TO_PWM, OUTPUT) wiringpi.softPwmCreate(PIN_TO_PWM, 0, 100) # Setup PWM using Pin, Initial Value and Range parameters for time in range(0, 4): for brightness in range(0, 100): # Going from 0 to 100 will give us full off to full on wiringpi.softPwmWrite(PIN_TO_PWM, brightness) # Change PWM duty cycle wiringpi.delay(10) # Delay for 0.2 seconds for brightness in reversed(range(0, 100)): wiringpi.softPwmWrite(PIN_TO_PWM, brightness) wiringpi.delay(10)
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)