@@ -13,19 +13,19 @@ static lv_disp_drv_t disp_drv;
13
13
/* Display flushing */
14
14
static void my_disp_flush (lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
15
15
{
16
- uint32_t w = lv_area_get_width (area);
17
- uint32_t h = lv_area_get_height (area);
18
16
19
- #if 1
20
- // SCB_InvalidateICache ();
21
-
22
- // SCB_CleanInvalidateDCache();
17
+ #if ARDUINO_PORTENTA_H7_M7
18
+ SCB_CleanInvalidateDCache ();
19
+ SCB_InvalidateICache ();
20
+ # endif
23
21
24
22
DMA2D_HandleTypeDef * dma2d = stm32_get_DMA2D ();
25
23
26
24
lv_color_t * pDst = (lv_color_t *)fb;
27
25
pDst += area->y1 * lcd_x_size + area->x1 ;
28
26
27
+ uint32_t w = lv_area_get_width (area);
28
+ uint32_t h = lv_area_get_height (area);
29
29
/* ##-1- Configure the DMA2D Mode, Color Mode and output offset #############*/
30
30
dma2d->Init .Mode = DMA2D_M2M;
31
31
dma2d->Init .ColorMode = DMA2D_OUTPUT_RGB565;
@@ -45,31 +45,26 @@ static void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t
45
45
dma2d->LayerCfg [1 ].AlphaInverted = DMA2D_REGULAR_ALPHA; /* No ForeGround Alpha inversion */
46
46
47
47
/* DMA2D Initialization */
48
- if (HAL_DMA2D_Init (dma2d) == HAL_OK) {
49
- if (HAL_DMA2D_ConfigLayer (dma2d, 1 ) == HAL_OK) {
50
- HAL_DMA2D_Start (dma2d, (uint32_t )color_p, (uint32_t )pDst, w, h);
51
- HAL_DMA2D_PollForTransfer (dma2d, 1000 );
48
+ if (HAL_DMA2D_Init (dma2d) == HAL_OK) {
49
+ if (HAL_DMA2D_ConfigLayer (dma2d, 1 ) == HAL_OK) {
50
+ HAL_DMA2D_Start (dma2d, (uint32_t )color_p, (uint32_t )pDst, w, h);
51
+ HAL_DMA2D_PollForTransfer (dma2d, 1000 );
52
52
}
53
53
}
54
- #else
55
- //NO GPU
56
- int32_t y;
57
- for(y = area->y1; y <= area->y2; y++) {
58
- memcpy(&fb[y * lcd_x_size + area->x1], color_p, w * sizeof(lv_color_t));
59
- color_p += w;
60
- }
61
- #endif
62
- lv_disp_flush_ready (disp); /* tell lvgl that flushing is done */
54
+
55
+ lv_disp_flush_ready (disp); /* tell lvgl that flushing is done */
63
56
}
64
57
65
58
66
59
/* If your MCU has hardware accelerator (GPU) then you can use it to blend to memories using opacity
67
- * It can be used only in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/
60
+ It can be used only in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/
68
61
static void gpu_blend (lv_disp_drv_t * disp_drv, lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa)
69
62
{
70
-
71
- // SCB_CleanInvalidateDCache();
72
-
63
+
64
+ #if ARDUINO_PORTENTA_H7_M7
65
+ SCB_CleanInvalidateDCache ();
66
+ #endif
67
+
73
68
DMA2D_HandleTypeDef * dma2d = stm32_get_DMA2D ();
74
69
75
70
dma2d->Instance = DMA2D;
@@ -87,24 +82,25 @@ static void gpu_blend(lv_disp_drv_t * disp_drv, lv_color_t * dest, const lv_colo
87
82
dma2d->LayerCfg [0 ].AlphaMode = DMA2D_NO_MODIF_ALPHA;
88
83
dma2d->LayerCfg [0 ].InputColorMode = DMA2D_INPUT_RGB565;
89
84
dma2d->LayerCfg [0 ].InputOffset = 0 ;
90
-
85
+
91
86
/* DMA2D Initialization */
92
87
if (HAL_DMA2D_Init (dma2d) == HAL_OK) {
93
88
if (HAL_DMA2D_ConfigLayer (dma2d, 0 ) == HAL_OK && HAL_DMA2D_ConfigLayer (dma2d, 1 ) == HAL_OK) {
94
- HAL_DMA2D_BlendingStart (dma2d, (uint32_t ) src, (uint32_t ) dest, (uint32_t ) dest, length, 1 );
95
- HAL_DMA2D_PollForTransfer (dma2d, 1000 );
89
+ HAL_DMA2D_BlendingStart (dma2d, (uint32_t ) src, (uint32_t ) dest, (uint32_t ) dest, length, 1 );
90
+ HAL_DMA2D_PollForTransfer (dma2d, 1000 );
96
91
}
97
92
}
98
93
}
99
94
100
95
/* If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color */
101
96
static void gpu_fill (lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
102
- const lv_area_t * fill_area, lv_color_t color)
97
+ const lv_area_t * fill_area, lv_color_t color)
103
98
{
104
- // SCB_CleanInvalidateDCache();
105
-
106
- DMA2D_HandleTypeDef * dma2d = stm32_get_DMA2D ();
99
+ # if ARDUINO_PORTENTA_H7_M7
100
+ SCB_CleanInvalidateDCache ();
101
+ # endif
107
102
103
+ DMA2D_HandleTypeDef * dma2d = stm32_get_DMA2D ();
108
104
109
105
lv_color_t * destination = dest_buf + (dest_width * fill_area->y1 + fill_area->x1 );
110
106
@@ -120,7 +116,7 @@ static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t
120
116
if (HAL_DMA2D_Init (dma2d) == HAL_OK) {
121
117
if (HAL_DMA2D_ConfigLayer (dma2d, 1 ) == HAL_OK) {
122
118
lv_coord_t h = lv_area_get_height (fill_area);
123
- if (HAL_DMA2D_BlendingStart (dma2d, lv_color_to32 (color), (uint32_t )destination, (uint32_t )destination, w, h) == HAL_OK) {
119
+ if (HAL_DMA2D_BlendingStart (dma2d, lv_color_to32 (color), (uint32_t )destination, (uint32_t )destination, w, h) == HAL_OK) {
124
120
HAL_DMA2D_PollForTransfer (dma2d, 1000 );
125
121
}
126
122
}
@@ -157,11 +153,11 @@ void setup() {
157
153
anx7625_dp_start (0 , &recognized_edid, EDID_MODE_720x480_60Hz);
158
154
SDRAM.begin (getFramebufferEnd ());
159
155
160
- lv_init ();
161
-
156
+ lv_init ();
157
+
162
158
lcd_x_size = stm32_getXSize ();
163
159
lcd_y_size = stm32_getYSize ();
164
-
160
+
165
161
fb = (uint16_t *)getNextFrameBuffer ();
166
162
getNextFrameBuffer ();
167
163
@@ -182,14 +178,11 @@ void setup() {
182
178
// lv_label_set_text(label, "Hello Arduino! Dev-7,0");
183
179
// lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
184
180
185
- lv_demo_widgets ();
181
+ lv_demo_widgets ();
186
182
187
183
}
188
184
189
185
void loop () {
190
- uint32_t t1 = millis ();
191
186
lv_task_handler ();
192
187
delay (3 );
193
- uint32_t t2 = millis ();
194
- lv_tick_inc (t2-t1);
195
188
}
0 commit comments