You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.9 KiB
Python
79 lines
1.9 KiB
Python
from micropython import const # NOQA
|
|
import display_driver_framework
|
|
# from font import get_font
|
|
|
|
# inter_font_20 = get_font("inter_20.bin")
|
|
|
|
_WIDTH = const(480)
|
|
_HEIGHT = const(320)
|
|
|
|
_BUFFER_SIZE = _WIDTH * _HEIGHT * 3
|
|
import lcd_bus # NOQA
|
|
|
|
bus = lcd_bus.SDLBus(flags=0)
|
|
|
|
buf1 = bus.allocate_framebuffer(_BUFFER_SIZE, 0)
|
|
buf2 = bus.allocate_framebuffer(_BUFFER_SIZE, 0)
|
|
|
|
import lvgl as lv # NOQA
|
|
|
|
import sdl_display # NOQA
|
|
|
|
lv.init()
|
|
display = sdl_display.SDLDisplay(
|
|
data_bus=bus,
|
|
display_width=480,
|
|
display_height=320,
|
|
frame_buffer1=buf1,
|
|
frame_buffer2=buf2,
|
|
color_space=lv.COLOR_FORMAT.RGB888
|
|
)
|
|
|
|
display.init()
|
|
|
|
import sdl_pointer
|
|
|
|
mouse = sdl_pointer.SDLPointer()
|
|
print(mouse)
|
|
|
|
import task_handler
|
|
th = task_handler.TaskHandler()
|
|
|
|
scrn = lv.screen_active()
|
|
scrn.set_style_bg_color(lv.color_hex(0x000000), 0)
|
|
|
|
tabview = lv.tabview(scrn)
|
|
tabview.set_tab_bar_position(lv.DIR.LEFT)
|
|
tabview.set_tab_bar_size(80)
|
|
|
|
tab_buttons = tabview.get_tab_bar()
|
|
tab_buttons.set_style_text_color(lv.color_hex(0xFFFFFF), 0)
|
|
#f58700 dark orange
|
|
tab_buttons.set_style_border_side(lv.BORDER_SIDE.RIGHT, lv.PART.ITEMS | lv.STATE.CHECKED)
|
|
tab_buttons.set_style_text_font(lv.font_inter_36,0)
|
|
home_tab = tabview.add_tab(lv.SYMBOL.HOME)
|
|
target_tab = tabview.add_tab(lv.SYMBOL.LIST)
|
|
settings_tab = tabview.add_tab(lv.SYMBOL.SETTINGS)
|
|
|
|
# Button on settings
|
|
|
|
btn = lv.button(settings_tab)
|
|
btn.align(lv.ALIGN.CENTER, 0, 0)
|
|
btn.set_size(150, 75)
|
|
btn_label = lv.label(btn)
|
|
btn_label.align(lv.ALIGN.CENTER, 0, 0)
|
|
btn_label.set_style_text_font(lv.font_inter_20, 0)
|
|
btn_label.set_style_text_align(lv.STATE.DEFAULT, lv.TEXT_ALIGN.CENTER)
|
|
btn_label.set_text("Button")
|
|
g_btn_count = 0
|
|
|
|
def btn_event_cb(e: lv.event_t):
|
|
btn = e.get_target_obj()
|
|
label = btn.get_child(0)
|
|
if e.get_code() == lv.EVENT.CLICKED:
|
|
global g_btn_count
|
|
g_btn_count += 1
|
|
label.set_text(f"Button: {g_btn_count}")
|
|
|
|
btn.add_event_cb(btn_event_cb, lv.EVENT.ALL, None)
|