def __init__(self): self.PIN1 = 16 self.b = buttons.Button(self.PIN1, cb=self.set_btn_evt) self.lcd = i2c_lcd.lcd(0x3f) self.lcd.lcd_clear() self.lcd_mq = Queue() self.lcd_evt = Event()
def main(): try: # initialize sensors and output modules lcd = RPi_I2C_driver.lcd() red_led = LED(GPIO_PINS['red_led']) green_led = LED(GPIO_PINS['green_led']) button = Button(GPIO_PINS['button']) while True: # wait for button to be pressed to take image button.wait_for_press() # capture image from camera img_fp = capture_image() # detect if person has face mask or not mask_detected = detect_face_mask(img_fp) if mask_detected: # flash green led and display on LCD lcd.lcd_display_string("Access granted!", 1) green_led.on() sleep(3) lcd.lcd_clear() green_led.off() else: # flash red led and display on LCD lcd.lcd_display_string("Access denied!", 1) red_led.on() sleep(3) lcd.lcd_clear() red_led.off() except KeyboardInterrupt: print("[INFO] Terminating")
def main(): mylcd = RPi_I2C_driver.lcd() while (True): mylcd.lcd_display_string("Distance: ") mylcd.lcd_display_string("Distance: ") time.sleep(1)
def main(args): # 초기화 lcd = RPi_I2C_driver.lcd(LCD_ADDR) # 기능구현 try: while True: # Print a message to the LCD. lcd.clear() lcd.printdata("Hello, ") time.sleep(1) # At 0.5c second interval " World!!!" Print lcd.printdata(" World!", 0.5) time.sleep(1) for i in range(16): # Move the screen to the right lcd.scrollDisplayLeft() time.sleep(0.4) for i in range(16): # Move the screen to the right lcd.scrollDisplayRight() time.sleep(0.4) except KeyboardInterrupt: print(" KeyboardInterrupt") return 0
def main(): mylcd = RPi_I2C_driver.lcd() # oled = ssd1306(port=2, address=0x3C) while True: trello(mylcd) time.sleep(60 * 10)
def main(): mylcd = RPi_I2C_driver.lcd() # oled = ssd1306(port=2, address=0x3C) while True: trello(mylcd) time.sleep(60*10)
def main(): Celsius = getTemp(address) mylcd = RPi_I2C_driver.lcd() while (True): mylcd.lcd_display_string( "Time: " + str(datetime.datetime.now().time()), 1) mylcd.lcd_display_string("Temp: " + str(Celsius) + " C", 2) time.sleep(1)
def out_ke_lcd(): mylcd = RPi_I2C_driver.lcd() # test 2 mylcd.lcd_clear() mylcd.lcd_display_string(" BANANY READY ", 1) mylcd.lcd_display_string("----WELCOME!----", 2) sleep(3) mylcd.lcd_clear() mylcd.lcd_display_string("WiFi:BANANY01", 1) mylcd.lcd_display_string("PWD:bananybanany", 2) sleep(3)
def setLcd(self, line1, line2): """Show the lines on the LCD, if present""" try: if self.lcd is None: #print("Creating LCD", self.lcd) self.lcd = RPi_I2C_driver.lcd(0x3f) print(self.lcd) #self.lcd.lcd_clear() if line1 is not None: self.lcd.lcd_display_string(line1, 1) if line2 is not None: self.lcd.lcd_display_string(line2, 2) except Exception as e: #print("Trapped exception when creating LCD", e) self.lcd = None
def exit(): """ Exit handler, which clears all custom chars and shuts down the display. """ try: if not DISPLAY: lcd = RPi_I2C_driver.lcd() lcd.backlight(0) if DEBUG: print "exit()" GPIO.cleanup() except: # avoids ugly KeyboardInterrupt trace on console... pass
def main(): """Main""" sensor = BME280(mode=BME280_OSAMPLE_8) mylcd = RPi_I2C_driver.lcd() mylcd.lcd_clear() while True: try: read_data(sensor).print_data_lcd(mylcd) time.sleep(2) except KeyboardInterrupt: mylcd.lcd_clear() time.sleep(1) mylcd.backlight(0) sys.exit()
def lcd_i2c_driver(): import RPi_I2C_driver lcd = RPi_I2C_driver.lcd() def write_line(self, text, line): logging.info('writing to line %d: %s', line, text) self.lcd_display_string(text, line + 1) def clear_line(self, line): self.lcd_display_string(' ' * 16, line + 1) lcd.clear_line = types.MethodType(clear_line, lcd) lcd.write_line = types.MethodType(write_line, lcd) return lcd
def __init__(self, pi): scroll = "scroll" function = "function" dictionary = "dictionary" list = "list" self.pi = pigpio.pi() self.motor1_enable_pin = 26 #enable pin for turning motor on/off self.motor2_enable_pin = 19 self.pi.set_mode(self.motor1_enable_pin, pigpio.OUTPUT) self.pi.set_mode(self.motor2_enable_pin, pigpio.OUTPUT) self.pi.write(self.motor1_enable_pin, 0) self.pi.write(self.motor2_enable_pin, 0) self.lcd = RPi_I2C_driver.lcd() #Create lcd object self.lcd.lcd_load_custom_chars( [[0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F]]) self.teensy = serial.Serial( "/dev/ttyACM0", 115200) #Initialize teensy serial communication self.cursor = 0 #Cursor value (relative to the entire screen dictionary) self.local_cursor = 0 #Cursor value (relative to the display size -- i.e. self.disp_rows) self.start = 0 #Holder remember which item to print first on lcd... #INPUT THE SIZE OF THE DISPLAY BELOW: self.disp_cols = 20 self.disp_rows = 4 self.state = "HOME" #Start state will be home screen self.path = [ ] #Path is used to remember the current "location" in the gui dictionary. Will be a string of values to enter in dictionary self.home_screen = [ " Sand Speed [%]: ", " Belt Speed [%]: ", " Thickness [\"]:", " Direction: ", " Home Belt" ] home_screen = [[scroll, 0, 0, 100], [scroll, 0, 0, 100], [list, 0, self.range(0.125, 4, 0.125)], [list, 0, ["FORWARD", "REVERSE"]], [function, self.home_belt]] self.home_dict = self.make_screen_dict(self.home_screen, home_screen) self.menu_dict = self.home_dict
def lcd_i2c_driver(): import RPi_I2C_driver lcd = RPi_I2C_driver.lcd() def write_line(self, text, line): logging.info('writing to line %d: %s', line, text) self.lcd_display_string(text, line+1) def clear_line(self, line): self.lcd_display_string(' ' * 16, line+1) lcd.clear_line= types.MethodType(clear_line, lcd) lcd.write_line = types.MethodType(write_line, lcd) return lcd
def __init__(self, config, core): super(LCDFrontend, self).__init__() self.lcd = RPi_I2C_driver.lcd() if config['lcd']['display_temperature']: bus = SMBus(config['lcd']['bme280_i2c_bus']) self.bme280 = BME280(i2c_dev=bus) else: self.bme280 = None self.ticker = Ticker(self.actor_ref, LCDFrontend.TICK_INTERVAL) self.ticker.start() self.stream_title = "" self.st_pos = 0 self.lifetime = 0 self.lcd_on = True self.volume = 0
def go(self): if self.etat == 0 : try: self.lcd = RPi_I2C_driver.lcd(i2cBus, r.i2cLCD) self.etat = 1 except : self.etat = 0 if self.etat == 1 : try: self.lcd.lcd_reinit() self.lcd.lcd_clear() self.etat = 2 except : self.etat = 1 i = 1 for el in self.defaut_list : try: self.lcd.lcd_display_string_pos(el,i,0) except : self.etat = 1 i += 1 for el in self.devices_list : if el[0].modif != 0 : el[0].modif = 0 ch = el[1]() l = el[4] - len(ch) if l >= 0 : txt=ch+" "*l elif l < 0 : txt="#"*el[4] i = 0 while i < len(txt): self.shadow[el[3]][el[2]+i] = txt[i] i += 1 if self.etat > 1 : try: self.lcd.lcd_display_string_pos(txt,el[3]+1,el[2]) except : self.etat = 1
def __init__(self, parent_window): Gtk.Box.__init__(self, spacing=30) self.parent_window = parent_window # Creem un container vertical box: self.vBox = Gtk.VBox(spacing=50) self.pack_start(self.vBox, True, False, 50) self.label = Gtk.Label(label="Please, login with your university card") self.label.set_name("login") self.label.set_property("width-request", 300) self.label.set_property("height-request", 50) self.vBox.pack_start(self.label, True, False, 0) self.entry = Gtk.Entry() self.entry.connect("activate", self.onLogin) self.vBox.pack_start(self.entry, True, False, 0) self.l = RPi_I2C_driver.lcd() self.l.lcd_display_string_pos("Please, login with", 2, 1) self.l.lcd_display_string("your university card", 3) threading.Thread(target=self.nfcThread, daemon=True).start()
#robogaia.com # the temperatures are in fahrenheit # temperature_hysteresis sets how low the temperature #goes until the heater starts import smbus import time import datetime from subprocess import call import sys import ignitionlcd import RPi_I2C_driver bus = smbus.SMBus(1) lcd = RPi_I2C_driver.lcd() #I2C addres address = 0x4d #this will tell how low will go until the heater starts again below the set point temperature_hysteresis = 4 isHeating = True def get_fahrenheit_val(): data = bus.read_i2c_block_data(address, 1,2) val = (data[0] << 8) + data[1] return val/5.00*9.00/5.00+32.00 def get_celsius_val(): data = bus.read_i2c_block_data(address, 1,2) val = (data[0] << 8) + data[1]
def idle_screen(): mylcd = RPi_I2C_driver.lcd() mylcd.lcd_clear() mylcd.lcd_display_string(direk[2], 1) mylcd.lcd_display_string(hdd + "B Free", 2)
def __init__(self): self.display = RPi_I2C_driver.lcd() self.update("Loading,", 1) self.update("Please wait...", 2) self.display.lcd_load_custom_chars(spinner_chars)
# requires RPi_I2C_driver.py import RPi_I2C_driver from time import * ADDRESS = 0x3E mylcd = RPi_I2C_driver.lcd(ADDRESS) mylcd.lcd_clear() mylcd.lcd_display_string("Test displeje 2004", 1) mylcd.lcd_display_string(" Custom chars", 2) mylcd.lcd_display_string(" Custom chars", 3) mylcd.lcd_display_string(" Custom chars", 4) sleep(2) # 2 sec delay mylcd.lcd_clear() # let's define a custom icon, consisting of 6 individual characters # 3 chars in the first row and 3 chars in the second row fontdata1 = [ # Char 0 - Upper-left [0x00, 0x00, 0x03, 0x04, 0x08, 0x19, 0x11, 0x10], # Char 1 - Upper-middle [0x00, 0x1F, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00], # Char 2 - Upper-right [0x00, 0x00, 0x18, 0x04, 0x02, 0x13, 0x11, 0x01], # Char 3 - Lower-left [0x12, 0x13, 0x1b, 0x09, 0x04, 0x03, 0x00, 0x00], # Char 4 - Lower-middle
def __init__(self, addresses): for i in addresses: print("Initializing LCD on", i) self.lcds[i] = RPi_I2C_driver.lcd(i) print(self.lcds)
# library modified 5 Jul 2009 # by Limor Fried (http://www.ladyada.net) # example added 9 Jul 2009 # by Tom Igoe # modified 22 Nov 2010 # by Tom Igoe # modified 7 Nov 2016 # by Arturo Guadalupi # modified Python 20 June 2019 # by eleparts (yeon) (https://www.eleparts.co.kr/) ''' # include the library import RPi_I2C_driver from time import * # RPi_I2C_driver.lcd( I2C address ) lcd = RPi_I2C_driver.lcd(0x27) # lcd = RPi_I2C_driver.lcd(0x27, 16, 2) # Print a message to the LCD. lcd.print("hello, world!") while True: # Turn off the blinking cursor: lcd.noBlink() sleep(3) # Turn on the blinking cursor: lcd.blink() sleep(3)
import RPi_I2C_driver as I2C_LCD_driver import socket import fcntl import struct mylcd = I2C_LCD_driver.lcd() def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa( fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', ifname[:15]))[20:24]) mylcd.lcd_display_string("IP Address:", 1) try: mylcd.lcd_display_string(get_ip_address('eth0'), 2) except IOError: mylcd.lcd_display_string(get_ip_address('wlan0'), 2)
# How much the volume status screen will last before returning to displaying current song volume_screen_duration = 300 # x10, it will last for 300x10 = 3000 ms (3 seconds) ######################################################################################### ######### MPD PARAMETERS ############## # Only if you know what you're doing! # HOST = 'localhost' # PORT = '6600' # PASSWORD = False # CON_ID = {'host':HOST, 'port':PORT} # ######################################### # Initialize LCD lcd = LCD.lcd() lcd.setWidth(lcd_columns) # MPD client object instance2 client = MPDClient() client_cntrl = MPDClient() # Current data # state: 0 (for stopped), 1 (for playing), 2 (for paused) # artist: artist name (for files), radio name (for radio stations) # song: song name (for files), ARTIST - SONG (for radio stations, if available) # type: 0 (for files), 1 (for radio) data = {'state': 0, 'artist': '', 'title': '', 'type': 0, 'volume': 0} data_changed = False; # Used to indicate that data has changed to LCD display thread data_changed_vol = False; # Used to indicate that volume has changed to LCD display thread
import json import os from dotenv import load_dotenv from azure.iot.device.aio import IoTHubDeviceClient, ProvisioningDeviceClient # The connection details from IoT Central for the device load_dotenv() id_scope = os.getenv("ID_SCOPE") primary_key = os.getenv("PRIMARY_KEY") device_id = "pi-environment-monitor" # initial setup of DHT11, LCD1602 and ADC0832 for photoresistor GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) DHT_SENSOR = dht11.DHT11(pin=4) mylcd = lcd1602.lcd() ADC0832.setup() # Gets telemetry from the Grove sensors # Telemetry needs to be sent as JSON data async def get_telemetry() -> str: # The dht call returns the temperature and the humidity, # we only want the temperature, so ignore the humidity result = DHT_SENSOR.read() temperature = result.temperature humidity = result.humidity light = ADC0832.getResult() - 80 light = min(max(light, 0), 100) print(f'light intensity: = {light}') # The temperature can come as 0, meaning you are reading # too fast, if so sleep for a second to ensure the next reading
#!/usr/bin/python3 import RPi_I2C_driver from time import * import netifaces as ni import psutil import os REFRESH_DELAY = 0.7 CYCLE_CLOCK = 4 CYCLE_IP = 7 CYCLE_END = 7 PSTFX_THSHD = 8*1024**2 # 8Mbps = 1MB/s l = RPi_I2C_driver.lcd(0x27,16,2) l.lcd_clear() fontdata1 = [ # 0: Clock [0x00,0x0E,0x1B,0x1B,0x19,0x1F,0x0E,0x00], # 1: LAN [0x00,0x1F,0x11,0x11,0x11,0x1B,0x0E,0x00], # 2: WiFi [0x00,0x0E,0x11,0x04,0x0A,0x00,0x04,0x00], # 3: WiFi(external) [0x1F,0x11,0x0E,0x1B,0x15,0x1F,0x1B,0x1F], # 4: Up (kbps) [0x04,0x0E,0x1F,0x00,0x08,0x0A,0x0C,0x0A], # 5: Down (kbps) [0x08,0x0A,0x0C,0x0A,0x00,0x1F,0x0E,0x04], # 6: Up (mbps)
def main(): mainBox = BoxClimate("mainBox") ## input_state = GPIO.input(25) ## print("Test lamp H0 ... ") ## if input_state == False: #### lastTimeLampOn = datetime.datetime.now() ## print colored('LAMP IS ON', 'green') ## time.sleep(7) ## ## It's Ok ! ## ## ## else: ## print colored('LAMP IS OFF', 'red') ## time.sleep(2) ## lNow = datetime.datetime.now() ## deltaTime = lNow - lastTimeLampOn ## print (deltaTime) ## duration_in_s = deltaTime.total_seconds() ## minutes = divmod(duration_in_s, 60)[0] ## print (minutes) ## if minutes>=lampCooling: ## GPIO.output(19, False) ## time.sleep(1) lastTimeLampOn = datetime.now() lastTimeLampOff = datetime.now() lastTurnOff = datetime.now() lNow = datetime.now() lastComRead = datetime.now() timesOfDay = 0 lampStat = 0 mylcd = RPi_I2C_driver.lcd() fontdata1 = [ [ 0b00000, 0b00111, 0b01000, 0b11010, 0b10101, 0b01000, 0b00111, 0b00000 ], [ 0b00100, 0b11111, 0b00000, 0b10101, 0b01010, 0b00000, 0b11111, 0b00000 ], [ 0b01100, 0b11111, 0b00110, 0b11111, 0b11111, 0b00110, 0b11111, 0b01100 ], [ 0b00110, 0b00110, 0b01100, 0b01100, 0b11000, 0b11000, 0b10000, 0b10000 ], [ 0b10001, 0b10001, 0b10001, 0b10001, 0b10001, 0b10001, 0b10001, 0b10001 ], [ 0b01100, 0b01100, 0b00110, 0b00110, 0b00011, 0b00011, 0b00001, 0b00001 ], ] fontdata2 = [ [ 0b11111, 0b11000, 0b10111, 0b00101, 0b01010, 0b10111, 0b11000, 0b11111 ], [ 0b11111, 0b00000, 0b11111, 0b01010, 0b10101, 0b11111, 0b00000, 0b11111 ], [ 0b11111, 0b01101, 0b00101, 0b10111, 0b01111, 0b00101, 0b01101, 0b11111 ], [ 0b11101, 0b11111, 0b11111, 0b11111, 0b11111, 0b01111, 0b11111, 0b11111 ], [ 0b11111, 0b01011, 0b10111, 0b01011, 0b11111, 0b11111, 0b11111, 0b11101 ], [ 0b11111, 0b11111, 0b11101, 0b11111, 0b11111, 0b11111, 0b10111, 0b11111 ], ] while True: now = datetime.now() ## this is main loop if now > timeOn and now < timeOff: # DAY now = datetime.now() # LampOn = now - lastTimeLampOn deltaTime = now - lNow cls() print("DAY " + datetime.now().strftime("%Y/%m/%d %H:%M:%S") + " delta " + str(31 - deltaTime.seconds)) input_state = GPIO.input(25) if input_state == False: print colored('LAMP IS ON', 'green') else: print colored('LAMP IS OFF', 'red') print(" " + str(LampOn)) duration_in_s = deltaTime.total_seconds() minutes = divmod(duration_in_s, 60)[0] print(" LAMP IS ON " + str(minutes) + "minutes") print("############" + mainBox.name + "############") mainBox.getInfo() if deltaTime.seconds >= 5: print("OBJECT START") mainBox.setState() print("OBJECT END") print("Test lamp ... ") input_state = GPIO.input(25) if input_state == False: ## lastTimeLampOn = datetime.now() print colored('LAMP IS ON', 'green') time.sleep(7) ## It's Ok ! ## else: print colored('LAMP IS OFF', 'red') time.sleep(2) lNow = datetime.now() deltaTime = lNow - lastTimeLampOn print(deltaTime) duration_in_s = deltaTime.total_seconds() minutes = divmod(duration_in_s, 60)[0] print(minutes) if minutes >= lampCooling: GPIO.output(19, False) time.sleep(1) GPIO.output(19, True) time.sleep(2) input_state = GPIO.input(25) if input_state == False: print colored("____TRY TURN ON HID LAMP____", "green") lampStat = 1 if timesOfDay <> 1: mylcd.lcd_load_custom_chars(fontdata1) mylcd.lcd_write(0x8D) mylcd.lcd_write_char(0) mylcd.lcd_write_char(1) mylcd.lcd_write_char(2) mylcd.lcd_write(0xCD) mylcd.lcd_write_char(3) mylcd.lcd_write_char(4) mylcd.lcd_write_char(5) timesOfDay = 1 lastTimeLampOn = datetime.now() else: timesOfDay = 0 lampStat = 0 time.sleep(7) lNow = datetime.now() else: ## NIGHT now = datetime.now() LampOff = now - lastTurnOff deltaTime = now - lNow cls() print("NIGHT " + datetime.now().strftime("%Y/%m/%d %H:%M:%S") + " delta " + str(30 - deltaTime.seconds)) input_state = GPIO.input(25) if input_state == False: print colored('LAMP IS ON', 'red') else: print colored('LAMP IS OFF', 'green') ## deltaTime = lNow - lastTimeLampOn print(" " + str(LampOff)) duration_in_s = deltaTime.total_seconds() minutes = divmod(duration_in_s, 60)[0] print(" LAMP IS OFF " + str(minutes) + "minutes") if deltaTime.seconds >= 10: print("Test lamp ... ") print("OBJECT START") ## mainBox.setNeedState() ## mainBox.setState() ## mainBox.printx() mainBox.getInfo() #mainBox.setTermHumHome() mainBox.openComPort(0) ## mainBox.setTermHumHome() #print (mainBox.lastState) print("OBJECT END") input_state = GPIO.input(25) if input_state == False: lastTimeLampOn = datetime.now() print colored('LAMP IS ON', 'yellow') print colored("____TRY TURN OFF HID LAMP____", "yellow") GPIO.output(19, True) time.sleep(1) GPIO.output(26, False) time.sleep(1) GPIO.output(26, True) time.sleep(1) GPIO.output(19, True) time.sleep(1) input_state = GPIO.input(25) if input_state == True: lastTurnOff = datetime.now() print colored('LAMP IS SHUTDOWN', 'green') mylcd.lcd_load_custom_chars(fontdata2) mylcd.lcd_write(0x8D) mylcd.lcd_write_char(0) mylcd.lcd_write_char(1) mylcd.lcd_write_char(2) mylcd.lcd_write(0xCD) mylcd.lcd_write_char(3) mylcd.lcd_write_char(4) mylcd.lcd_write_char(5) time.sleep(7) else: print colored('ALARM!!! LAMP IS NOT POWER OFF', 'red') time.sleep(20) ##################################################### ## TELEGRAM BOT !!! ##################################################### lNow = datetime.now() ## deltaTime = lNow - lastTimeLampOn ## else: print colored('LAMP IS OFF', 'green') #time.sleep(30) lNow = datetime.now() ## deltaTime = lNow - lastTimeLampOn print(" " + str(deltaTime)) duration_in_s = deltaTime.total_seconds() minutes = divmod(duration_in_s, 60)[0] print(" LAMP IS OFF " + str(minutes) + "minutes") time.sleep(5) ## now = datetime.now() ## LampOff = now - lastTurnOff ## deltaTime = now - lNow #NIGHT ## mylcd.lcd_load_custom_chars(fontdata1) ## mylcd.lcd_write(0x8D) ## mylcd.lcd_write_char(0) ## mylcd.lcd_write_char(1) ## mylcd.lcd_write_char(2) ## mylcd.lcd_write(0xCD) ## mylcd.lcd_write_char(3) ## mylcd.lcd_write_char(4) ## mylcd.lcd_write_char(5) ## time.sleep(2) ## mylcd.lcd_write(0x8D) ## mylcd.lcd_write_char(6) ## mylcd.lcd_write_char(7) ## mylcd.lcd_write_char(8) time.sleep(1)
from apscheduler.schedulers.background import BackgroundScheduler scheduler = BackgroundScheduler() #PROJECT STRINGS projectname = "Atlantis" ecname = "EC" phname = "pH" tempname = "C" humidityname = "H" sensorstart = projectname + " " + "SEN ON" controlstart = projectname + " " + "CTRL ON" #INITILIZATION mylcd = RPi_I2C_driver.lcd() #raspiI2C driver GPIO.setmode(GPIO.BOARD) # GPIO.BOARD mode GPIO.setwarnings(False) # disable warnings - Your not a noob to want warnings config = { 'bz': 13, 'dz1': 15, 'dz2': 16, 'exfan1': 18, 'exfan2': 22, 'ofan': 29, 'ac': 31, 'rm1': 36, 'rl1': 37 } print(config) for key in config:
import sys sys.path.insert(0, "/home/pi/python_modules") import RPi_I2C_driver as i2c import re import time import datetime from board import * from pad4pi import rpi_gpio from subprocess import Popen, PIPE import digitalio #import adafruit_character_lcd.character_lcd as characterlcd mylcd = i2c.lcd() ROW_PINS = [21, 20, 16, 12] COL_PINS = [26, 19, 13, 6] KEYPAD = [[1, 2, 3, "A"], [4, 5, 6, "B"], [7, 8, 9, "C"], ["*", 0, "#", "D"]] factory = rpi_gpio.KeypadFactory() keypad = factory.create_keypad(keypad=KEYPAD, row_pins=ROW_PINS, col_pins=COL_PINS) led = digitalio.DigitalInOut(D23) led.direction = digitalio.Direction.OUTPUT print(led.value) safelight1 = digitalio.DigitalInOut(D7) safelight.direction = digitalio.Direction.OUTPUT safelight2 = digitalio.DigitalInOut(D8) safelight.direction = digitalio.Direction.OUTPUT safelight3 = digitalio.DigitalInOut(D25) safelight.direction = digitalio.Direction.OUTPUT
import serial # <----Rpi import memo import uart import RPi_I2C_driver import ac_control01 import thegpio from unittest import case port_def = "/dev/ttyUSB0" # <----Rpi #=============================================================================== # MAIN SETUP #=============================================================================== # LCD mylcd = RPi_I2C_driver.lcd(0x3F) #-------------------------------------------------------------- # Check logging... # Start new log file a day. #-------------------------------------------------------------- memo.checkSystemNote() memo.checkNoteFolder() memo.checkMemoFolder[1]() #--------------------------------------------- # Program header #--------------------------------------------- print "\n\n\n"
import RPi_I2C_driver from lift_state import LiftState, BlowerState, ValveState from app import socketio import json import datetime import logging status_lcd = RPi_I2C_driver.lcd() logging.basicConfig( filename='/home/pi/lift.log', level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") state_object = { "updated": datetime.datetime.now().isoformat(), "lift_state": LiftState.UP, "blower_state": BlowerState.OFF, "master_valve_state": ValveState.CLOSED, "rear_valve_state": ValveState.CLOSED, "front_valve_state": ValveState.CLOSED, "current_countdown": 0, "messages": [] } class LiftStatus(object): @staticmethod def get_state_object(): return state_object @staticmethod
import RPi_I2C_driver import os from time import * mylcd = RPi_I2C_driver.lcd() mylcd.backlight(1) print("ON, and LCD has been reset")
from time import sleep import datetime from math import floor import sys sys.path.insert(0, "lcd/rpi-lcd") import RPi_I2C_driver logging.basicConfig( level=logging.DEBUG, format='[%(levelname)s] (%(threadName)-10s) %(message)s', ) # get a display display = RPi_I2C_driver.lcd() GPIO.setmode(GPIO.BCM) # button setup START_PAUSE_BTN_PIN = 24 RESET_BTN_PIN = 7 GPIO.setup(START_PAUSE_BTN_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(RESET_BTN_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # rele setup pinSiren = 4 # init rele pin as output, and turns it off GPIO.setup(pinSiren, GPIO.OUT) GPIO.output(pinSiren, GPIO.HIGH)