Skip to content

Commit

Permalink
just something to play with lvgl
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gagarinlg authored and raphaelcoeffic committed Jun 11, 2022
1 parent 67787af commit fb7a736
Show file tree
Hide file tree
Showing 20 changed files with 1,313 additions and 15 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "libopenui"]
path = radio/src/thirdparty/libopenui
url = https://github.com/EdgeTX/libopenui.git
branch = master
branch = lvgl
[submodule "radio/src/thirdparty/AccessDenied"]
path = radio/src/thirdparty/AccessDenied
url = https://github.com/raphaelcoeffic/AccessDenied.git
Expand All @@ -12,3 +12,6 @@
path = radio/src/thirdparty/FreeRTOS
url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git
shallow = true
[submodule "radio/src/thirdparty/lvgl"]
path = radio/src/thirdparty/lvgl
url = https://github.com/lvgl/lvgl.git
2 changes: 2 additions & 0 deletions cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
cmake --target simu "$@"
68 changes: 68 additions & 0 deletions help.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
additional libopenui patch:
diff --git a/src/bitmapbuffer.h b/src/bitmapbuffer.h
index 146c815..f5ce245 100644
--- a/src/bitmapbuffer.h
+++ b/src/bitmapbuffer.h
@@ -36,7 +36,7 @@ constexpr uint8_t STASHED = 0x33;
#define APPLY_OFFSET() x += this->offsetX; y += this->offsetY
#define RESTORE_OFFSET() this->offsetX = offsetX, this->offsetY = offsetY

-#if defined(LCD_VERTICAL_INVERT)
+#if defined(LCD_VERTICAL_INVERT) && 0
#define MOVE_PIXEL_RIGHT(p, count) p -= count
#else
#define MOVE_PIXEL_RIGHT(p, count) p += count
@@ -156,7 +156,7 @@ class BitmapBufferBase

inline const pixel_t * getPixelPtrAbs(coord_t x, coord_t y) const
{
-#if defined(LCD_VERTICAL_INVERT)
+#if defined(LCD_VERTICAL_INVERT) && 0
x = _width - x - 1;
y = _height - y - 1;
#endif
@@ -401,7 +401,7 @@ class BitmapBuffer: public BitmapBufferBase<pixel_t>

inline const pixel_t * getPixelPtrAbs(coord_t x, coord_t y) const
{
-#if defined(LCD_VERTICAL_INVERT)
+#if defined(LCD_VERTICAL_INVERT) && 0
x = _width - x - 1;
y = _height - y - 1;
#endif
@@ -410,7 +410,7 @@ class BitmapBuffer: public BitmapBufferBase<pixel_t>

inline pixel_t * getPixelPtrAbs(coord_t x, coord_t y)
{
-#if defined(LCD_VERTICAL_INVERT)
+#if defined(LCD_VERTICAL_INVERT) && 0
x = _width - x - 1;
y = _height - y - 1;
#endif
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index c256d0b..dede0c9 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -179,9 +179,21 @@ void MainWindow::invalidate(const rect_t & rect)
invalidatedRect = rect;
}
}
-
+#include "lvgl/lvgl.h"
+extern lv_obj_t * canvas;
+extern BitmapBuffer lcdBackup;
bool MainWindow::refresh()
{
+ if (invalidatedRect.w) {
+ lcdBackup.setOffset(0, 0);
+ lcdBackup.setClippingRect(0,LCD_W,0, LCD_H);
+ fullPaint(&lcdBackup);
+ lv_canvas_copy_buf(canvas, lcdBackup.getData(), 0, 0, LCD_W, LCD_H);
+ lv_img_cache_invalidate_src(lcdBackup.getData());
+ lv_obj_invalidate(canvas);
+ }
+ 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);
15 changes: 15 additions & 0 deletions prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
mkdir -p _Release
cd _Release

cmake -DPCB=X10 -DPCBREV=TX16S -DDEFAULT_MODE=2 -DGVARS=YES -DPPM_UNIT=US -DHELI=YES -DLUA=YES -DINTERNAL_GPS=NO -DCMAKE_BUILD_TYPE=Release ../

cd ..
mkdir -p _Debug
cd _Debug
cmake -DPCB=X10 -DPCBREV=TX16S -DDEFAULT_MODE=2 -DGVARS=YES -DPPM_UNIT=US -DHELI=YES -DLUA=YES -DINTERNAL_GPS=NO -DCMAKE_BUILD_TYPE=Debug ../

cd ..
mkdir -p _NV14
cd _NV14
cmake -DPCB=NV14 -DDEFAULT_MODE=2 -DGVARS=YES -DPPM_UNIT=US -DHELI=YES -DLUA=YES -DINTERNAL_GPS=NO -DCMAKE_BUILD_TYPE=Debug ../
4 changes: 2 additions & 2 deletions radio/src/bitmaps/480x272/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ else()
if(PCBREV STREQUAL T18)
# straight screen
else()
set(BITMAP_ARGS ${BITMAP_ARGS} --reverse)
set(MASK_ARGS ${MASK_ARGS} --reverse)
# set(BITMAP_ARGS ${BITMAP_ARGS} --reverse)
# set(MASK_ARGS ${MASK_ARGS} --reverse)
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion radio/src/fonts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ else()
endif()

if(PCB STREQUAL X10)
set(FONT_ARGS ${FONT_ARGS} --reverse)
# set(FONT_ARGS ${FONT_ARGS} --reverse)
endif()

add_truetype_font_target(9 9 ${subset} none "${FONT_ARGS}")
Expand Down
146 changes: 146 additions & 0 deletions radio/src/gui/colorlcd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ set(GUI_SRC
menu_screen.cpp
screen_setup.cpp
switch_warn_dialog.cpp
LvglWrapper.cpp
)

macro(add_gui_src src)
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit fb7a736

Please sign in to comment.