From d741d14cbfb46e08c6ed9defd9ceb611156c895d Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Fri, 18 Apr 2025 22:34:12 +0200 Subject: [PATCH] Simplify --- appstore.mpy | 65 +++++----------------------------------------------- 1 file changed, 6 insertions(+), 59 deletions(-) diff --git a/appstore.mpy b/appstore.mpy index 2aa13eb4..36e3cd3c 100644 --- a/appstore.mpy +++ b/appstore.mpy @@ -1,4 +1,3 @@ - import lvgl as lv import time from machine import Pin, SPI @@ -10,9 +9,6 @@ import machine import task_handler # NOQA import cst816s # NOQA import i2c # NOQA - - - import network import urequests @@ -56,7 +52,6 @@ lv.init() # Display configuration TFT_HOR_RES = 320 TFT_VER_RES = 240 -DRAW_BUF_SIZE = TFT_HOR_RES * TFT_VER_RES // 10 # Pin configuration LCD_SCLK = 39 @@ -65,6 +60,9 @@ LCD_MISO = 40 LCD_DC = 42 LCD_CS = 45 LCD_BL = 1 +TP_SDA = 48 +TP_SCL = 47 + spi_bus = machine.SPI.Bus( host=2, @@ -95,63 +93,15 @@ display.set_power(True) display.init() display.set_backlight(100) -#define TP_SDA 48 -#define TP_SCL 47 i2c_bus = i2c.I2C.Bus(host=0, scl=47, sda=48, freq=100000, use_locks=False) touch_dev = i2c.I2C.Device(bus=i2c_bus, dev_id=0x15, reg_bits=8) indev = cst816s.CST816S(touch_dev) -#touch_dev = machine.SPI.Device(spi_bus=spi_bus,freq=40000000,cs=-1) - - th = task_handler.TaskHandler() -scrn = lv.screen_active() -scrn.set_style_bg_color(lv.color_hex(0x000000), 0) - - -label = lv.label(scrn) -label.set_text('HELLO WORLD!') -label.align(lv.ALIGN.CENTER, 0, -50) - -label = lv.label(scrn) -label.set_text('HELLO WORLD again!') -label.align(lv.ALIGN.CENTER, 0, -100) - scr = lv.screen_active() - -# Label 1: Red -label1 = lv.label(scr) -label1.set_text("Red Text") -label1.set_style_text_color(lv.color_make(255, 0, 0), 0) # RGB: Red -label1.align(lv.ALIGN.TOP_LEFT, 10, 10) - -# Label 2: Green -label2 = lv.label(scr) -label2.set_text("Green Text") -label2.set_style_text_color(lv.color_make(0, 255, 0), 0) # RGB: Green -label2.align(lv.ALIGN.TOP_LEFT, 10, 40) - -# Label 3: Blue -label3 = lv.label(scr) -label3.set_text("Blue Text") -label3.set_style_text_color(lv.color_make(0, 0, 255), 0) # RGB: Blue -label3.align(lv.ALIGN.TOP_LEFT, 10, 70) - -# Label 4: White -label4 = lv.label(scr) -label4.set_text("White Text") -label4.set_style_text_color(lv.color_make(255, 255, 255), 0) # RGB: White -label4.align(lv.ALIGN.TOP_LEFT, 10, 100) - -# Label 5: Yellow -label5 = lv.label(scr) -label5.set_text("Yellow Text") -label5.set_style_text_color(lv.color_make(255, 255, 0), 0) # RGB: Yellow -label5.align(lv.ALIGN.TOP_LEFT, 10, 130) - - +scr.set_style_bg_color(lv.color_hex(0x000000), 0) # Create a button (using lv.obj as a base) btn = lv.obj(scr) @@ -234,14 +184,11 @@ style.set_pad_all(10) style.set_radius(10) label.add_style(style, 0) -# Load the screen -lv.scr_load(scr) - # Connect to Wi-Fi and fetch block height if connect_wifi(): height = get_block_height() - label.set_text(f"Bitcoin Block Height: {height}") + label.set_text(f"Block Height: {height}") else: - label.set_text("Bitcoin Block Height: Wi-Fi Error") + label.set_text("Block Height: Wi-Fi Error")