def _on_btnOk(self): buttonA.wasPressed(None) buttonB.wasPressed(None) buttonC.wasPressed(None) self._editingActive = False self.printToLcd() self._screen.editingDone(self)
def startEditing(self, screen): self._editingActive = True self._screen = screen self.printToLcd() buttonA.wasPressed(self._on_btnOk) buttonB.wasPressed(self._on_btnUp) buttonC.wasPressed(self._on_btnDown)
def _showOptions(self): buttonA.wasPressed(self._menu.show) lcd.image(50, 205, 'imgs/menu.bmp') buttonB.wasPressed(kippenstal.doorOpener.toggle) lcd.image(145, 205, 'imgs/door.bmp') buttonC.wasPressed(kippenstal.light.toggle) lcd.image(243, 205, 'imgs/lightbulb-outline.bmp')
def refresh(self, newSelections): buttonA.wasPressed(self.pressUp) buttonB.wasPressed(self.pressDown) buttonC.wasPressed(self.fileSelected) self.selections = newSelections self.index = 0 self.__drawBackground() if len(self.selections) > self.MIOP: self.__drawNaviBar(1) self.__guiUpdate()
def __init__(self, selections): self.selections = selections self.index = 0 # Initial choice self.MIOP = const(11) # Max Index in One Page self.currentPage = 1 self.upleft = (0, 24) self.downright = (320, 204) buttonA.wasPressed(self.pressUp) buttonB.wasPressed(self.pressDown) buttonC.wasPressed(self.fileSelected)
def show(self): super().show() buttonA.wasPressed(self._on_btnOk) buttonB.wasPressed(self._on_btnUp) buttonC.wasPressed(self._on_btnDown) self.resetScreen() self.printHeader() self.cursor = lcd.getCursor() if self.cursor[1] != 85: self.cursor = (self.cursor[0], self.cursor[1] + 15) self.printMenu()
def fileSelected(self): if '.' in self.selections[self.index]: global FLAG_FOREGROUND FLAG_FOREGROUND = False buttonA.wasPressed(eventCls) buttonB.wasPressed(eventCls) buttonC.wasPressed(eventCls) if self.__ext(self.selections[self.index], ['py']): self.app_pyLauncher(self.selections[self.index]) elif self.__ext(self.selections[self.index], ['csv', 'json', 'txt']): self.app_txtReader(self.selections[self.index]) self.ui_refresh() else: try: uos.chdir(self.selections[self.index]) self.root_current = uos.getcwd() self.refresh(self.__path2fileList(uos.getcwd())) print('Enter folder: %s' % self.root_current) except: print('*** Unknown file type ***') pass
def main(): thread.allowsuspend(True) gc_count = 0 if datebase is None: pass else: ssid_text.update(datebase['wifi']['ssid']) pwd_text.update(datebase['wifi']['pwd']) del_name_list.updatelistdate(namelist) while True: if buttonA.wasPressed(callback=None): window.event(1) elif buttonB.wasPressed(callback=None): window.event(2) elif buttonC.wasPressed(callback=None): window.event(3) #temp = keyboard.read() #if temp != b'\x00': #window.event(temp) #print(temp) ntf = thread.getnotification() if ntf: if ntf == 1001: # 获取数据 # print(internet_date) display() gc_count += 1 # gc.collect() # 将debug_date 数据显示到debug窗口 if len(debug_date) > 0: de(debug_date[0]) del debug_date[0] gc_count += 1 if gc_count > 20: gc.collect() gc_count = 0
def _sleep(self): self._isSleeping = True lcd.backlight(0) buttonA.wasPressed(self._wake) buttonB.wasPressed(self._wake) buttonC.wasPressed(self._wake)
def hide(self): super().hide() buttonA.wasPressed(None) buttonB.wasPressed(None) buttonC.wasPressed(None)
lcd.print(d, lcd.CENTER, 50) lcd.print(t, lcd.CENTER, 130) time.sleep(0.02) if buttonA.isPressed(): break if buttonС.isPressed(): break def but_a(): lcd.clear(lcd.GREEN) lcd.setCursor(100, 100) lcd.setColor(lcd.BLACK, lcd.GREEN) lcd.print('Hello') def but_b(): lcd.clear(lcd.ORANGE) lcd.setCursor(100, 100) lcd.setColor(lcd.BLACK, lcd.ORANGE) lcd.print('World') return () lcd.font(lcd.FONT_Comic) but_a() buttonA.wasPressed(but_a) buttonB.wasPressed(clock) buttonC.wasPressed(but_b) #buttonA.releasedFor(1.2, may_meny_A)
imageList = [ "/sd/image1.jpg", "/sd/image2.jpg", "/sd/image3.jpg", "/sd/image4.jpg" ] position = 0 uos.mountsd() lcd.clear() lcd.image(0, 0, file=imageList[0], scale=0, type=lcd.JPG) while True: if buttonA.wasPressed(): position = position + 1 lcd.clear() lcd.image(0, 0, file=imageList[position % len(imageList)], scale=0, type=lcd.JPG) if buttonC.wasPressed(): position = position - 1 lcd.clear() lcd.image(0, 0, file=imageList[position % len(imageList)], scale=0, type=lcd.JPG) utime.sleep(0.1)
def _on_btnOk(self): buttonA.wasPressed(None) buttonB.wasPressed(None) buttonC.wasPressed(None) self._menuItems[self.value - 1][1]()