Skip to content

Commit 4740646

Browse files
committed
Port to new video library
1 parent 889ebf9 commit 4740646

File tree

6 files changed

+42
-868
lines changed

6 files changed

+42
-868
lines changed

examples/Gears/Gears.ino

+22-25
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@ extern "C" {
33
#include "zbuffer.h"
44
#include "GL/gl.h"
55
}
6-
#include "Portenta_lvgl.h"
6+
#include "Arduino_H7_Video.h"
7+
#include "Arduino_GigaDisplayTouch.h"
78
#include "dsi.h"
9+
#include "lvgl.h"
810
#include "SDRAM.h"
9-
#include "Goodix.h" // Arduino_GT911_Library
10-
11-
void LCD_ST7701_Init();
1211

1312
uint16_t touchpad_x;
1413
uint16_t touchpad_y;
1514

16-
void i2c_touch_setup();
17-
void i2c_touch_loop();
1815
extern "C" void init_gears();
1916
extern "C" void draw_gears();
2017
extern "C" void idle_gears();
@@ -26,11 +23,11 @@ extern "C" void tkSwapBuffers(void)
2623

2724
}
2825

29-
GTPoint prev_points[3];
26+
GDTpoint_t prev_points[3];
3027
float zoom_scale = 1.0f;
3128
uint32_t first_touch = 0;
3229

33-
void handleTouch(int8_t contacts, GTPoint *points) {
30+
void handleTouch(uint8_t contacts, GDTpoint_t *points) {
3431
if (first_touch == 0 || millis() - first_touch > 500) {
3532
first_touch = millis();
3633
goto save;
@@ -86,25 +83,28 @@ static void anim(lv_timer_t * timer) {
8683
lv_obj_invalidate(canvas);
8784
}
8885

86+
#ifdef ARDUINO_GIGA
87+
#ifdef LANDSCAPE
88+
Arduino_H7_Video display(800, 480, GigaDisplayShield);
89+
#else
90+
Arduino_H7_Video display(480, 800, GigaDisplayShield);
91+
#endif
92+
Arduino_GigaDisplayTouch touch;
93+
#else
94+
Arduino_H7_Video display(720, 480, USBCVideo);
95+
#endif
96+
8997
void setup() {
9098
Serial.begin(115200);
91-
while (!Serial);
9299

100+
display.begin();
93101
#ifdef ARDUINO_GIGA
94-
i2c_touch_setup();
95-
giga_init_video(LANDSCAPE);
96-
LCD_ST7701_Init();
97-
#else
98-
portenta_init_video();
102+
touch.begin();
103+
touch.onDetect(handleTouch);
99104
#endif
100105

101-
if (LANDSCAPE) {
102-
WINDOWX = stm32_getYSize();
103-
WINDOWY = stm32_getXSize();
104-
} else {
105-
WINDOWX = stm32_getXSize();
106-
WINDOWY = stm32_getYSize();
107-
}
106+
WINDOWX = display.width();
107+
WINDOWY = display.height();
108108

109109
cbuf = (lv_color_t*)ea_malloc(WINDOWX * WINDOWY * 4);
110110

@@ -121,12 +121,9 @@ void setup() {
121121
}
122122

123123
void loop() {
124-
#ifdef ARDUINO_GIGA
125-
i2c_touch_loop();
126-
#endif
127124
#if LVGL_VERSION_MAJOR > 7
128125
lv_timer_handler();
129126
#else
130127
lv_task_handler();
131128
#endif
132-
}
129+
}

0 commit comments

Comments
 (0)