22
33#include " Arduino.h"
44#include " mbed.h"
5- #include " Portenta_Video.h"
5+ #include " Arduino_H7_Video.h"
6+ #include " dsi.h"
67
78#define sleep _sleep
89
@@ -89,8 +90,6 @@ static void addKeyToQueue(int pressed, unsigned char keyCode)
8990 s_KeyQueueWriteIndex %= KEYQUEUE_SIZE;
9091}
9192
92- struct edid recognized_edid;
93-
9493uint32_t LCD_X_Size = 0 , LCD_Y_Size = 0 ;
9594DMA2D_HandleTypeDef DMA2D_Handle;
9695
@@ -162,30 +161,13 @@ static void DMA2D_Init(uint16_t xsize, uint16_t ysize)
162161 HAL_DMA2D_PollForTransfer (&DMA2D_Handle, 100 );
163162}
164163
165- void DG_Init ()
166- {
167- int ret = -1 ;
168-
169- ret = anx7625_init (0 );
170- if (ret < 0 ) {
171- printf (" Cannot continue, anx7625 init failed.\n " );
172- while (1 );
173- }
164+ Arduino_H7_Video display (640 , 480 , USBCVideo);
174165
175- anx7625_wait_hpd_event (0 );
176- anx7625_dp_get_edid (0 , &recognized_edid);
177- // edid_set_framebuffer_bits_per_pixel(&recognized_edid, 16, 0);
178- // set_display_mode(&recognized_edid, EDID_MODE_720x480_60Hz);
179- // anx7625_dp_start(0, &recognized_edid, EDID_MODE_1280x720_60Hz);
180- anx7625_dp_start (0 , &recognized_edid, EDID_MODE_640x480_60Hz);
166+ uint32_t fbs[2 ];
181167
182- LCD_X_Size = stm32_getXSize ();
183- LCD_Y_Size = stm32_getYSize ();
184-
185- SDRAM.begin (getFramebufferEnd ());
186-
187- stm32_LCD_Clear (0 );
188- stm32_LCD_Clear (0 );
168+ void DG_Init ()
169+ {
170+ display.begin ();
189171}
190172
191173void DG_OnPaletteReload () {
@@ -224,8 +206,8 @@ static void DMA2D_CopyBuffer(uint32_t *pSrc, uint32_t *pDst)
224206 uint32_t xPos, yPos, destination;
225207
226208 /* ##-1- calculate the destination transfer address ############*/
227- xPos = (stm32_getXSize () - DOOMGENERIC_RESX) / 2 ;
228- yPos = (stm32_getYSize () - DOOMGENERIC_RESY) / 2 ;
209+ xPos = (display. width () - DOOMGENERIC_RESX) / 2 ;
210+ yPos = (display. height () - DOOMGENERIC_RESY) / 2 ;
229211
230212 destination = (uint32_t )pDst; // + ((yPos * stm32_getXSize()) + xPos) * 4;
231213
@@ -239,14 +221,15 @@ static void DMA2D_CopyBuffer(uint32_t *pSrc, uint32_t *pDst)
239221
240222void DG_DrawFrame ()
241223{
242- uint32_t fb = getNextFrameBuffer ();
224+ uint32_t fb = dsi_getCurrentFrameBuffer ();
243225#ifdef CORE_CM7
244226 // SCB_CleanInvalidateDCache();
245227 // SCB_InvalidateICache();
246228 SCB_InvalidateDCache_by_Addr ((uint32_t *)fb, DOOMGENERIC_RESX * DOOMGENERIC_RESY * 4 );
247229#endif
248230
249231 DMA2D_CopyBuffer ((uint32_t *)DG_ScreenBuffer, (uint32_t *)fb);
232+ dsi_drawCurrentFrameBuffer ();
250233 // handleKeyInput();
251234}
252235
0 commit comments