You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# 320x200 => make 320x240 screenshot => it's 240x200 (but the display shows more than 200)
35
+
importmpos.ui
37
36
mpos.ui.main_display=st7789.ST7789(
38
37
data_bus=display_bus,
39
38
frame_buffer1=fb1,
40
39
frame_buffer2=fb2,
41
40
display_width=170,
42
41
display_height=320,
43
-
color_space=lv.COLOR_FORMAT.RGB565,
42
+
color_space=lv.COLOR_FORMAT.RGB565, # gives bad colors
43
+
#color_space=lv.COLOR_FORMAT.RGB888, # not supported by qemu
44
44
color_byte_order=st7789.BYTE_ORDER_RGB,
45
45
# rgb565_byte_swap=False, # always False is data_bus.get_lane_count() == 8
46
+
power_pin=9, # Must set RD pin to high, otherwise blank screen as soon as LVGL's task_handler starts
46
47
reset_pin=5,
47
-
backlight_pin=38,
48
+
reset_state=st7789.STATE_LOW, # needs low: high will not enable the display
49
+
backlight_pin=38, # needed
48
50
backlight_on_state=st7789.STATE_PWM,
51
+
offset_x=0,
52
+
offset_y=35
49
53
)
54
+
mpos.ui.main_display.set_power(True) # set RD pin to high before the rest, otherwise garbled output
50
55
mpos.ui.main_display.init()
51
-
mpos.ui.main_display.set_power(True)
52
-
mpos.ui.main_display.set_backlight(100)
56
+
mpos.ui.main_display.set_backlight(100) # works
53
57
54
58
lv.init()
55
-
#mpos.ui.main_display.set_rotation(lv.DISPLAY_ROTATION._90) # must be done after initializing display and creating the touch drivers, to ensure proper handling
56
-
mpos.ui.main_display.set_color_inversion(True) # doesnt seem to do anything?
59
+
mpos.ui.main_display.set_rotation(lv.DISPLAY_ROTATION._270) # must be done after initializing display and creating the touch drivers, to ensure proper handling
60
+
mpos.ui.main_display.set_color_inversion(True)
61
+
57
62
58
63
# Button handling code:
59
64
frommachineimportPin
60
-
btn_a=Pin(0, Pin.IN, Pin.PULL_UP) # 1
61
-
btn_b=Pin(14, Pin.IN, Pin.PULL_UP) # 2
62
-
btn_c=Pin(3, Pin.IN, Pin.PULL_UP) # 3
65
+
btn_a=Pin(0, Pin.IN, Pin.PULL_UP)
66
+
btn_b=Pin(14, Pin.IN, Pin.PULL_UP)
63
67
64
68
# Key repeat configuration
65
69
# This whole debounce logic is only necessary because LVGL 9.2.2 seems to have an issue where
66
70
# the lv_keyboard widget doesn't handle PRESSING (long presses) properly, it loses focus.
67
71
REPEAT_INITIAL_DELAY_MS=300# Delay before first repeat
68
72
REPEAT_RATE_MS=100# Interval between repeats
73
+
REPEAT_PREV_BECOMES_BACK=700# Long previous press becomes back button
74
+
COMBO_GRACE_MS=60# Accept near-simultaneous A+B as ENTER
69
75
last_key=None
70
76
last_state=lv.INDEV_STATE.RELEASED
71
-
#key_press_start = 0 # Time when key was first pressed
72
-
#last_repeat_time = 0 # Time of last repeat event
77
+
key_press_start=0# Time when key was first pressed
78
+
last_repeat_time=0# Time of last repeat event
79
+
last_a_down_time=0
80
+
last_b_down_time=0
81
+
last_a_pressed=False
82
+
last_b_pressed=False
73
83
74
84
# Read callback
75
85
# Warning: This gets called several times per second, and if it outputs continuous debugging on the serial line,
76
86
# that will break tools like mpremote from working properly to upload new files over the serial line, thus needing a reflash.
0 commit comments