class TKOS: """The base class of the operating system.""" display_width = 480 display_height = 320 def __init__(self): """Initialize an instance of the OS.""" print('Initializing tkos...') self.tft = None self.gui = None self.encoder = None def start(self): """Start this instance of the OS.""" print('Welcome to tkos') self.init_display() self.init_gui(self.tft) self.init_encoder() def init_display(self): """Initialize the display driver.""" print('Initializing TFT...') self.tft = TFT() self.tft.init(self.tft.ILI9488, mosi=13, miso=35, clk=14, cs=15, dc=2, speed=40000000, width=self.display_width, height=self.display_height, rst_pin=4, backl_pin=27, backl_on=1, rot=self.tft.LANDSCAPE_FLIP, bgr=True, splash=False) def init_encoder(self): """Initialize the encoder driver.""" self.encoder = RotaryIRQ(25, 26, range_mode=drivers.Rotary.RANGE_UNBOUNDED) def init_gui(self, tft: TFT): """Initializes the user interface on the specified display. Args: tft (TFT): The display. """ self.gui = UI(tft)
def init_display(self): """Initialize the display driver.""" print('Initializing TFT...') self.tft = TFT() self.tft.init(self.tft.ILI9488, mosi=13, miso=35, clk=14, cs=15, dc=2, speed=40000000, width=self.display_width, height=self.display_height, rst_pin=4, backl_pin=27, backl_on=1, rot=self.tft.LANDSCAPE_FLIP, bgr=True, splash=False)
def _init_display(): # Initialize the display # https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/display # https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/issues/310 tft = TFT() tft.init(tft.ST7789, rst_pin=23, backl_pin=4, miso=0, mosi=19, clk=18, cs=5, dc=16, width=235, height=340, backl_on=1) # Invert colors tft.tft_writecmd(0x21) # Set orientation (optional) tft.orient(tft.LANDSCAPE) return tft
a.enablePower(AXP202_LDO3) a.setLDO3Voltage(3000) pmu_pin = Pin(PMU_PIN_IRQ, Pin.IN, trigger=Pin.IRQ_FALLING, handler=power_button_handler) #user_button = Pin( # BUTTON_PIN, Pin.IN, trigger=Pin.IRQ_FALLING, handler=user_button_handler #) a.enableADC(AXP202_ADC1, AXP202_BATT_VOL_ADC1) a.enableIRQ(AXP202_PEK_SHORTPRESS_IRQ) if TFT_present: pwm = PWM(TFT_PIN_BL, freq=12000, duty=0) tft = TFT() tft.init(tft.ST7789, miso=TFT_PIN_MISO, mosi=TFT_PIN_MOSI, clk=TFT_PIN_CLK, cs=TFT_PIN_SS, dc=TFT_PIN_DC, rot=tft.PORTRAIT_FLIP, color_bits=tft.COLOR_BITS16, splash=False, height=240) tft.tft_writecmd(ST7789_INVON) tft.clear(tft.NAVY)
import machine, time, utime import network from display import TFT from ui.interface import UI tft = TFT() tft.init(tft.ILI9341, width=320, height=320, miso=19, mosi=23, clk=18, cs=14, dc=27, bgr=True, backl_pin=32, rst_pin=33, backl_on=1, spihost=tft.VSPI, invrot=2) tft.orient(2) def init(): tft.font(tft.FONT_Default) fw,fh = tft.fontSize() tft.clear() tft.text(0,0*fh, "connecting...") station = network.WLAN(network.STA_IF) station.active(True) station.connect("box", "pass") time.sleep(2) if station.isconnected(): tft.text(0, 1*fh, "connected:") tft.text(0, 2*fh, station.ifconfig()[0]) rtc = machine.RTC() rtc.ntp_sync(server="hr.pool.ntp.org") tmo = 100 while not rtc.synced(): utime.sleep_ms(100) tmo -= 1 if tmo == 0: break
# test modules with classess from display import TFT screen = TFT.init() # fixme: autocomplete; init() of class should have return type of class screen