Skip to content

Commit 3601b83

Browse files
leonardocavagnisfacchinm
authored andcommitted
embed LVGL touch management inside H7_Video library
1 parent f24f6f4 commit 3601b83

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

libraries/H7_Video/examples/LVGLDemo/LVGLDemo.ino

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,8 @@ void setup() {
2727
giga_touch_setup();
2828

2929
Display.begin();
30-
31-
static lv_indev_drv_t indev_drv; /* Descriptor of a input device driver */
32-
lv_indev_drv_init(&indev_drv); /* Basic initialization */
33-
indev_drv.type = LV_INDEV_TYPE_POINTER; /* Touch pad is a pointer-like device */
34-
indev_drv.read_cb = my_touchpad_read; /* Set your driver function */
35-
lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv); /* Register the driver in LVGL and save the created input device object */
36-
30+
Display.attachLVGLTouchCb((void (*)(void*,void*))(my_touchpad_read));
31+
3732
/* Change the active screen's background color */
3833
lv_obj_set_style_bg_color(lv_scr_act(), lv_color_hex(0x03989e), LV_PART_MAIN);
3934

libraries/H7_Video/src/H7_Video.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,12 @@ void lvgl_displayFlushing(lv_disp_drv_t * disp, const lv_area_t * area, lv_color
123123
stm32_LCD_DrawImage((void *) color_p, (void *)(getCurrentFrameBuffer() + offsetPos), width, height, DMA2D_INPUT_RGB565);
124124
lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/
125125
}
126+
127+
void H7_Video::attachLVGLTouchCb(void (*touch_cb)(void*,void*)) {
128+
static lv_indev_drv_t indev_drv; /* Descriptor of a input device driver */
129+
lv_indev_drv_init(&indev_drv); /* Basic initialization */
130+
indev_drv.type = LV_INDEV_TYPE_POINTER; /* Touch pad is a pointer-like device */
131+
indev_drv.read_cb = (void(*)(lv_indev_drv_t *, lv_indev_data_t *))(touch_cb); /* Set your driver function */
132+
lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv); /* Register the driver in LVGL and save the created input device object */
133+
}
126134
#endif

libraries/H7_Video/src/H7_Video.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class H7_Video : public ArduinoGraphics {
2828
virtual void endDraw();
2929

3030
virtual void set(int x, int y, uint8_t r, uint8_t g, uint8_t b);
31+
32+
void attachLVGLTouchCb(void (*touch_cb)(void*,void*));
3133
private:
3234
DisplayShieldModel _shield;
3335
bool _landscape;

0 commit comments

Comments
 (0)