async def open_popup(self, scr): # wait for another popup to finish while self.background is not None: await asyncio.sleep_ms(10) self.background = self.scr self.scr = scr lv.scr_load(scr)
def show_recovery_phrase_warning(self): self.screen = lv.obj() self.recovery_phrase_header_label = lv.label(self.screen) self.recovery_phrase_header_label.set_text( "WRITE DOWN YOUR\nRECOVERY PHRASE!") self.recovery_phrase_header_label.align(self.screen, lv.ALIGN.CENTER, 0, -300) self.recovery_phrase_instruction_label = lv.label(self.screen) self.recovery_phrase_instruction_label.set_text( "If you lose your wallet,\nyou can recover it on any\n computer " "ONLY with BOTH:\n\n1)Your recovery phrase\n2)Your password") self.recovery_phrase_instruction_label.align(self.screen, lv.ALIGN.CENTER, 0, -85) self.show_recovery_phrase_button = lv.btn(self.screen) self.show_recovery_phrase_button.set_size(400, 100) self.show_recovery_phrase_button.align(self.screen, lv.ALIGN.CENTER, 0, 150) self.show_recovery_phrase_button.set_event_cb( self.handle_show_recovery_phrase_button) self.show_recovery_phrase_button_label = lv.label( self.show_recovery_phrase_button) self.show_recovery_phrase_button_label.set_text("Show recovery phrase") lv.scr_load(self.screen)
def m2(): print("This is callback for M2") scr = lv.obj() lv.scr_load(scr) #make container con = lv.cont(scr) con.set_auto_realign(True) con.set_layout(lv.LAYOUT.CENTER) con.align(scr, lv.ALIGN.CENTER, 0, 0) con.set_fit(lv.FIT.TIGHT) #make label in container label = lv.label(con) label.set_text(""" This is the second screen""") ta = lv.textarea(con) kb = lv.keyboard(con) #kb.set_style_local_radius(0,0,0) kb.set_textarea(ta) btn = lv.btn(con) label = lv.label(btn) label.set_text("Skip la") btn.set_event_cb(lambda obj, event: m4() if event == lv.EVENT.CLICKED else None)
def interface(): def event_handler(source, evt): if evt == lv.EVENT.VALUE_CHANGED: date = lv.calendar.get_pressed_date(source) if date: print("Clicked date: %02d.%02d.%02d" % (date.day, date.month, date.year)) # Create a screen and load it scr = lv.obj() lv.scr_load(scr) # create a calendar calendar = lv.calendar(lv.scr_act(), None) calendar.set_size(235, 235) calendar.align(None, lv.ALIGN.CENTER, 0, 0) calendar.set_event_cb(event_handler) # Make the date number smaller to be sure they fit into their area calendar.set_style_local_text_font(lv.calendar.PART.DATE, lv.STATE.DEFAULT, lv.theme_get_font_small()) today = lv.calendar_date_t() date = cetTime() today.year = date[0] today.month = date[1] today.day = date[2] calendar.set_today_date(today) calendar.set_showed_date(today) watch.tft.backlight_fade(100)
def show_phrase_length_selection(self): self.screen = lv.obj() self.recovery_phrase_length_screen_label = lv.label(self.screen) self.recovery_phrase_length_screen_label.set_text( "How many words are in\n your recovery phrase?") self.recovery_phrase_length_screen_label.align(self.screen, lv.ALIGN.CENTER, 0, -300) self.recovery_phrase_length_roller = lv.roller(self.screen) recovery_phrase_length_options_str = "\n".join( str(phrase_length) for phrase_length in self.RECOVERY_PHRASE_LENGTHS) self.recovery_phrase_length_roller.set_options( recovery_phrase_length_options_str, 0) self.recovery_phrase_length_roller.set_fix_width(True) self.recovery_phrase_length_roller.set_selected(2, 0) self.recovery_phrase_length_roller.set_size(200, 200) self.recovery_phrase_length_roller.align(self.screen, lv.ALIGN.CENTER, 0, -75) self.recovery_phrase_length_roller.set_visible_row_count(5) self.confirm_phrase_length_button = lv.btn(self.screen) self.confirm_phrase_length_button.set_size(125, 60) self.confirm_phrase_length_button.align(self.screen, lv.ALIGN.CENTER, 0, 100) self.confirm_phrase_length_button.set_event_cb( self.handle_confirm_phrase_length_button) self.confirm_phrase_length_button_label = lv.label( self.confirm_phrase_length_button) self.confirm_phrase_length_button_label.set_text("Ok") lv.scr_load(self.screen)
def __init__(self, profiles_obj, config_dict, pid_obj, sensor_obj): self.profiles = profiles_obj self.config = config_dict self.pid = pid_obj self.sensor = sensor_obj self.pid_params = self.config.get('pid') self.temp_offset = self.config.get('sensor_offset') self.alloy_list = self.profiles.get_profile_alloy_names() self.has_started = False self.main_scr = lv.obj() self.oven_title = self.oven_title_init() self.chart, self.chart_series = self.chart_init() self.profile_title_label, self.profile_title_cont, self.profile_title_text = self.profile_title_init( ) self.timer_label, self.timer_cont, self.timer_text = self.timer_init() self.profile_alloy_selector = self.profile_selector_init() self.start_btn, self.start_label = self.start_btn_init() self.stage_cont, self.stage_label = self.stage_init() self.settings_btn = self.settings_btn_init() self.temp_text = self.temp_init() self.led = self.led_init() self.line = None self.dashed_line = None self.point_count = None self.chart_point_list = None self.profile_detail_init() self.profile_alloy_selector.move_foreground() self.show_set_btn_hide_stage() self.reflow_process_start_cb = None self.reflow_process_stop_cb = None self.current_input_placeholder = 'Set Kp' lv.scr_load(self.main_scr)
def __init__(self, profiles_obj, config_dict): self.profiles = profiles_obj self.config = config_dict self.alloy_list = self.profiles.get_profile_alloy_names() self.has_started = False self.main_scr = lv.obj() self.oven_title = self.oven_title_init() self.chart, self.chart_series = self.chart_init() self.profile_title_label, self.profile_title_cont, self.profile_title_text = self.profile_title_init( ) self.timer_label, self.timer_cont, self.timer_text = self.timer_init() self.profile_alloy_selector = self.profile_selector_init() self.start_btn, self.start_label = self.start_btn_init() self.stage_cont, self.stage_label = self.stage_init() self.cali_btn = self.cali_btn_init() self.temp_text = self.temp_init() self.led = self.led_init() self.line = None self.dashed_line = None self.null_chart_point_list = None self.profile_detail_init() self.profile_alloy_selector.move_foreground() self.show_cali_btn_hide_stage() self.reflow_process_start_cb = None self.reflow_process_stop_cb = None lv.scr_load(self.main_scr)
def m1(): scr = lv.obj() lv.scr_load(scr) scr.set_style_local_bg_color(lv.obj.PART.MAIN, lv.STATE.DEFAULT, lv.color_hex(0xffffff)) decoder = lv.img.decoder_create() decoder.info_cb = get_png_info decoder.open_cb = open_png with open('bonsai-logo.png', 'rb') as f: png_data = f.read() global png_img_dsc png_img_dsc = lv.img_dsc_t({ 'data_size':len(png_data), 'data':png_data }) img1 = lv.img(scr) img1.set_src(png_img_dsc) img1.align(scr, lv.ALIGN.CENTER,0,0) img1.fade_in(2000,0) img1.set_drag(True) time.sleep(2) img1.fade_out(2000,0) time.sleep(2) m2()
def __init__(self): # init LVGL lv.init() # TFT and TS driver # POTENTIAL: move into LaserMcu self._tft = tftwing.TFTFeatherWing(tft_mhz=24) self._tft.init() # Register display buffer, driver and input device driver self._register_disp_drv() self._register_indev_drv() th = lv.theme_night_init(210, lv.font_roboto_16) lv.theme_set_current(th) blank_scr = lv.obj() lv.scr_load(blank_scr) # MCU Control self.mcu = laser_mcu.LaserMCU() # Laser Measuring Control self.laser = laser_ctrl.LaserCtrl() self.laser.off() # Load Time # TODO: also move into LaserMcu try: self.mcu.set_time_ntp() except OSError as err: print("OSError: {0}".format(err)) self.mcu.load_time() self.mcu.set_creation_time() # Create screen self._load_screen() # Register Tasks self._register_tasks() # Create lock for panel wait process self._lock = _thread.allocate_lock() return
def btn_event(task, params): if params == 'cancel': lv.scr_load(scr) elif params['param'] == 'save' and params['flag'] == 'edit': print(params) temp_trigger_item['name'] = params['name'] temp_trigger_item['hb'] = params['hb'] temp_trigger_item['mb'] = params['mb'] temp_trigger_item['sb'] = params['sb'] temp_trigger_item['dur'] = params['dur'] temp_trigger_item['pin'] = params['pin'] temp_trigger_item['timerno'] = params['timerno'] temp_trigger_item['cardnum'] = params['cardnum'] temp_trigger_item['daysoweek'] = params['daysoweek'] temp_trigger_item['sec_start'] = params['sec_start'] print('Triger Edit : Settings saved') lv.scr_load(scr) elif params['param'] == 'save' and params['flag'] == 'new': del params['param'] del params['flag'] trigger.append(params) gui_main() print('new key added : {}'.format(params))
async def load_screen(self, scr): while self.background is not None: await asyncio.sleep_ms(10) old_scr = lv.scr_act() lv.scr_load(scr) self.scr = scr old_scr.del_async()
def close(self): # activate old screen lv.scr_load(self.old_screen) if self.close_callback is not None: self.close_callback() popups.remove(self) # delete this screen self.del_async()
def __init__(self, screen): # initialize esp32 self.init_gui_esp32() # Create the main screen and load it. self.screen_main = screen() lv.scr_load(self.screen_main)
def show_rejected_tx(self, message): self.screen = lv.obj() self.rejected_tx_label = lv.label( self.screen) self.rejected_tx_label.set_text(message) self.rejected_tx_label.align( self.screen, lv.ALIGN.CENTER, 0, -200) lv.scr_load(self.screen)
def show_password_input(self): self.screen = lv.obj() self.wallet_paddword_screen_label = lv.label(self.screen) self.wallet_paddword_screen_label.set_text( " Enter your recovery\nphrase password (if any)") self.wallet_paddword_screen_label.align(self.screen, lv.ALIGN.CENTER, 0, -350) self.password_input = lv.ta(self.screen) self.password_input.set_one_line(True) self.password_input.set_text("") self.password_input.align(self.screen, lv.ALIGN.CENTER, 0, -275) self.password_back_button = lv.btn(self.screen) self.password_back_button.set_size(125, 60) self.password_back_button_label = lv.label(self.password_back_button) self.password_back_button_label.set_text("Back") self.password_back_button.align(self.screen, lv.ALIGN.CENTER, -100, -150) self.password_back_button.set_event_cb( self.handle_password_back_button) self.password_finish_button = lv.btn(self.screen) self.password_finish_button.set_size(150, 60) self.password_finish_button_label = lv.label( self.password_finish_button) self.password_finish_button_label.set_text("Finish") self.password_finish_button.align(self.screen, lv.ALIGN.CENTER, 100, -150) self.password_finish_button.set_event_cb( self.handle_password_finish_button) self.toggle_keyboard_button = lv.btn(self.screen) self.toggle_keyboard_button.set_size(230, 100) self.toggle_keyboard_button_label = lv.label( self.toggle_keyboard_button) self.toggle_keyboard_button_label.set_text( self.UPPER_CASE_KEYBOARD_SYMBOL) self.toggle_keyboard_button.align(self.screen, lv.ALIGN.CENTER, -118, 50) self.toggle_keyboard_button.set_event_cb( self.handle_toggle_password_keyboard_button) self.backspace_button = lv.btn(self.screen) self.backspace_button.set_size(230, 100) self.backspace_button_label = lv.label(self.backspace_button) self.backspace_button_label.set_text("Bksp") self.backspace_button.align(self.screen, lv.ALIGN.CENTER, 118, 50) self.backspace_button.set_event_cb( self.handle_password_backspace_button) self.keyboard = lv.kb(self.screen) self.keyboard.set_height(300) self.keyboard.align(self.screen, lv.ALIGN.IN_BOTTOM_MID, 0, 0) self.keyboard.set_map(self.PASSWORD_KEYBOARD_MAP_LOWER_CASE) self.keyboard.set_ta(self.password_input) lv.scr_load(self.screen)
def init(blocking=True): display.init(not blocking) # Initialize the styles init_styles() scr = lv.obj() lv.scr_load(scr) update()
def _load_screen(self): # Create screen obj self.scr = lv.obj() # Add header and body self.hdr = GuiHeader(self.scr, 0, 0, self.mcu.get_creation_time_str()) self.body = GuiLaserMain(self.scr, 0, self.hdr.get_height(), self) # Load screen lv.scr_load(self.scr) return
def show_recovery_succeeded(self): self.screen = lv.obj() self.recovery_succeeded_label = lv.label(self.screen) self.recovery_succeeded_label.set_text( "Wallet successfully\n recovered") self.recovery_succeeded_label.align(self.screen, lv.ALIGN.CENTER, 0, -200) lv.scr_load(self.screen)
def show_set_password(self): self.screen = lv.obj() self.create_password_screen_label = lv.label(self.screen) self.create_password_screen_label.set_text("Set a password (optional)") self.create_password_screen_label.align(self.screen, lv.ALIGN.CENTER, 0, -360) self.password_input = lv.ta(self.screen) self.password_input.set_one_line(True) self.password_input.set_text("") self.password_input.align(self.screen, lv.ALIGN.CENTER, 0, -285) self.submit_password_button = lv.btn(self.screen) self.submit_password_button.set_size(125, 60) self.submit_password_button.align(self.screen, lv.ALIGN.CENTER, 0, -220) self.submit_password_button.set_event_cb( self.handle_submit_password_button) self.submit_password_button_label = lv.label( self.submit_password_button) self.submit_password_button_label.set_text("Set") self.password_tips_label = lv.label(self.screen) self.password_tips_label.set_text( "-Avoid common passwords\n" "-Use at least 11 characters\n" "-Use letters, numbers and\nspecial characters") self.password_tips_label.align(self.screen, lv.ALIGN.CENTER, 0, -90) self.toggle_keyboard_button = lv.btn(self.screen) self.toggle_keyboard_button.set_size(230, 100) self.toggle_keyboard_button_label = lv.label( self.toggle_keyboard_button) self.toggle_keyboard_button_label.set_text( self.UPPER_CASE_KEYBOARD_SYMBOL) self.toggle_keyboard_button.align(self.screen, lv.ALIGN.CENTER, -118, 50) self.toggle_keyboard_button.set_event_cb( self.handle_toggle_password_keyboard_button) self.backspace_button = lv.btn(self.screen) self.backspace_button.set_size(230, 100) self.backspace_button_label = lv.label(self.backspace_button) self.backspace_button_label.set_text("Bksp") self.backspace_button.align(self.screen, lv.ALIGN.CENTER, 118, 50) self.backspace_button.set_event_cb( self.handle_password_backspace_button) self.keyboard = lv.kb(self.screen) self.keyboard.set_height(300) self.keyboard.align(self.screen, lv.ALIGN.IN_BOTTOM_MID, 0, 0) self.keyboard.set_map(self.PASSWORD_KEYBOARD_MAP_LOWER_CASE) self.keyboard.set_ta(self.password_input) lv.scr_load(self.screen)
def start(self): lv.scr_load(self.temp_cali_scr) self._update_text("Calibration will start in 5sec...\n\n") utime.sleep(5) self._update_text("Starting...\n") self._update_text("Calibrating oven temperature to " + str(self.check_temp) + ' C`... \n') self.oven.on() self.tim.deinit() self.start_time = utime.time() self.tim.init(period=1000, mode=machine.Timer.PERIODIC, callback=lambda t: self._heating_cb_handler())
def interface(): def update_task(task): set_usb_voltage(power.getVbusVoltage()) set_usb_pwr(power.getVbusCurrent()) if power.isBatteryConnect(): set_batt_voltage(power.getBattVoltage()) if power.isChargeing(): set_batt_pwr("Charging", power.getBattChargeCurrent()) batt_percent.set_hidden(True) else: set_batt_pwr("Discharging", power.getBattDischargeCurrent()) set_batt_per(power.getBattPercentage()) batt_percent.set_hidden(False) def event_cb(obj, event): if event == lv.EVENT.VALUE_CHANGED: tft.set_backlight_level(obj.get_value()) def set_usb_pwr(pwr): usb_pwr.set_text("USB current: {} mA".format(pwr)) def set_usb_voltage(volts): usb_voltage.set_text("USB voltage: {} mV".format(volts)) def set_batt_voltage(volts): batt_voltage.set_text("Battery voltage: {} mV".format(volts)) def set_batt_pwr(mode, pwr): batt_pwr.set_text("{} battery \ncurrent: {} mA".format(mode, pwr)) def set_batt_per(per): batt_percent.set_text("Battery percent: {}%".format(per)) scr = lv.obj() tabview = lv.tabview(scr) vbus_tab = tabview.add_tab("USB") usb_voltage = lv.label(vbus_tab) usb_pwr = lv.label(vbus_tab) usb_pwr.set_y(usb_voltage.get_y() + 20) la = lv.switch(vbus_tab) batt_tab = tabview.add_tab("Battery") batt_voltage = lv.label(batt_tab) batt_pwr = lv.label(batt_tab) batt_pwr.set_y(batt_voltage.get_y() + 20) batt_percent = lv.label(batt_tab) batt_percent.set_y(batt_pwr.get_y() + 40) brightness_slider = lv.slider(batt_tab) brightness_slider.align(None, lv.ALIGN.IN_BOTTOM_MID, 0, 0) brightness_slider.set_range(0, 100) brightness_slider.set_value(100, 1) brightness_slider.set_event_cb(event_cb) update_task(None) lv.scr_load(scr) watch.tft.backlight_fade(100) lv.task_create(update_task, 1000, 5, None)
def __init__(self): scr = lv.obj() # Create style for the Arcs - Hour styleHour = lv.style_t() lv.style_copy(styleHour, lv.style_plain) styleHour.line.color = lv.color_make(119,158,203) # Arc color styleHour.line.width = 8 # Arc width # Create an Arc - Hour arcHour = lv.arc(scr) arcHour.set_style(lv.arc.STYLE.MAIN, styleHour) # Use the new style arcHour.set_angles(45, 0) arcHour.set_size(300, 300) arcHour.align(None, lv.ALIGN.CENTER, 0, 0) # Create style for the Arcs - Minute styleMin = lv.style_t() lv.style_copy(styleMin, lv.style_plain) styleMin.line.color = lv.color_make(124,252,0) # Arc color styleMin.line.width = 8 # Arc width # Create an Arc - Minute arcMin = lv.arc(scr) arcMin.set_style(lv.arc.STYLE.MAIN, styleMin) # Use the new style arcMin.set_angles(45, 0) arcMin.set_size(380, 380) arcMin.align(None, lv.ALIGN.CENTER, 0, 0) # Create style for the Arcs - Second styleSecond = lv.style_t() lv.style_copy(styleSecond, lv.style_plain) styleSecond.line.color = lv.color_make(250,128,114) # Arc color styleSecond.line.width = 8 # Arc width # Create an Arc - Minute arcSecond = lv.arc(scr) arcSecond.set_style(lv.arc.STYLE.MAIN, styleSecond) # Use the new style arcSecond.set_angles(45, 0) arcSecond.set_size(220, 220) arcSecond.align(None, lv.ALIGN.CENTER, 0, 0) def event_handler(obj, event): lv.obj_del(scr) from secondScreen import secondScreen btn1 = lv.btn(scr) btn1.set_event_cb(event_handler) btn1.align(None, lv.ALIGN.CENTER, 0, 0) label = lv.label(btn1) label.set_text("Button") lv.scr_load(scr)
async def show_environmental_screen(self): # # Environmental screen using a table # # # lv.table.STYLE.CELL1 = normal cell # lv.table.STYLE.CELL2 = header cell # lv.table.STYLE.CELL3 = ? # lv.table.STYLE.CELL4 = ? environmental_screen = lv.obj() # set background color, with no gradient screenstyle = lv.style_t(lv.style_plain) #screenstyle.body.main_color = lv.color_make(0xFF, 0xA5, 0x00) # 0xFF, 0x00, 0x00 Red # 0xC0, 0xC0, 0xC0 Silver # 0xFF, 0xA5, 0x00 Orange #screenstyle.body.grad_color = lv.color_make(0xFF, 0xA5, 0x00) #screenstyle.body.border.color = lv.color_hex(0xe32a19) #screenstyle.body.border.width = 5 environmental_screen.set_style(screenstyle) tablestyle = lv.style_t(lv.style_plain) tablestyle.body.border.width = 0 tablestyle.body.opa = 0 cellstyle = lv.style_t(lv.style_plain) cellstyle.text.color = lv.color_hex(0xa028d4) cellstyle.text.font = lv.font_roboto_28 cellstyle.body.padding.top = 1 cellstyle.body.padding.bottom = 1 cellstyle.body.border.width = 0 cellstyle.body.opa = 0 mtable = lv.table(environmental_screen) mtable.set_row_cnt(2) mtable.set_col_cnt(3) mtable.set_col_width(0, 130) mtable.set_col_width(1, 90) mtable.set_col_width(2, 90) mtable.set_style(lv.table.STYLE.BG, tablestyle) mtable.set_style(lv.table.STYLE.CELL1, cellstyle) mtable.set_cell_value(0,0, "Temp") mtable.set_cell_value(1,0, "Humidity") mtable.set_cell_value(0,1, '{:.1f}'.format(repo.get('tdegc').current)) mtable.set_cell_value(1,1, '{:.1f}'.format(repo.get('rh').current)) mtable.set_cell_value(0,2, "degC") mtable.set_cell_value(1,2, "%") lv.scr_load(environmental_screen) self.backlight_ctrl.value(1)
async def show_voltage_monitor_screen(self): # # Measurement screen using a table # # # lv.table.STYLE.CELL1 = normal cell # lv.table.STYLE.CELL2 = header cell # lv.table.STYLE.CELL3 = ? # lv.table.STYLE.CELL4 = ? voltage_screen = lv.obj() # set background color, with no gradient screenstyle = lv.style_t(lv.style_plain) #screenstyle.body.main_color = lv.color_make(0xFF, 0xA5, 0x00) # 0xFF, 0x00, 0x00 Red # 0xC0, 0xC0, 0xC0 Silver # 0xFF, 0xA5, 0x00 Orange #screenstyle.body.grad_color = lv.color_make(0xFF, 0xA5, 0x00) #screenstyle.body.border.color = lv.color_hex(0xe32a19) #screenstyle.body.border.width = 5 voltage_screen.set_style(screenstyle) tablestyle = lv.style_t(lv.style_plain) tablestyle.body.border.width = 0 tablestyle.body.opa = 0 cellstyle = lv.style_t(lv.style_plain) cellstyle.text.color = lv.color_hex(0xa028d4) cellstyle.text.font = lv.font_roboto_28 cellstyle.body.padding.top = 1 cellstyle.body.padding.bottom = 1 cellstyle.body.border.width = 0 cellstyle.body.opa = 0 mtable = lv.table(voltage_screen) mtable.set_row_cnt(2) mtable.set_col_cnt(3) mtable.set_col_width(0, 110) mtable.set_col_width(1, 100) mtable.set_col_width(2, 100) mtable.set_style(lv.table.STYLE.BG, tablestyle) mtable.set_style(lv.table.STYLE.CELL1, cellstyle) mtable.set_cell_value(0,0, "Vbat") mtable.set_cell_value(1,0, "Vusb") mtable.set_cell_value(0,2, "V") mtable.set_cell_value(1,2, "V") mtable.set_cell_value(0,1, '{:.2f}'.format(repo.get('vbat').current)) mtable.set_cell_value(1,1, '{:.2f}'.format(repo.get('vusb').current)) lv.scr_load(voltage_screen) self.backlight_ctrl.value(1)
def show_phrase_input(self): self.phrase_input_length = 0 self.screen = lv.obj() self.recovery_phrase_length_screen_label = lv.label(self.screen) self.recovery_phrase_length_screen_label.set_text( "Recovery phrase word {page_number}/{recovery_phrase_target_length}" .format(page_number=len(self.recovery_phrase) + 1, recovery_phrase_target_length=self. recovery_phrase_target_length)) self.recovery_phrase_length_screen_label.align(self.screen, lv.ALIGN.CENTER, 0, -350) self.recovery_phrase_input = lv.ta(self.screen) self.recovery_phrase_input.set_one_line(True) self.recovery_phrase_input.set_text("") self.recovery_phrase_input.set_max_length(16) self.recovery_phrase_input.align(self.screen, lv.ALIGN.CENTER, 0, -275) self.recovery_phrase_input.set_event_cb( self.handle_recovery_phrase_input_change) # need to keep track of this for the autocomplete self.autocompleted = False self.phrase_input_length = 0 self.prev_recovery_phrase_word_button = lv.btn(self.screen) self.prev_recovery_phrase_word_button.set_size(125, 60) self.prev_recovery_phrase_word_button_label = lv.label( self.prev_recovery_phrase_word_button) self.prev_recovery_phrase_word_button_label.set_text("Back") self.prev_recovery_phrase_word_button.align(self.screen, lv.ALIGN.CENTER, -100, -150) self.prev_recovery_phrase_word_button.set_event_cb( self.handle_previous_recovery_phrase_word_button) self.next_recovery_phrase_word_button = lv.btn(self.screen) self.next_recovery_phrase_word_button.set_size(125, 60) self.next_recovery_phrase_word_button_label = lv.label( self.next_recovery_phrase_word_button) self.next_recovery_phrase_word_button_label.set_text("Next") self.next_recovery_phrase_word_button.align(self.screen, lv.ALIGN.CENTER, 100, -150) self.next_recovery_phrase_word_button.set_state(BUTTON_DISABLED_STATE) self.next_recovery_phrase_word_button.set_event_cb( self.handle_next_recovery_phrase_word_button) self.keyboard = lv.kb(self.screen) self.keyboard.set_map(self.RECOVERY_PHRASE_KEYBOARD_MAP) self.keyboard.set_ta(self.recovery_phrase_input) lv.scr_load(self.screen)
def show_recovery_phrase(self): self.screen = lv.obj() self.recovery_phrase_header_label = lv.label(self.screen) recovery_phrase_word_index = self.recovery_phrase_page_number - 1 recovery_phrase_header_label_text = "Recovery phrase " \ "{page_number}/{total_pages}:".format( page_number=self.recovery_phrase_page_number, total_pages=len(self.recovery_phrase) ) self.recovery_phrase_header_label.set_text( recovery_phrase_header_label_text) self.recovery_phrase_header_label.align(self.screen, lv.ALIGN.CENTER, 0, -300) self.recovery_phrase_word_label = lv.label(self.screen) self.recovery_phrase_word_label.set_text( self.recovery_phrase[recovery_phrase_word_index]) self.recovery_phrase_word_label.align(self.screen, lv.ALIGN.CENTER, 0, -150) if self.recovery_phrase_page_number != 1: self.prev_recovery_phrase_word_button = lv.btn(self.screen) self.prev_recovery_phrase_word_button.set_size(125, 60) self.prev_recovery_phrase_word_button_label = lv.label( self.prev_recovery_phrase_word_button) self.prev_recovery_phrase_word_button_label.set_text("Back") self.prev_recovery_phrase_word_button.align( self.screen, lv.ALIGN.CENTER, -100, 0) self.prev_recovery_phrase_word_button.set_event_cb( self.handle_previous_recovery_phrase_word_button) if self.recovery_phrase_page_number != len(self.recovery_phrase): self.next_recovery_phrase_word_button = lv.btn(self.screen) self.next_recovery_phrase_word_button.set_size(125, 60) self.next_recovery_phrase_word_button_label = lv.label( self.next_recovery_phrase_word_button) self.next_recovery_phrase_word_button_label.set_text("Next") self.next_recovery_phrase_word_button.align( self.screen, lv.ALIGN.CENTER, 100, 0) self.next_recovery_phrase_word_button.set_event_cb( self.handle_next_recovery_phrase_word_button) else: self.finish_recovery_phrase_button = lv.btn(self.screen) self.finish_recovery_phrase_button.set_size(150, 60) self.finish_recovery_phrase_button.align(self.screen, lv.ALIGN.CENTER, 100, 0) self.finish_recovery_phrase_button_label = lv.label( self.finish_recovery_phrase_button) self.finish_recovery_phrase_button_label.set_text("Finish") self.finish_recovery_phrase_button.set_event_cb( self.handle_finish_recovery_phrase_button) lv.scr_load(self.screen)
def interface(): print("starting interface.") scr = lv.obj() print("created screen") tileview = lv.tileview(scr) tileview.set_valid_positions(pages, len(pages)) print("created tileview") clock_screen = clock.init(tileview) tileview.add_element(clock_screen) lv.scr_load(scr) print("started interface.")
def __init__(self, close_callback=None): super().__init__() self.old_screen = lv.scr_act() self.close_callback = close_callback # add back button self.close_button = add_button(scr=self, callback=on_release(self.close)) self.close_label = lv.label(self.close_button) self.close_label.set_text("OK") #lv.SYMBOL.LEFT+" Back") # activate the screen lv.scr_load(self) popups.append(self)
def init_gui(self): import lvgl as lv import lvgl_helper as lv_h import lcd import time from machine import I2C config_touchscreen_support = True board_m1n = False i2c = I2C(I2C.I2C0, freq=400000, scl=30, sda=31) if not board_m1n: lcd.init() else: lcd.init(type=2, freq=20000000) if config_touchscreen_support: import touchscreen as ts ts.init(i2c) lv.init() disp_buf1 = lv.disp_buf_t() buf1_1 = bytearray(320 * 10) lv.disp_buf_init(disp_buf1, buf1_1, None, len(buf1_1) // 4) disp_drv = lv.disp_drv_t() lv.disp_drv_init(disp_drv) disp_drv.buffer = disp_buf1 disp_drv.flush_cb = lv_h.flush if board_m1n: disp_drv.hor_res = 240 disp_drv.ver_res = 240 else: disp_drv.hor_res = 320 disp_drv.ver_res = 240 lv.disp_drv_register(disp_drv) if config_touchscreen_support: indev_drv = lv.indev_drv_t() lv.indev_drv_init(indev_drv) indev_drv.type = lv.INDEV_TYPE.POINTER indev_drv.read_cb = lv_h.read lv.indev_drv_register(indev_drv) # lv.log_register_print_cb(lv_h.log) lv.log_register_print_cb(lambda level, path, line, msg: print( '%s(%d): %s' % (path, line, msg))) # Create the main screen and load it. self.screen_main = Screen_Main(self) lv.scr_load(self.screen_main)
def __init__(self): super().__init__() # first we save the active screen self.old_screen = lv.scr_act() # add back button btn = lv.btn(self) lbl = lv.label(btn) lbl.set_text(lv.SYMBOL.LEFT + " Back") btn.set_width(380) btn.align(self, lv.ALIGN.IN_BOTTOM_MID, 0, -30) btn.set_event_cb(on_release(self.close)) self.back_btn = btn # activate the screen lv.scr_load(self)