Adding project0 files
parent
dfc3ddf6ad
commit
0e9b98605f
@ -0,0 +1,66 @@
|
||||
A list of `lvgl.EVENT` names and values.
|
||||
|
||||
| Event Name | Value |
|
||||
|---------------------------|--------|
|
||||
| ALL | 0 |
|
||||
| PRESSED | 1 |
|
||||
| PRESSING | 2 |
|
||||
| PRESS_LOST | 3 |
|
||||
| SHORT_CLICKED | 4 |
|
||||
| LONG_PRESSED | 5 |
|
||||
| LONG_PRESSED_REPEAT | 6 |
|
||||
| CLICKED | 7 |
|
||||
| RELEASED | 8 |
|
||||
| SCROLL_BEGIN | 9 |
|
||||
| SCROLL_THROW_BEGIN | 10 |
|
||||
| SCROLL_END | 11 |
|
||||
| SCROLL | 12 |
|
||||
| GESTURE | 13 |
|
||||
| KEY | 14 |
|
||||
| ROTARY | 15 |
|
||||
| FOCUSED | 16 |
|
||||
| DEFOCUSED | 17 |
|
||||
| LEAVE | 18 |
|
||||
| HIT_TEST | 19 |
|
||||
| INDEV_RESET | 20 |
|
||||
| COVER_CHECK | 21 |
|
||||
| REFR_EXT_DRAW_SIZE | 22 |
|
||||
| DRAW_MAIN_BEGIN | 23 |
|
||||
| DRAW_MAIN | 24 |
|
||||
| DRAW_MAIN_END | 25 |
|
||||
| DRAW_POST_BEGIN | 26 |
|
||||
| DRAW_POST | 27 |
|
||||
| DRAW_POST_END | 28 |
|
||||
| DRAW_TASK_ADDED | 29 |
|
||||
| VALUE_CHANGED | 30 |
|
||||
| INSERT | 31 |
|
||||
| REFRESH | 32 |
|
||||
| READY | 33 |
|
||||
| CANCEL | 34 |
|
||||
| CREATE | 35 |
|
||||
| DELETE | 36 |
|
||||
| CHILD_CHANGED | 37 |
|
||||
| CHILD_CREATED | 38 |
|
||||
| CHILD_DELETED | 39 |
|
||||
| SCREEN_UNLOAD_START | 40 |
|
||||
| SCREEN_LOAD_START | 41 |
|
||||
| SCREEN_LOADED | 42 |
|
||||
| SCREEN_UNLOADED | 43 |
|
||||
| SIZE_CHANGED | 44 |
|
||||
| STYLE_CHANGED | 45 |
|
||||
| LAYOUT_CHANGED | 46 |
|
||||
| GET_SELF_SIZE | 47 |
|
||||
| INVALIDATE_AREA | 48 |
|
||||
| RESOLUTION_CHANGED | 49 |
|
||||
| COLOR_FORMAT_CHANGED | 50 |
|
||||
| REFR_REQUEST | 51 |
|
||||
| REFR_START | 52 |
|
||||
| REFR_READY | 53 |
|
||||
| RENDER_START | 54 |
|
||||
| RENDER_READY | 55 |
|
||||
| FLUSH_START | 56 |
|
||||
| FLUSH_FINISH | 57 |
|
||||
| FLUSH_WAIT_START | 58 |
|
||||
| FLUSH_WAIT_FINISH | 59 |
|
||||
| VSYNC | 60 |
|
||||
| PREPROCESS | 32768 |
|
@ -0,0 +1,125 @@
|
||||
from micropython import const # NOQA
|
||||
import display_driver_framework
|
||||
|
||||
_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_montserrat_16,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, 100)
|
||||
btn_label = lv.label(btn)
|
||||
btn_label.align(lv.ALIGN.CENTER, 0, 0)
|
||||
btn_label.set_style_text_font(lv.font_montserrat_14, 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)
|
||||
|
||||
|
||||
# lv_obj_set_style_border_side(tab_buttons, LV_BORDER_SIDE_RIGHT, LV_PART_ITEMS | LV_STATE_CHECKED);
|
||||
|
||||
# /*Add 3 tabs (the tabs are page (lv_page) and can be scrolled*/
|
||||
# lv_obj_t * tab1 = lv_tabview_add_tab(tabview, "Tab 1");
|
||||
# lv_obj_t * tab2 = lv_tabview_add_tab(tabview, "Tab 2");
|
||||
# lv_obj_t * tab3 = lv_tabview_add_tab(tabview, "Tab 3");
|
||||
# lv_obj_t * tab4 = lv_tabview_add_tab(tabview, "Tab 4");
|
||||
# lv_obj_t * tab5 = lv_tabview_add_tab(tabview, "Tab 5");
|
||||
|
||||
# lv_obj_set_style_bg_color(tab2, lv_palette_lighten(LV_PALETTE_AMBER, 3), 0);
|
||||
# lv_obj_set_style_bg_opa(tab2, LV_OPA_COVER, 0);
|
||||
|
||||
# /*Add content to the tabs*/
|
||||
# lv_obj_t * label = lv_label_create(tab1);
|
||||
# lv_label_set_text(label, "First tab");
|
||||
|
||||
# label = lv_label_create(tab2);
|
||||
# lv_label_set_text(label, "Second tab");
|
||||
|
||||
# label = lv_label_create(tab3);
|
||||
# lv_label_set_text(label, "Third tab");
|
||||
|
||||
# label = lv_label_create(tab4);
|
||||
# lv_label_set_text(label, "Forth tab");
|
||||
|
||||
# label = lv_label_create(tab5);
|
||||
# lv_label_set_text(label, "Fifth tab");
|
||||
|
||||
# lv_obj_remove_flag(lv_tabview_get_content(tabview), LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
|
||||
# # Button
|
||||
# btn = lv.button(scrn)
|
||||
# btn.set_pos(10, 10)
|
||||
# btn.set_size(120, 50)
|
||||
# btn_label = lv.label(btn)
|
||||
# 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)
|
Loading…
Reference in New Issue