def printing_ip_on_display(): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("gmail.com",90)) local_ip = s.getsockname()[0] geniePi.genieWriteStr(1, local_ip) s.close() return local_ip
def turn_led(status): if (status == ON): print >>sys.stderr, ("Turning on LED!") geniePi.genieWriteObj(19, 0, 1) geniePi.genieWriteStr(0, MESSAGE_ON) else: print >>sys.stderr, ("Turning off LED!") geniePi.genieWriteObj(19, 0, 0) geniePi.genieWriteStr(0, MESSAGE_OFF)
def printing_ip_on_display(): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("gmail.com",90)) local_ip = s.getsockname()[0] time.sleep(0.1) geniePi.genieWriteStr(1, local_ip) time.sleep(0.1) geniePi.genieWriteObj(19, 0, 1) time.sleep(0.1) geniePi.genieWriteStr(0, MESSAGE_ON) s.close() return local_ip
def run(self): # Infinite look until event signalling exit self._logger.debug('Starting clock thread') while not self._kill_event.is_set(): # Get the current time as a string, and update display if different datetime_str = datetime.now().strftime('%A, %B %d %H:%M') if (datetime_str != self._prev_datetime) and not self._display_error: geniePi.genieWriteStr(CLOCK_ADD, datetime_str) self._prev_datetime = datetime_str # Delay between date string updates - will give reasonable lag for the clock update self._kill_event.wait(1) # 1 second self._logger.debug('Clock thread exiting.')
def turn_on_off_led(status): geniePi.genieSetup(PORT, BAUD_RATE) if (status == 1): print("Turning on LED!") time.sleep(0.1) geniePi.genieWriteObj(19, 0, 1) time.sleep(0.1) geniePi.genieWriteStr(0, MESSAGE_ON) else: print("Turning off LED!") time.sleep(0.1) geniePi.genieWriteObj(19, 0, 0) time.sleep(0.1) geniePi.genieWriteStr(0, MESSAGE_OFF) geniePi.genieClose()
def recover_data(ip): while True: # Add all the return bottons here. event = geniePi.genieReadObj(geniePi.GENIE_OBJ_WINBUTTON, 7) if event == 1: print ("valor de event: %d") % event if (event == 1): print >>sys.stderr, ("Recovering info to display!") time.sleep(0.1) geniePi.genieWriteObj(19, 0, 1) time.sleep(0.1) geniePi.genieWriteStr(0, MESSAGE_ON) time.sleep(0.1) geniePi.genieWriteStr(1, ip) time.sleep(0.1) event = 0
def opening_serial_communication(): geniePi.genieSetup(PORT, BAUD_RATE) geniePi.genieWriteStr(0, 'Conexao Local') geniePi.genieWriteObj(0x0E, 0x00, 0x01) #time.sleep(1) geniePi.genieWriteStr(1, 'Pronto para operar!') while True: event = geniePi.genieReadObj(geniePi.GENIE_OBJ_WINBUTTON, 1) if event == 1: break #time.sleep(0.2) geniePi.genieWriteStr(2, 'Procurando Placas...') for i in range(1,5): devices = bus.scan(i) geniePi.genieWriteStr(i+2, str(devices)) geniePi.genieWriteStr(2, 'Placas encontradas!')
def scan_boards(): geniePi.genieWriteStr(2, 'Searching boards...') devices = bus.scan() print devices for i in range(1,5): time.sleep(0.1) geniePi.genieWriteStr(i+2, str(devices[i-1])) geniePi.genieWriteStr(2, 'Found boards!') print >>sys.stderr, ("Scan realizado com sucesso!\n")
def opening_serial_communication(f): setup_port() printing_ip_on_display() time.sleep(0.2) geniePi.genieWriteStr(2, 'Searching boards...') devices = bus.scan() for i in range(1,5): geniePi.genieWriteStr(i+2, str(devices[i-1])) geniePi.genieWriteStr(2, 'Found boards!') print >>sys.stderr, ("Scan realizado com sucesso!\n")
def scan_recover(threadName): turn_led(ON) while True: while True: if (read_display(START_SCAN) == TRUE): break time.sleep(0.2) geniePi.genieWriteStr(2, 'Searching boards...') devices = bus.scan() for i in range(1,5): geniePi.genieWriteStr(i+2, str(devices[i-1])) geniePi.genieWriteStr(2, 'Found boards!') print >>sys.stderr, ("%s: Scan realizado com sucesso!\n") % threadName
def _update_string(self, address, text): # types: (int, string) -> None # Only update if the display is connected if not self._display_error: geniePi.genieWriteStr(address, text)