just something to play with lvgl
simu is working partially
TX16S has worked, is now broken, due to changes to make simu work
working means, lvgl shows something on the display and handles touch events
to stop libopenui from interfering this is needed in libopenui:
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 09cc3d3..cda095f 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -79,7 +79,7 @@ void MainWindow::checkEvents()
if (touchPanelEventOccured()) {
short lastDeltaX = touchState.lastDeltaX;
short lastDeltaY = touchState.lastDeltaY;;
- touchState = touchPanelRead();
+ //touchState = touchPanelRead();
touchState.lastDeltaX = lastDeltaX;
touchState.lastDeltaY = lastDeltaY;
}
@@ -177,6 +177,7 @@ void MainWindow::invalidate(const rect_t & rect)
bool MainWindow::refresh()
{
+return false;
if (invalidatedRect.w) {
if (invalidatedRect.x > 0 || invalidatedRect.y > 0 || invalidatedRect.w < LCD_W || invalidatedRect.h < LCD_H) {
TRACE_WINDOWS("Refresh rect: left=%d top=%d width=%d height=%d", invalidatedRect.left(), invalidatedRect.top(), invalidatedRect.w, invalidatedRect.h);
add eclipse projetc files and helper scripts
some cleanup and fix simu
NV14 simu and TX16s simu are working with lvgl
no more magic numbers
added files for a lvgl wrapper class for initialization
moved lvgl initialization to LvglWrapper
code cleanup
started implementing a widget as a drawing target for libopenui
with some additional changesin libopenui, the libopenui ui can be displayed on a lvgl canvas
fix lvgl full screen canvas
update personal project files
add file with patch instructions for libopenui
works on NV14 with a canvas as the drawingtarget for libopenui and direct touch handling by libopenui
fix indentation
enabled double buffering for LVGL using the LCD frame buffers
transparancies are broken on TX16s
simulator does not work
untested on NV14
simu for NV14 and TX16S run and work mostly
works mostly on NV14 and TX16S
some pop ups (e.g. USB) flicker
LUA full screen apps won't display anything
touch handling still done by libopenui
on TX16S lvgl widgets are rotated by 180°
untested on all other radios
fix using of commeted out function. No touch handling for LVGL right now
rotate screens, so that libopenui and LVGL have the same screen rotation
removed the need to rotate images and fonts when using LVGL
currently the changes can be easily reverted
deleted lvgl copy
building with lvgl as unmodified submodule works
move lv_conf to radio/src
delete eclipse project files
use specific branch for lvgl
use libopenui lvgl branch
remove now unneeded help.txt
add missing file to colorlcd CMakelist
fix image display problems in TX16S simulator
just something to play with lvgl
simu is working partially
TX16S has worked, is now broken, due to changes to make simu work
working means, lvgl shows something on the display and handles touch events
to stop libopenui from interfering this is needed in libopenui:
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 09cc3d3..cda095f 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -79,7 +79,7 @@ void MainWindow::checkEvents()
if (touchPanelEventOccured()) {
short lastDeltaX = touchState.lastDeltaX;
short lastDeltaY = touchState.lastDeltaY;;
- touchState = touchPanelRead();
+ //touchState = touchPanelRead();
touchState.lastDeltaX = lastDeltaX;
touchState.lastDeltaY = lastDeltaY;
}
@@ -177,6 +177,7 @@ void MainWindow::invalidate(const rect_t & rect)
bool MainWindow::refresh()
{
+return false;
if (invalidatedRect.w) {
if (invalidatedRect.x > 0 || invalidatedRect.y > 0 || invalidatedRect.w < LCD_W || invalidatedRect.h < LCD_H) {
TRACE_WINDOWS("Refresh rect: left=%d top=%d width=%d height=%d", invalidatedRect.left(), invalidatedRect.top(), invalidatedRect.w, invalidatedRect.h);
add eclipse projetc files and helper scripts
some cleanup and fix simu
NV14 simu and TX16s simu are working with lvgl
no more magic numbers
added files for a lvgl wrapper class for initialization
moved lvgl initialization to LvglWrapper
code cleanup
started implementing a widget as a drawing target for libopenui
with some additional changesin libopenui, the libopenui ui can be displayed on a lvgl canvas
fix lvgl full screen canvas
update personal project files
add file with patch instructions for libopenui
works on NV14 with a canvas as the drawingtarget for libopenui and direct touch handling by libopenui
fix indentation
enabled double buffering for LVGL using the LCD frame buffers
transparancies are broken on TX16s
simulator does not work
untested on NV14
simu for NV14 and TX16S run and work mostly
works mostly on NV14 and TX16S
some pop ups (e.g. USB) flicker
LUA full screen apps won't display anything
touch handling still done by libopenui
on TX16S lvgl widgets are rotated by 180°
untested on all other radios
fix using of commeted out function. No touch handling for LVGL right now
rotate screens, so that libopenui and LVGL have the same screen rotation
removed the need to rotate images and fonts when using LVGL
currently the changes can be easily reverted
deleted lvgl copy
building with lvgl as unmodified submodule works
move lv_conf to radio/src
delete eclipse project files
This commit is contained in:
committed by
Raphael Coeffic
parent
67787afc92
commit
fb7a7364a4
@@ -75,6 +75,7 @@ set(GUI_SRC
|
||||
menu_screen.cpp
|
||||
screen_setup.cpp
|
||||
switch_warn_dialog.cpp
|
||||
LvglWrapper.cpp
|
||||
)
|
||||
|
||||
macro(add_gui_src src)
|
||||
@@ -134,6 +135,151 @@ foreach(LIBOPENUI_FILE ${LIBOPENUI_SRC})
|
||||
set(SRC ${SRC} thirdparty/libopenui/src/${LIBOPENUI_FILE})
|
||||
endforeach()
|
||||
|
||||
set(LVGL_SOURCES
|
||||
gpu/lv_gpu_stm32_dma2d.c
|
||||
core/lv_group.c
|
||||
core/lv_obj.c
|
||||
core/lv_event.c
|
||||
core/lv_indev.c
|
||||
core/lv_obj_scroll.c
|
||||
core/lv_obj_draw.c
|
||||
core/lv_disp.c
|
||||
core/lv_obj_style.c
|
||||
core/lv_theme.c
|
||||
core/lv_obj_style_gen.c
|
||||
core/lv_refr.c
|
||||
core/lv_indev_scroll.c
|
||||
core/lv_obj_class.c
|
||||
core/lv_obj_tree.c
|
||||
core/lv_obj_pos.c
|
||||
font/lv_font_montserrat_20.c
|
||||
font/lv_font_unscii_8.c
|
||||
font/lv_font_montserrat_48.c
|
||||
font/lv_font_montserrat_28.c
|
||||
font/lv_font_montserrat_26.c
|
||||
font/lv_font_montserrat_38.c
|
||||
font/lv_font_montserrat_18.c
|
||||
font/lv_font_montserrat_8.c
|
||||
font/lv_font_montserrat_44.c
|
||||
font/lv_font_montserrat_40.c
|
||||
font/lv_font_dejavu_16_persian_hebrew.c
|
||||
font/lv_font_montserrat_32.c
|
||||
font/lv_font_montserrat_46.c
|
||||
font/lv_font_montserrat_14.c
|
||||
font/lv_font_montserrat_12_subpx.c
|
||||
font/lv_font_montserrat_34.c
|
||||
font/lv_font_montserrat_16.c
|
||||
font/lv_font_montserrat_42.c
|
||||
font/lv_font_montserrat_12.c
|
||||
font/lv_font_simsun_16_cjk.c
|
||||
font/lv_font_montserrat_30.c
|
||||
font/lv_font_montserrat_22.c
|
||||
font/lv_font_montserrat_10.c
|
||||
font/lv_font_fmt_txt.c
|
||||
font/lv_font_montserrat_24.c
|
||||
font/lv_font_loader.c
|
||||
font/lv_font_montserrat_28_compressed.c
|
||||
font/lv_font.c
|
||||
font/lv_font_montserrat_36.c
|
||||
font/lv_font_unscii_16.c
|
||||
misc/lv_timer.c
|
||||
misc/lv_txt.c
|
||||
misc/lv_gc.c
|
||||
misc/lv_style_gen.c
|
||||
misc/lv_templ.c
|
||||
misc/lv_color.c
|
||||
misc/lv_fs.c
|
||||
misc/lv_printf.c
|
||||
misc/lv_style.c
|
||||
misc/lv_log.c
|
||||
misc/lv_area.c
|
||||
misc/lv_math.c
|
||||
misc/lv_tlsf.c
|
||||
misc/lv_anim_timeline.c
|
||||
misc/lv_ll.c
|
||||
misc/lv_bidi.c
|
||||
misc/lv_mem.c
|
||||
misc/lv_utils.c
|
||||
misc/lv_async.c
|
||||
misc/lv_anim.c
|
||||
misc/lv_txt_ap.c
|
||||
draw/lv_draw_mask.c
|
||||
draw/lv_img_cache.c
|
||||
draw/lv_draw_blend.c
|
||||
draw/lv_draw_line.c
|
||||
draw/lv_img_buf.c
|
||||
draw/lv_draw_rect.c
|
||||
draw/lv_draw_label.c
|
||||
draw/lv_draw_img.c
|
||||
draw/lv_draw_arc.c
|
||||
draw/lv_draw_triangle.c
|
||||
draw/lv_img_decoder.c
|
||||
hal/lv_hal_indev.c
|
||||
hal/lv_hal_disp.c
|
||||
hal/lv_hal_tick.c
|
||||
extra/others/snapshot/lv_snapshot.c
|
||||
extra/layouts/grid/lv_grid.c
|
||||
extra/layouts/flex/lv_flex.c
|
||||
extra/libs/bmp/lv_bmp.c
|
||||
extra/libs/gif/lv_gif.c
|
||||
extra/libs/gif/gifdec.c
|
||||
extra/libs/freetype/lv_freetype.c
|
||||
extra/libs/qrcode/lv_qrcode.c
|
||||
extra/libs/qrcode/qrcodegen.c
|
||||
extra/libs/sjpg/tjpgd.c
|
||||
extra/libs/sjpg/lv_sjpg.c
|
||||
extra/libs/fsdrv/lv_fs_win32.c
|
||||
extra/libs/fsdrv/lv_fs_stdio.c
|
||||
extra/libs/fsdrv/lv_fs_posix.c
|
||||
extra/libs/fsdrv/lv_fs_fatfs.c
|
||||
extra/libs/rlottie/lv_rlottie.c
|
||||
extra/libs/png/lv_png.c
|
||||
extra/libs/png/lodepng.c
|
||||
extra/lv_extra.c
|
||||
extra/widgets/imgbtn/lv_imgbtn.c
|
||||
extra/widgets/win/lv_win.c
|
||||
extra/widgets/colorwheel/lv_colorwheel.c
|
||||
extra/widgets/list/lv_list.c
|
||||
extra/widgets/chart/lv_chart.c
|
||||
extra/widgets/calendar/lv_calendar_header_arrow.c
|
||||
extra/widgets/calendar/lv_calendar.c
|
||||
extra/widgets/calendar/lv_calendar_header_dropdown.c
|
||||
extra/widgets/tileview/lv_tileview.c
|
||||
extra/widgets/led/lv_led.c
|
||||
extra/widgets/spinner/lv_spinner.c
|
||||
extra/widgets/tabview/lv_tabview.c
|
||||
extra/widgets/meter/lv_meter.c
|
||||
extra/widgets/spinbox/lv_spinbox.c
|
||||
extra/widgets/animimg/lv_animimg.c
|
||||
extra/widgets/span/lv_span.c
|
||||
extra/widgets/keyboard/lv_keyboard.c
|
||||
extra/widgets/msgbox/lv_msgbox.c
|
||||
extra/themes/basic/lv_theme_basic.c
|
||||
extra/themes/default/lv_theme_default.c
|
||||
extra/themes/mono/lv_theme_mono.c
|
||||
widgets/lv_line.c
|
||||
widgets/lv_dropdown.c
|
||||
widgets/lv_objx_templ.c
|
||||
widgets/lv_canvas.c
|
||||
widgets/lv_switch.c
|
||||
widgets/lv_btnmatrix.c
|
||||
widgets/lv_bar.c
|
||||
widgets/lv_roller.c
|
||||
widgets/lv_img.c
|
||||
widgets/lv_btn.c
|
||||
widgets/lv_checkbox.c
|
||||
widgets/lv_label.c
|
||||
widgets/lv_table.c
|
||||
widgets/lv_slider.c
|
||||
widgets/lv_textarea.c
|
||||
widgets/lv_arc.c
|
||||
)
|
||||
|
||||
|
||||
foreach(LVGL_FILE ${LVGL_SOURCES})
|
||||
set(SRC ${SRC} thirdparty/lvgl/src/${LVGL_FILE})
|
||||
endforeach()
|
||||
|
||||
add_gui_src(fullscreen_dialog.cpp)
|
||||
add_gui_src(message_dialog.cpp)
|
||||
add_gui_src(confirm_dialog.cpp)
|
||||
|
||||
@@ -0,0 +1,332 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
#include "LvglWrapper.h"
|
||||
|
||||
LvglWrapper* LvglWrapper::_instance = nullptr;
|
||||
|
||||
static lv_disp_drv_t disp_drv; /*A variable to hold the drivers. Must be static or global.*/
|
||||
lv_disp_t * disp;
|
||||
|
||||
static lv_disp_draw_buf_t disp_buf;
|
||||
static lv_indev_drv_t indev_drv;
|
||||
|
||||
void newLcdRefresh(uint16_t* buffer);
|
||||
static void flushLcd(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
|
||||
{
|
||||
#if 0
|
||||
uint16_t width = area->x2-area->x1+1;
|
||||
uint16_t height = area->y2-area->y1+1;
|
||||
#if defined (LCD_VERTICAL_INVERT)
|
||||
uint16_t x = LCD_W - area->x2 -1;
|
||||
uint16_t y = LCD_H - area->y2 -1;
|
||||
#else
|
||||
uint16_t x = area->x1;
|
||||
uint16_t y = area->y1;
|
||||
#endif
|
||||
|
||||
lcdCopy(lcd->getData(), lcdFront->getData());
|
||||
DMACopyBitmap(lcd->getData(), LCD_W, LCD_H, x, y, (uint16_t*)color_p, width, height, 0, 0, width, height);
|
||||
lv_disp_flush_ready(disp_drv);
|
||||
newLcdRefresh(nullptr);
|
||||
#else
|
||||
newLcdRefresh((uint16_t*)color_p);
|
||||
lv_disp_flush_ready(disp_drv);
|
||||
#endif
|
||||
}
|
||||
#if 1
|
||||
/*Initialize `disp_buf` with the buffer(s). With only one buffer use NULL instead buf_2 */
|
||||
static void btn_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * btn = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_CLICKED) {
|
||||
static uint8_t cnt = 0;
|
||||
cnt++;
|
||||
|
||||
/*Get the first child of the button which is the label and change its text*/
|
||||
lv_obj_t * label = lv_obj_get_child(btn, 0);
|
||||
lv_label_set_text_fmt(label, "Button: %d", cnt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void lv_example_get_started_1(void)
|
||||
{
|
||||
lv_obj_t * btn = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/
|
||||
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
|
||||
lv_obj_set_size(btn, 120, 50); /*Set its size*/
|
||||
lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_ALL, NULL); /*Assign a callback to the button*/
|
||||
|
||||
lv_obj_t * label = lv_label_create(btn); /*Add a label to the button*/
|
||||
lv_label_set_text(label, "Button"); /*Set the labels text*/
|
||||
lv_obj_center(label);
|
||||
}
|
||||
void lv_example_label_1(void)
|
||||
{
|
||||
lv_obj_t * label1 = lv_label_create(lv_scr_act());
|
||||
lv_label_set_long_mode(label1, LV_LABEL_LONG_WRAP); /*Break the long lines*/
|
||||
lv_label_set_recolor(label1, true); /*Enable re-coloring by commands in the text*/
|
||||
lv_label_set_text(label1, "#0000ff Re-color# #ff00ff words# #ff0000 of a# label, align the lines to the center "
|
||||
"and wrap long text automatically.");
|
||||
lv_obj_set_width(label1, 150); /*Set smaller width to make the lines wrap*/
|
||||
lv_obj_set_style_text_align(label1, LV_TEXT_ALIGN_CENTER, 0);
|
||||
lv_obj_align(label1, LV_ALIGN_CENTER, 0, -40);
|
||||
|
||||
|
||||
lv_obj_t * label2 = lv_label_create(lv_scr_act());
|
||||
lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL_CIRCULAR); /*Circular scroll*/
|
||||
lv_obj_set_width(label2, 150);
|
||||
lv_label_set_text(label2, "It is a circularly scrolling text. ");
|
||||
lv_obj_align(label2, LV_ALIGN_CENTER, 0, 40);
|
||||
}
|
||||
|
||||
extern "C" void my_input_read(lv_indev_drv_t * drv, lv_indev_data_t*data)
|
||||
{
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
TouchState st = touchPanelRead();
|
||||
if(st.event == TE_NONE)
|
||||
return;
|
||||
if(st.event == TE_DOWN || st.event == TE_SLIDE)
|
||||
{
|
||||
#if defined (LCD_VERTICAL_INVERT)
|
||||
data->point.x = LCD_W - st.x;
|
||||
data->point.y = LCD_H - st.y;
|
||||
#else
|
||||
data->point.x = st.x;
|
||||
data->point.y = st.y;
|
||||
#endif
|
||||
data->state = LV_INDEV_STATE_PRESSED;
|
||||
} else {
|
||||
data->state = LV_INDEV_STATE_RELEASED;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void slider_event_cb(lv_event_t * e);
|
||||
static lv_obj_t * slider_label;
|
||||
|
||||
/**
|
||||
* A default slider with a label displaying the current value
|
||||
*/
|
||||
void lv_example_slider_1(void)
|
||||
{
|
||||
/*Create a slider in the center of the display*/
|
||||
lv_obj_t * slider = lv_slider_create(lv_scr_act());
|
||||
lv_obj_center(slider);
|
||||
lv_obj_add_event_cb(slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
lv_obj_align(slider, LV_ALIGN_BOTTOM_LEFT, 10, -10);
|
||||
|
||||
/*Create a label below the slider*/
|
||||
slider_label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(slider_label, "0%");
|
||||
|
||||
lv_obj_align_to(slider_label, slider, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
static void slider_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * slider = lv_event_get_target(e);
|
||||
char buf[8];
|
||||
lv_snprintf(buf, sizeof(buf), "%d%%", (int)lv_slider_get_value(slider));
|
||||
lv_label_set_text(slider_label, buf);
|
||||
lv_obj_align_to(slider_label, slider, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
static void sw_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * sw = lv_event_get_target(e);
|
||||
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_obj_t * list = (lv_obj_t*)lv_event_get_user_data(e);
|
||||
|
||||
if(lv_obj_has_state(sw, LV_STATE_CHECKED))
|
||||
lv_obj_add_flag(list, LV_OBJ_FLAG_SCROLL_ONE);
|
||||
else
|
||||
lv_obj_clear_flag(list, LV_OBJ_FLAG_SCROLL_ONE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show an example to scroll snap
|
||||
*/
|
||||
void lv_example_scroll_2(void)
|
||||
{
|
||||
lv_obj_t * panel = lv_obj_create(lv_scr_act());
|
||||
lv_obj_set_size(panel, LCD_W/3, LCD_H/3);
|
||||
lv_obj_set_scroll_snap_x(panel, LV_SCROLL_SNAP_CENTER);
|
||||
lv_obj_set_flex_flow(panel, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_align(panel, LV_ALIGN_BOTTOM_RIGHT, 0, 0);
|
||||
// lv_obj_align(panel, LV_ALIGN_BOTTOM_RIGHT, 0, 20);
|
||||
|
||||
unsigned int i;
|
||||
for(i = 0; i < 10; i++) {
|
||||
lv_obj_t * btn = lv_btn_create(panel);
|
||||
lv_obj_set_size(btn, lv_pct(60), lv_pct(80));
|
||||
|
||||
lv_obj_t * label = lv_label_create(btn);
|
||||
if(i == 3) {
|
||||
lv_label_set_text_fmt(label, "Panel %u\nno snap", i);
|
||||
lv_obj_clear_flag(btn, LV_OBJ_FLAG_SNAPPABLE);
|
||||
} else {
|
||||
lv_label_set_text_fmt(label, "Panel %u", i);
|
||||
}
|
||||
|
||||
lv_obj_center(label);
|
||||
}
|
||||
lv_obj_update_snap(panel, LV_ANIM_ON);
|
||||
|
||||
/*Switch between "One scroll" and "Normal scroll" mode*/
|
||||
lv_obj_t * sw = lv_switch_create(lv_scr_act());
|
||||
lv_obj_align(sw, LV_ALIGN_TOP_RIGHT, -20, 10);
|
||||
lv_obj_add_event_cb(sw, sw_event_cb, LV_EVENT_ALL, panel);
|
||||
lv_obj_t * label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(label, "One scroll");
|
||||
lv_obj_align_to(label, sw, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* Create a transparent canvas with Chroma keying and indexed color format (palette).
|
||||
*/
|
||||
#define CANVAS_WIDTH LCD_W
|
||||
#define CANVAS_HEIGHT LCD_H
|
||||
lv_obj_t * canvas=nullptr;
|
||||
static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)] __SDRAM;
|
||||
void lv_example_canvas_2(void)
|
||||
{
|
||||
/*Create a button to better see the transparency*/
|
||||
//lv_btn_create(lv_scr_act());
|
||||
|
||||
/*Create a buffer for the canvas*/
|
||||
|
||||
/*Create a canvas and initialize its palette*/
|
||||
/*lv_obj_t * */canvas = lv_canvas_create(lv_scr_act());
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_TRUE_COLOR);
|
||||
#if 0
|
||||
lv_canvas_set_palette(canvas, 0, LV_COLOR_CHROMA_KEY);
|
||||
lv_canvas_set_palette(canvas, 1, lv_palette_main(LV_PALETTE_RED));
|
||||
|
||||
/*Create colors with the indices of the palette*/
|
||||
lv_color_t c0;
|
||||
lv_color_t c1;
|
||||
|
||||
c0.full = 0;
|
||||
c1.full = 1;
|
||||
|
||||
/*Red background (There is no dedicated alpha channel in indexed images so LV_OPA_COVER is ignored)*/
|
||||
lv_canvas_fill_bg(canvas, c1, LV_OPA_COVER);
|
||||
|
||||
/*Create hole on the canvas*/
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
for( y = 10; y < 30; y++) {
|
||||
for( x = 5; x < 20; x++) {
|
||||
lv_canvas_set_px_color(canvas, x, y, c0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
extern BitmapBuffer * lcdFront;
|
||||
extern BitmapBuffer * lcd;
|
||||
LvglWrapper::LvglWrapper()
|
||||
{
|
||||
lv_init();
|
||||
// lv_disp_draw_buf_init(&disp_buf, lcdGetScratchBuffer(),NULL, LCD_W*LCD_H);
|
||||
lv_disp_draw_buf_init(&disp_buf, lcdFront->getData(), lcd->getData(), LCD_W*LCD_H);
|
||||
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
|
||||
disp_drv.draw_buf = &disp_buf; /*Set an initialized buffer*/
|
||||
disp_drv.flush_cb = flushLcd; /*Set a flush callback to draw to the display*/
|
||||
disp_drv.hor_res = LCD_W; /*Set the horizontal resolution in pixels*/
|
||||
disp_drv.ver_res = LCD_H; /*Set the vertical resolution in pixels*/
|
||||
disp_drv.full_refresh = 0;
|
||||
disp_drv.direct_mode = 0;
|
||||
#if defined (LCD_VERTICAL_INVERT)
|
||||
disp_drv.rotated = LV_DISP_ROT_180;
|
||||
#endif
|
||||
disp_drv.sw_rotate = 1;
|
||||
|
||||
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
|
||||
indev_drv.type =LV_INDEV_TYPE_POINTER; /*See below.*/
|
||||
indev_drv.read_cb = my_input_read; /*See below.*/
|
||||
/*Register the driver in LVGL and save the created input device object*/
|
||||
|
||||
|
||||
disp = lv_disp_drv_register(&disp_drv); /*Register the driver and save the created display objects*/
|
||||
lv_example_canvas_2();
|
||||
|
||||
|
||||
#if 0
|
||||
/*lv_indev_t * my_indev = */lv_indev_drv_register(&indev_drv);
|
||||
lv_example_get_started_1();
|
||||
lv_example_label_1();
|
||||
lv_example_slider_1();
|
||||
lv_example_scroll_2();
|
||||
#endif
|
||||
}
|
||||
|
||||
void LvglWrapper::run()
|
||||
{
|
||||
tmr10ms_t tick = get_tmr10ms();
|
||||
lv_tick_inc((tick - lastTick) * 10);
|
||||
lastTick = tick;
|
||||
lv_timer_handler();
|
||||
}
|
||||
|
||||
#if 0
|
||||
extern const lv_obj_class_t GuiWidgetClass;
|
||||
|
||||
extern "C"
|
||||
void GuiWidgetConstructor(const struct _lv_obj_class_t * class_p, struct _lv_obj_t * obj)
|
||||
{}
|
||||
|
||||
extern "C"
|
||||
void GuiWidgetEvent(const struct _lv_obj_class_t * class_p, struct _lv_event_t * e)
|
||||
{
|
||||
LV_UNUSED(class_p);
|
||||
|
||||
lv_res_t res;
|
||||
|
||||
/*Call the ancestor's event handler*/
|
||||
res = lv_obj_event_base(&GuiWidgetClass, e);
|
||||
if(res != LV_RES_OK) return;
|
||||
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
|
||||
switch(code)
|
||||
{
|
||||
case LV_EVENT_DRAW_MAIN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
const lv_obj_class_t GuiWidgetClass = {
|
||||
.base_class = nullptr,
|
||||
.constructor_cb = GuiWidgetConstructor,
|
||||
.event_cb = GuiWidgetEvent,
|
||||
.editable = LV_OBJ_CLASS_EDITABLE_TRUE,
|
||||
.group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE,
|
||||
.instance_size = sizeof(GuiWidget)
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _LVGLWRAPPER_H_
|
||||
#define _LVGLWRAPPER_H_
|
||||
|
||||
#include "opentx_types.h"
|
||||
#include "lvgl/lvgl.h"
|
||||
#if 0
|
||||
struct GuiWidget
|
||||
{
|
||||
lv_obj_t obj;
|
||||
};
|
||||
#endif
|
||||
|
||||
class LvglWrapper {
|
||||
public:
|
||||
LvglWrapper();
|
||||
~LvglWrapper() {}
|
||||
|
||||
static LvglWrapper* instance()
|
||||
{
|
||||
if (!_instance)
|
||||
_instance = new LvglWrapper();
|
||||
|
||||
return _instance;
|
||||
}
|
||||
void run();
|
||||
|
||||
private:
|
||||
static LvglWrapper* _instance;
|
||||
tmr10ms_t lastTick = 0;
|
||||
};
|
||||
|
||||
#endif // _LVGLWRAPPER_H_
|
||||
@@ -170,7 +170,7 @@ uint8_t * decompressFont(const uint8_t * font, unsigned len)
|
||||
((uint16_t*)buf)[0] = (uint16_t)width;
|
||||
((uint16_t*)buf)[1] = (uint16_t)height;
|
||||
|
||||
#if defined(LCD_VERTICAL_INVERT)
|
||||
#if defined(LCD_VERTICAL_INVERT) && 0
|
||||
uint8_t* src = raw_font + font_size - 1;
|
||||
for(uint8_t* dst = buf + 4; src >= raw_font; --src, ++dst) {
|
||||
*dst = 0xFF - *src;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "fullscreen_dialog.h"
|
||||
#include "LvglWrapper.h"
|
||||
#include "mainwindow.h"
|
||||
#include "opentx.h"
|
||||
#include "libopenui.h"
|
||||
@@ -183,6 +184,7 @@ void FullScreenDialog::runForever()
|
||||
|
||||
RTOS_WAIT_MS(1);
|
||||
mainWin->run(false);
|
||||
LvglWrapper::instance()->run();
|
||||
}
|
||||
|
||||
deleteLater();
|
||||
@@ -204,6 +206,7 @@ void FullScreenDialog::runForeverNoPwrCheck()
|
||||
|
||||
RTOS_WAIT_MS(1);
|
||||
mainWin->run(false);
|
||||
LvglWrapper::instance()->run();
|
||||
}
|
||||
|
||||
deleteLater();
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include "coloredit.h"
|
||||
#include "draw_functions.h"
|
||||
#include "textedits.h"
|
||||
#include "LvglWrapper.h"
|
||||
|
||||
inline MessageDialog * createPopupInformation(const char * message)
|
||||
{
|
||||
@@ -74,6 +75,7 @@ inline void POPUP_INFORMATION(const char * message)
|
||||
while (popup->getParent()) {
|
||||
WDG_RESET();
|
||||
MainWindow::instance()->run(false);
|
||||
LvglWrapper::instance()->run();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +88,7 @@ inline void POPUP_WARNING(const char * message, const char * info = nullptr)
|
||||
while (popup->getParent()) {
|
||||
WDG_RESET();
|
||||
MainWindow::instance()->run(false);
|
||||
LvglWrapper::instance()->run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "radio_sdmanager.h"
|
||||
#include "opentx.h"
|
||||
#include "libopenui.h"
|
||||
#include "gui/colorlcd/LvglWrapper.h"
|
||||
#include "io/frsky_firmware_update.h"
|
||||
#include "io/multi_firmware_update.h"
|
||||
#include "io/bootloader_flash.h"
|
||||
@@ -163,6 +164,7 @@ class FlashDialog: public FullScreenDialog
|
||||
setMessage(message);
|
||||
progress.setValue(total > 0 ? count * 100 / total : 0);
|
||||
MainWindow::instance()->run(false);
|
||||
LvglWrapper::instance()->run();
|
||||
});
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user