14
14
#include " dsi.h"
15
15
#include " st7701.h"
16
16
#include " SDRAM.h"
17
+ extern " C" {
17
18
#include " video_modes.h"
19
+ }
18
20
#include " anx7625.h"
19
21
20
22
#if __has_include ("lvgl.h")
@@ -30,7 +32,29 @@ void lvgl_displayFlushing(lv_disp_drv_t * disp, const lv_area_t * area, lv_color
30
32
Arduino_H7_Video::Arduino_H7_Video (int width, int heigth, DisplayShieldModel shield) :
31
33
ArduinoGraphics(width, heigth) {
32
34
_shield = shield;
33
- _landscape = (width >= heigth) ? true : false ;
35
+
36
+ #if defined(ARDUINO_PORTENTA_H7_M7)
37
+ if (_shield == NONE_SHIELD) {
38
+ _edidMode = video_modes_get_edid (width, heigth);
39
+ } else if (_shield == GIGA_DISPLAY_SHIELD) {
40
+ _edidMode = EDID_MODE_480x800_60Hz;
41
+ }
42
+ #elif defined(ARDUINO_GIGA)
43
+ _edidMode = EDID_MODE_480x800_60Hz;
44
+ #endif
45
+
46
+ switch (_edidMode) {
47
+ case EDID_MODE_640x480_60Hz ... EDID_MODE_800x600_59Hz:
48
+ case EDID_MODE_1024x768_60Hz ... EDID_MODE_1920x1080_60Hz:
49
+ _rotated = (width < heigth) ? true : false ;
50
+ break ;
51
+ case EDID_MODE_480x800_60Hz:
52
+ _rotated = (width >= heigth) ? true : false ;
53
+ break ;
54
+ default :
55
+ _rotated = false ;
56
+ break ;
57
+ }
34
58
}
35
59
36
60
Arduino_H7_Video::~Arduino_H7_Video () {
@@ -61,20 +85,20 @@ int Arduino_H7_Video::begin() {
61
85
anx7625_dp_get_edid (0 , &recognized_edid);
62
86
63
87
// DSI Configuration
64
- anx7625_dp_start (0 , &recognized_edid, EDID_MODE_720x480_60Hz );
88
+ anx7625_dp_start (0 , &recognized_edid, ( enum edid_modes) _edidMode );
65
89
66
90
// Configure SDRAM
67
91
SDRAM.begin (dsi_getFramebufferEnd ());
68
92
} else if (_shield == GIGA_DISPLAY_SHIELD) {
69
93
// Init LCD Controller
70
- st7701_init (EDID_MODE_480x800_60Hz );
94
+ st7701_init (( enum edid_modes) _edidMode );
71
95
72
96
// Configure SDRAM
73
97
SDRAM.begin ();
74
98
}
75
99
#elif defined(ARDUINO_GIGA)
76
100
// Init LCD Controller
77
- st7701_init (EDID_MODE_480x800_60Hz );
101
+ st7701_init (( enum edid_modes) _edidMode );
78
102
79
103
// Configure SDRAM
80
104
SDRAM.begin ();
@@ -101,7 +125,7 @@ int Arduino_H7_Video::begin() {
101
125
lv_disp_drv_init (&disp_drv); /* Basic initialization */
102
126
disp_drv.flush_cb = lvgl_displayFlushing; /* Set your driver function */
103
127
disp_drv.draw_buf = &draw_buf; /* Assign the buffer to the display */
104
- if (_landscape ) {
128
+ if (_rotated ) {
105
129
disp_drv.hor_res = height (); /* Set the horizontal resolution of the display */
106
130
disp_drv.ver_res = width (); /* Set the vertical resolution of the display */
107
131
disp_drv.rotated = LV_DISP_ROT_270;
@@ -141,7 +165,7 @@ void Arduino_H7_Video::clear(){
141
165
uint32_t bg = ArduinoGraphics::background ();
142
166
uint32_t x_size, y_size;
143
167
144
- if (_landscape ) {
168
+ if (_rotated ) {
145
169
x_size = (height () <= dsi_getDisplayXSize ())? height () : dsi_getDisplayXSize ();
146
170
y_size = (width () <= dsi_getDisplayYSize ())? width () : dsi_getDisplayYSize ();
147
171
} else {
@@ -155,7 +179,7 @@ void Arduino_H7_Video::clear(){
155
179
void Arduino_H7_Video::set (int x, int y, uint8_t r, uint8_t g, uint8_t b) {
156
180
uint32_t x_rot, y_rot;
157
181
158
- if (_landscape ) {
182
+ if (_rotated ) {
159
183
x_rot = ((height ()-1 ) - y);
160
184
y_rot = x;
161
185
0 commit comments