1414#include " dsi.h"
1515#include " st7701.h"
1616#include " SDRAM.h"
17+ extern " C" {
1718#include " video_modes.h"
19+ }
1820#include " anx7625.h"
1921
2022#if __has_include ("lvgl.h")
@@ -30,7 +32,29 @@ void lvgl_displayFlushing(lv_disp_drv_t * disp, const lv_area_t * area, lv_color
3032Arduino_H7_Video::Arduino_H7_Video (int width, int heigth, DisplayShieldModel shield) :
3133 ArduinoGraphics(width, heigth) {
3234 _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+ }
3458}
3559
3660Arduino_H7_Video::~Arduino_H7_Video () {
@@ -61,20 +85,20 @@ int Arduino_H7_Video::begin() {
6185 anx7625_dp_get_edid (0 , &recognized_edid);
6286
6387 // DSI Configuration
64- anx7625_dp_start (0 , &recognized_edid, EDID_MODE_720x480_60Hz );
88+ anx7625_dp_start (0 , &recognized_edid, ( enum edid_modes) _edidMode );
6589
6690 // Configure SDRAM
6791 SDRAM.begin (dsi_getFramebufferEnd ());
6892 } else if (_shield == GIGA_DISPLAY_SHIELD) {
6993 // Init LCD Controller
70- st7701_init (EDID_MODE_480x800_60Hz );
94+ st7701_init (( enum edid_modes) _edidMode );
7195
7296 // Configure SDRAM
7397 SDRAM.begin ();
7498 }
7599 #elif defined(ARDUINO_GIGA)
76100 // Init LCD Controller
77- st7701_init (EDID_MODE_480x800_60Hz );
101+ st7701_init (( enum edid_modes) _edidMode );
78102
79103 // Configure SDRAM
80104 SDRAM.begin ();
@@ -101,7 +125,7 @@ int Arduino_H7_Video::begin() {
101125 lv_disp_drv_init (&disp_drv); /* Basic initialization */
102126 disp_drv.flush_cb = lvgl_displayFlushing; /* Set your driver function */
103127 disp_drv.draw_buf = &draw_buf; /* Assign the buffer to the display */
104- if (_landscape ) {
128+ if (_rotated ) {
105129 disp_drv.hor_res = height (); /* Set the horizontal resolution of the display */
106130 disp_drv.ver_res = width (); /* Set the vertical resolution of the display */
107131 disp_drv.rotated = LV_DISP_ROT_270;
@@ -141,7 +165,7 @@ void Arduino_H7_Video::clear(){
141165 uint32_t bg = ArduinoGraphics::background ();
142166 uint32_t x_size, y_size;
143167
144- if (_landscape ) {
168+ if (_rotated ) {
145169 x_size = (height () <= dsi_getDisplayXSize ())? height () : dsi_getDisplayXSize ();
146170 y_size = (width () <= dsi_getDisplayYSize ())? width () : dsi_getDisplayYSize ();
147171 } else {
@@ -155,7 +179,7 @@ void Arduino_H7_Video::clear(){
155179void Arduino_H7_Video::set (int x, int y, uint8_t r, uint8_t g, uint8_t b) {
156180 uint32_t x_rot, y_rot;
157181
158- if (_landscape ) {
182+ if (_rotated ) {
159183 x_rot = ((height ()-1 ) - y);
160184 y_rot = x;
161185
0 commit comments