def lcd_print(self, end_event, event_to): # Not triggered on event timeout while (not event_to.isSet()) and (not end_event.isSet()): event_is_set = event_to.wait(0.2) if end_event.isSet(): break if event_is_set: self.display_single(cpf.msg_form(self.status)) event_to.clear()
def on_release(self, key): if key == keyboard.Key.esc: self.status = cpf.msg_form("<Esc>", "No keyboard") self.event_print.set() return False if key == keyboard.Key.end: self.end() return False if key == keyboard.Key.tab: self.event_print.set()
def lcd_printout_timeout(lcd,msg_list,event,timeout_sec): # Triggered on event timeout cntr=0 while not event.isSet(): cntr+=cntr #print(cntr) #=0 => e.wait works event_is_set = event.wait(timeout_sec) if event_is_set: lcd_printout(lcd,msg_list,1.5) event.clear() # clear isSet flag in event else: lcd_msg(lcd,cpf.msg_form(cpi.lcd_timestamp()[0:2]))
def display_multi(self, list_msg, delay): """Prints a list of text messages to terminal and LCD. LCD is first cleared. Args: list_msg (string list): a list of text messages formatted by printout_format.py into 2 rows of 16 chars delay (int): thread sleep """ self.LCD.clear() time.sleep(0.1) for msg in list_msg: self.display_single(cpf.msg_form(msg)) time.sleep(delay)
def lcd_print_timeout(self, end_event, event, timeout_sec=[1, 12]): # Triggered on event timeout >> periodic cntr = 0 while (not event.isSet()) and (not end_event.isSet()): cntr += cntr # print(cntr) #=0 => e.wait works event_is_set = event.wait(timeout_sec[0]) if end_event.isSet(): break if event_is_set: # infos[0] self.display_multi_info(0, 1.5) event.clear() # clear isSet flag in event else: # not set >> perform periodic updates # timestamps self.display_single(cpf.msg_form(self.tt.timestamps()[0:2])) # periodic remainder if self.tt.timedeltas(timeout_sec[1])[2]: # infos[1] <controls> self.display_multi_info(1, 2)
def lcd_msg_list(lcd_columns=16, lcd_rows=2): msg_list = [ cpf.lcd_ribbon(lcd_columns, lcd_rows), cpf.msg_form(plt_id.system, plt_id.node, "OS {}"), cpf.msg_form(plt_id.release, plt_id.machine, "rel {}", "chip {}"), cpf.msg_form(get_ip(), "", "{} IP", "{} ID"), cpf.msg_form(get_wlan(), "", "CFreq {} GHz", "WLAN Channel {}"), cpf.msg_form( "CPU {} %".format(psutil.cpu_percent()), "CPU {} {}C".format( psutil.sensors_temperatures()['cpu_thermal'][0].current, degree)), cpf.msg_form(psutil.virtual_memory().percent, psutil.swap_memory().percent, "Virt MEM {} %", "Swap MEM {} %"), cpf.lcd_ribbon(lcd_columns, lcd_rows) ] msg_idle = [cpf.lcd_info()] return msg_list, msg_idle