def main(): lcd = LCD.Adafruit_CharLCDPlate() bt = threading.Thread(target=_ButtonThread, args=(lcd, )) bt.daemon = True bt.start() lcd = LCD.Adafruit_CharLCDPlate() lcd.clear() lcd.set_color(0, 0, 1) lcd.message('Starting up...') while True: line = sys.stdin.readline().strip() r, g, b, x, y = line.split('|') lcd.clear() lcd.set_color(float(r), float(g), float(b)) lcd.message('%s\n%s' % (x, y))
def __init__(self, line1, line2): threading.Thread.__init__(self) self.daemon = True self.lcd = LCD.Adafruit_CharLCDPlate() self.turnOn() self.line1 = line1 self.line2 = line2 self.forceUpdate = False # http://www.quinapalus.com/hd44780udg.html 5x8 # Only 0-7 are allowed # Stop self.lcd.create_char(1, [0x0, 0x0, 0xe, 0xe, 0xe, 0xe, 0x0, 0x0]) # Smily self.lcd.create_char(2, [0x0, 0xa, 0xa, 0xa, 0x0, 0x11, 0xe, 0x0]) # Wifi self.lcd.create_char(3, [0x0, 0x1f, 0x0, 0xe, 0x0, 0x4, 0x0, 0x0]) # pause self.lcd.create_char(4, [0x0, 0x0, 0xa, 0xa, 0xa, 0xa, 0x0, 0x0]) # PL self.lcd.create_char(5, [0x18, 0x14, 0x18, 0x10, 0x4, 0x4, 0x7, 0x0]) # Wait self.lcd.create_char(6, [0x1f, 0x11, 0xa, 0x4, 0xa, 0x11, 0x1f, 0x0]) # Play self.lcd.create_char(7, [0x0, 0x8, 0xc, 0xe, 0xc, 0x8, 0x0, 0x0])
def main(argv): apikey = False apiurl = 'https://www.wienerlinien.at/ogd_realtime/monitor?rbl={rbl}&sender={apikey}' st = 10 try: opts, args = getopt.getopt(argv, "hk:t:", ["help", "key=", "time="]) except getopt.GetoptError: usage() sys.exit(2) for opt, arg in opts: if opt in ("-h", "--help"): usage() sys.exit() elif opt in ("-k", "--key"): apikey = arg elif opt in ("-t", "--time"): try: tmpst = int(arg) if tmpst > 0: st = tmpst except ValueError: usage() sys.exit(2) if apikey == False or len(args) < 1: usage() sys.exit() rbls = [] for rbl in args: tmprbl = RBL() tmprbl.id = rbl rbls.append(tmprbl) global lcd lcd = lcd = LCD.Adafruit_CharLCDPlate() lcd.clear() x = 1 while True: for rbl in rbls: url = apiurl.replace('{apikey}', apikey).replace('{rbl}', rbl.id) r = requests.get(url) if r.status_code == 200: try: for monitor in r.json()['data']['monitors']: rbl.station = monitor['locationStop']['properties'][ 'title'] for line in monitor['lines']: rbl.line = line['name'] rbl.direction = line['towards'] rbl.time = line['departures']['departure'][0][ 'departureTime']['countdown'] #dumpRBL(rbl) lcdShow(rbl) time.sleep(st) except: print "some error occurred try next one ..."
def set_up_display(): lcd = LCD.Adafruit_CharLCDPlate() lcd.set_color(1.0,1.0,1.0) lcd.clear() lcd.home() lcd.set_backlight(1) return(lcd)
def main(): # Initialize the APRSGate, passing in current machine name agate = APRSGate(is_hardware) packets = agate.get_packets() # Initialize the LCD lcd = LCD.Adafruit_CharLCDPlate() lcd.set_color(1, 0, 0) # Initialize the GPS gps = GPSMouse() # Create a menu menu = PacketMenu() while True: # Poll the switches on LCD board button_num = menu.get_button(lcd) if button_num is not None: menu.update_indexes(button_num, len(packets)) menu.update_lcd(packets, lcd) # Refresh the display every refresh_rate seconds if menu.time_for_update(4): menu.update_time() last_pack_len = len(packets) packets = agate.get_packets() if len(packets) > last_pack_len: menu.blink_alert(lcd, ((1,0,0)), ((0,1,0)), 10, 0.25) menu.update_lcd(packets, lcd) # Also update the GPS coorinates menu.update_location(gps.read_position())
def on_after_startup(self): """ Runs when plugin is started. Turn on and clear the LCD. """ self._logger.info("PiPrint starting") lcd = LCD.Adafruit_CharLCDPlate() lcd.clear()
def __init__(self, threadID, name): import math import time import Adafruit_CharLCD as LCD # init thread threading.Thread.__init__(self) # create threadlock self.threadLock = threading.Lock() self.threadID = threadID self.name = name # Initialize the LCD using the pins self.lcd = LCD.Adafruit_CharLCDPlate() self.lcd.clear() self.lcd.message('initialized') # create some custom characters self.lcd.create_char(1, [2, 3, 2, 2, 14, 30, 12, 0]) self.lcd.create_char(2, [0, 1, 3, 22, 28, 8, 0, 0]) self.lcd.create_char(3, [0, 14, 21, 23, 17, 14, 0, 0]) self.lcd.create_char(4, [31, 17, 10, 4, 10, 17, 31, 0]) self.lcd.create_char(5, [8, 12, 10, 9, 10, 12, 8, 0]) self.lcd.create_char(6, [2, 6, 10, 18, 10, 6, 2, 0]) self.lcd.create_char(7, [31, 17, 21, 21, 21, 21, 17, 31]) # Make list of button value, text, and backlight color. self.buttons = ((LCD.SELECT, 'Select', (1, 1, 1)), (LCD.LEFT, 'Left', (1, 0, 0)), (LCD.UP, 'Up', (0, 0, 1)), (LCD.DOWN, 'Down', (0, 1, 0)), (LCD.RIGHT, 'Right', (1, 0, 1))) #create default color self.color = [1.0, 1.0, 1.0]
def _write_to_lcd(cls, message): """ Write a string message to the LCD. Displays the text on the LCD display. :param message: Message to display on the LCD """ cls._turn_lcd_on() lcd = LCD.Adafruit_CharLCDPlate() lcd.message(message)
def __init__(self): self.currentScreenId = 0 self.screens = [ screens.AudioControl(screenCtrl=self) ] self.lcd = LCD.Adafruit_CharLCDPlate() self.previousBtnState = None
def __init__(self): self.clock = ipclock.ipclock() self.lcd = LCD.Adafruit_CharLCDPlate() self.message_queue = Queue() self.message_queue.put(lambda: self.clock.display()) run_thread = threading.Thread(target=self.run, args=()) run_thread.daemon = True run_thread.start()
def display_LCD(time, tempc, tempf): try: lcd = LCD.Adafruit_CharLCDPlate() except: return lcd.set_color(1.0, 1.0, 1.0) lcd.clear() lcd.message('%5.1f F %5.1f C \n%s'%(tempf, tempc, time))
def __init__(self, hplayer): super(KeypadInterface, self).__init__(hplayer, "KEYPAD") try: self.lcd = LCD.Adafruit_CharLCDPlate() self.lcd.set_color(0, 0, 0) except: self.log("LCD Keypad not found ...") self.lcd = None
def race(): # Let's us know function was called io.setmode(io.BCM) lcd = LCD.Adafruit_CharLCDPlate() global startGate global lane1 global lane2 global lane3 startGate = 23 lane1 = 24 lane2 = 25 lane3 = 26 io.setup(startGate, io.IN, pull_up_down=io.PUD_UP) io.setup(lane1, io.IN, pull_up_down=io.PUD_UP) io.setup(lane2, io.IN, pull_up_down=io.PUD_UP) io.setup(lane3, io.IN, pull_up_down=io.PUD_UP) lcd.set_color(1.0, 1.0, 1.0) lcd.clear() lcd.message(' START YOUR \n ENGINES!!!') print("Race Starting") time.sleep(1) # Waiting for startGate to Rise because of Pull Up io.wait_for_edge(startGate, io.RISING) time.sleep(1) # When startGate rises records time global startTime startTime = time.time() print(startTime) # Adding interrupts for lanes # When they are called will # trigger their distinct function io.add_event_detect(lane1, io.FALLING, callback=timeLane1, bouncetime=1000) io.add_event_detect(lane2, io.FALLING, callback=timeLane2, bouncetime=1000) io.add_event_detect(lane3, io.FALLING, callback=timeLane3, bouncetime=1000) io.wait_for_edge(startGate, io.FALLING) global time1 global time2 global time3 time1 = "{0:.2f}".format(time1) time2 = "{0:.2f}".format(time2) time3 = "{0:.2f}".format(time3) print(str(time1) + " " + str(time2) + " " + str(time3)) lcd.clear() lcd.message(' L1 L2 L3 \n' + ' ' + time1 + ' ' + time2 + ' ' + time3)
def __init__(self): self.volume = \ int(commands.getoutput('amixer sget PCM | awk -F"[][%]" \'/dB/ { print $2 }\'')) self.lcd = \ LCD.Adafruit_CharLCDPlate() self.status = MyPi.STATUS_PLAYING self.menu_index = 0 self.radio_station_index = 0 self.load_radio_stations() self.player_pid = None
def __init__(self): # constants self.__data = data.LCDData(LCD.Adafruit_CharLCDPlate()) self.__util = util.LCDUtil(self.__data) self.__events = events.Events(self.__data, self.__util) self.__filename = "" self.__synchronous_events = synchronousEvent.SynchronousEventQueue() self.__is_LCD_printing = False
def initLCDScreen(): #set up the LCD object for writing messages, etc. try: global lcd app_log.info("Initializing LCD screen.") lcd = LCD.Adafruit_CharLCDPlate() lcd.clear() lcd.message(readyMessage) lcd.set_backlight(1.0) app_log.info("LCD screen initialized OK!") except Exception as ex: app_log.info("Error trying to init LCD screen: " + str(ex.message))
def handle_sigterm(signum=None, frame=None): """Handle sigterm Graciously shutdown when we receive a SIGTERM. * Turn off display * Turn off backlight * Exit script """ lcd = LCD.Adafruit_CharLCDPlate() lcd.clear() lcd.enable_display(False) lcd.set_backlight(False) sys.exit(0)
def main(): # Get the LCD object lcd = LCD.Adafruit_CharLCDPlate() # Create the menu UI menu = MainMenu(lcd) menu.add_item(HiWorldAction("Say Hi!")) menu.add_item(PrintButtonAction("Test buttons")) menu.add_item(SystemCheckAction("System check")) menu.add_item(ShutDownAction("Shutdown")) # Start the UI menu.run()
def __init__(self): import Adafruit_CharLCD as LCD self.lcd = LCD.Adafruit_CharLCDPlate() self.buttons = (LCD.SELECT, LCD.LEFT, LCD.UP, LCD.DOWN, LCD.RIGHT) self.lcd.set_color(0, 0, 0) self.lcd.clear() self.lcd.enable_display(True) self.lcd.show_cursor(False) self.lcd.message('Ready') self.last_state = {} self.LEFT = LCD.DOWN self.RIGHT = LCD.RIGHT self.SELECT = LCD.SELECT
def __init__(self, config, core): super(FrontendAdafruitCharLCDPlate, self).__init__() self.input_manager = InputManager() self.display_object = DisplayObject() if True: import Adafruit_CharLCD as LCD self.display = LCD.Adafruit_CharLCDPlate() else: from web_socket_lcd_simulator import WebSockectLCDSimulator self.display = WebSockectLCDSimulator() self.main_screen = MainScreen(core) self.running = True
def init(self): # initialize the LCD plate try: lcd_plate = Adafruit_CharLCD.Adafruit_CharLCDPlate() except IOError: logger.error( "Error configuring LCD plate. Make sure it is connected.") raise self.lcd = LCD(lcd_plate) # initialize the ui self.ui = CisternUI(self.lcd, self.flow_meters) # initalize the recorder manager self.recorder_manager = RecorderManager(self.flow_meters)
def __init__(self): self.INFO = (1.0, 1.0, 0) self.ERROR = (1.0, 0, 0) self.GOOD = (0, 0.1, 0) try: import Adafruit_CharLCD self.display = Adafruit_CharLCD.Adafruit_CharLCDPlate() self.lcd_queue = Queue() self.reset_queue = Queue() except Exception, e: print('No LCD Display available') self.reset_queue = Queue() self.lcd_queue = Queue() self.display = None
def __init__(self, queue): # init the LCD self.lcd = LCD.Adafruit_CharLCDPlate() # set color to red self.lcd.set_color(1, 0, 0) self.lcd.message('Initializing...\n') self.lcd.create_char(1, [12, 18, 18, 12, 0, 0, 0, 0]) # degree symbol self.lcd.create_char(2, [0, 1, 3, 2, 14, 18, 18, 12]) # delta symbol self.modes = { "Main Menu": self.main_menu, "Observation": self.observation_mode, "Photography": self.photo_mode } self.options = None self.buttons = [[LCD.SELECT, 0], [LCD.LEFT, "Back"], [LCD.RIGHT, 3], [LCD.DOWN, 1], [LCD.UP, -1]] self.q = queue #type: Queue Thread.__init__(self)
def startProgram(events): '''Starts the countdown program and entry-point for program. ::param events:: List of events to be displayed. ''' index = 0 currentFuture = events[index] preposition = " in\n" lcd = LCD.Adafruit_CharLCDPlate() lcd_columns = lcd._cols eventSignalThread = threading.Event() currentEventThread = threading.Thread(target=calculateAndPrintMessage, args=(eventSignalThread, lcd, currentFuture[0], currentFuture[1], timeFormat)) try: while True: if lcd.is_pressed(LCD.UP): index = (index + 1) % len(events) eventSignalThread.set() # Waits until the current thread reads the signal to stop. currentEventThread.join() currentEventThread = moveToNextEvent(index, eventSignalThread, lcd) elif lcd.is_pressed(LCD.DOWN): index = (index - 1) % len(events) eventSignalThread.set() # Waits until the current thread reads the signal to stop. currentEventThread.join() currentEventThread = moveToNextEvent(index, eventSignalThread, lcd) if currentEventThread is not None and not currentEventThread.isAlive( ): eventSignalThread.clear() currentEventThread.start() time.sleep(1) except (KeyboardInterrupt): if currentEventThread is not None and currentEventThread.isAlive(): eventSignalThread.set() # Waits until the current thread reads the signal to stop. currentEventThread.join() print("Count Down Ended. Goodbye!")
def swLed(ev=None): n = 0 global Led_status global LCD lcd = LCD.Adafruit_CharLCDPlate() Led_status = not Led_status GPIO.output(LedPin, Led_status) # switch led status(on-->off; off-->on) print "LED: off" if Led_status else "LED: on" if Led_status == 1: lcd.message("LED off") else: lcd.message("LED: on") sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((SERVERIP, 8881)) print "%d : Connected to server" % n, data = "'Matts tilt switch','n', 'Tilt Detected'" sock.sendall(data) print " Sent:", data sock.close() n += 1 time.sleep(30)
def main(): # number of lines to read at a time (2 is faster) n_feed_lines = 1 for arg in sys.argv: if arg == '-2': n_feed_lines = 2 # Initialize the LCD using the pins lcd = LCD.Adafruit_CharLCDPlate() lcd.set_color(*RED) lcd.clear() signal.signal(signal.SIGINT, get_sighandler(lcd)) # create some custom characters lcd.create_char(1, DEGREE) if n_feed_lines == 1: lines = ['', ''] for line in sys.stdin: if not process_cmd(lcd, line, lines): line = reform_line(line) lines = [lines[1], line] lcd.clear() lcd.message(lines[-2] + '\n' + lines[-1]) elif n_feed_lines == 2: buf = ['', ''] buf_full = True for line in sys.stdin: if not process_cmd(lcd, line, lines): if buf_full: buf[0] = reform_line(line) buf_full = False else: buf[1] = reform_line(line) buf_full = True lcd.clear() lcd.message('\n'.join(buf))
def __init__(self): self.lcd = LCD.Adafruit_CharLCDPlate() self.lcd.clear() self.lcd.message('initialized') self.line1 = '' self.line2 = '' # create some custom characters self.lcd.create_char(1, [2, 3, 2, 2, 14, 30, 12, 0]) self.lcd.create_char(2, [0, 1, 3, 22, 28, 8, 0, 0]) self.lcd.create_char(3, [0, 14, 21, 23, 17, 14, 0, 0]) self.lcd.create_char(4, [31, 17, 10, 4, 10, 17, 31, 0]) self.lcd.create_char(5, [8, 12, 10, 9, 10, 12, 8, 0]) self.lcd.create_char(6, [2, 6, 10, 18, 10, 6, 2, 0]) self.lcd.create_char(7, [31, 17, 21, 21, 21, 21, 17, 31]) # Make list of button value, text, and backlight color. #self.buttons = ( (LCD.SELECT, 'Select', (1,1,1)), # (LCD.LEFT, 'Left' , (1,0,0)), # (LCD.UP, 'Up' , (0,0,1)), # (LCD.DOWN, 'Down' , (0,1,0)), # (LCD.RIGHT, 'Right' , (1,0,1)) ) self.buttons = ((LCD.SELECT, 'Select'), (LCD.LEFT, 'Left'), (LCD.UP, 'Up'), (LCD.DOWN, 'Down'), (LCD.RIGHT, 'Right')) #create default color #self.color=[1.0,1.0,1.0] # possible colors self.colorArray = [ 'red', 'green', 'blue', 'yellow', 'cyan', 'magenta', 'white' ] self.currentColorIndex = 0
def main(): lcd = LCD.Adafruit_CharLCDPlate() lcd.set_color(1.0, 0.0, 1.0) # Create check mark at \x01 lcd.create_char(1, SUCCESS_CHAR_CODE) # Create X mark at \x02 lcd.create_char(2, FAILURE_CHAR_CODE) menu = MainMenu(lcd) pressed_button = None while True: for button in (LCD.UP, LCD.DOWN, LCD.LEFT, LCD.RIGHT, LCD.SELECT): if lcd.is_pressed(button): if pressed_button == button: pass menu.on_button_press(button) pressed_button = button pressed_button = None
#! /usr/bin/python import time import Adafruit_CharLCD as LCD from datetime import datetime from spark import send_message_to_email import signal from config import dad_email lcd = LCD.Adafruit_CharLCDPlate() lcd.set_color(1, 0, 0) lcd.clear() # lcd.message("Hello") time_format = "%I:%M %p" menu_options = [ "Hello", "I am playing Minecraft", "Call me soon please!", "Have a good day.", "I love you Daddy!", "I'm watching a movie.", "I'm watching a movie on my phone", "I miss you very so much", "I miss you very very so much", "I miss you very very very so much" ] buttons = ((LCD.SELECT, 'Select'), (LCD.LEFT, 'Left'), (LCD.UP, 'Up'), (LCD.DOWN, 'Down'), (LCD.RIGHT, 'Right')) def get_time(): now = datetime.now() return now.strftime(time_format)
def __init__(self, **kwargs): knob_col = kwargs["kc"] knob_bright = kwargs["kb"] knob_color = (knob_col, knob_bright) previously_loaded_set = kwargs["sl"] previously_loaded_song = kwargs["s"] previously_loaded_part = kwargs["p"] #initialize parent class super(Rotary_Encoder, self).__init__(knob_color) self.lcd = Adafruit_CharLCD.Adafruit_CharLCDPlate( ) #Rotary_Encoder "has-a" lcd self.setlist = PartSongSet.Setlist() #Rotary_Encoder "has-a" Setlist self.displayed_msg = "" self.setlist_name = previously_loaded_set #load the set, song, and part that was last used that was saved to the default file self.setlist.load_setlist(SET_FOLDER + previously_loaded_set) self.current_song = self.setlist.songs.head while self.current_song.next is not None and previously_loaded_song <> self.current_song.data.name: self.current_song = self.current_song.next self.current_part = self.current_song.data.parts.head while self.current_part.next is not None and previously_loaded_part <> self.current_part.data.part_name: self.current_part = self.current_part.next # set up the Looper setup menus (set, seong, part, pedal, bpm) self.setlist_menu = self.setup_menu.add_child("Sets", self.show_setlists, self.load_set_func) self.songs_menu = self.setup_menu.add_child("Songs", self.show_songs, self.load_song_func) self.parts_menu = self.setup_menu.add_child("Parts", self.show_parts, self.load_part_func) self.pedal_menu = self.setup_menu.add_child("Pedals", self.show_pedals, self.load_pedal_func) self.bpm_menu = self.setup_menu.add_child("BPM", self.show_bpm, self.load_bpm_func) # dont let the tempo go below 40 or above 500 self.tempo_range = arange(40, 500, 0.5).tolist() self.set_song_info_message() # define power menu self.power_menu = self.menu.root.add_child("Power", self.set_menu_data_message) self.power_menu.menu_data_prompt = "Power Off?" self.power_menu.menu_data_items = ["NO yes", "no YES"] self.power_menu.menu_data_dict = { "NO yes": self.change_menu_nodes, "no YES": self.power_off } # build global menu self.knobcolor_menu = self.global_menu.add_child( "Knob Color", self.show_knob_colors, self.load_color_func) self.knobbrightness_menu = self.global_menu.add_child( "Knob Brightness", self.show_brightness, self.load_brightness_func) #variables for the rotary movement interpretation loop self.last_good_seq = 0 self.last_move = None #keeps time for last rotary turn in seconds self.last_rotary_turn = 0 self.menu.current_node.current_child = 0