我的目标是使用
STM32H735G-DK 板调出自定义显示。作为第一个简单步骤,我按照此处给出的说明使用带有内部(小)帧缓冲区的现有显示器:
请参阅下面的代码片段,我只是试图在帧缓冲区中设置一些 RGB888 颜色,并通过从 main() 中调用一个简单方法来重复循环。但是除了黑色或白色之外的任何其他颜色都会失败,通常在显示屏上显示为灰色条带......
也许我错过了有关 RGB888 颜色存储方式的一些信息。
声明帧缓冲区的代码:
- // The display on the STM32H735G-DK is a RGB888 with 480 x 272 px.
- // Lets use a small framebuffer for a portion of the display that
- // could fit into internal RAM.
- uint32_t *framebuffer[480*100];
- uint32_t bufferSize = sizeof(framebuffer)/sizeof(framebuffer[0]);
从 main() 调用的方法
- static void FillDisplay(void)
- {
- // BLACK - works OK
- uint32_t RGB888_color = 0x00000000;
- for (uint32_t i = 0; i < bufferSize; i++)
- {
- *(uint32_t*)(framebuffer + i)= RGB888_color;
- }
- // WHITE works OK
- HAL_Delay(1500);
- RGB888_color = 0xFFFFFFFF;
- for (uint32_t i = 0; i < bufferSize; i++)
- {
- *(uint32_t*)(framebuffer + i)= RGB888_color;
- }
- // PINK does not work..
- HAL_Delay(1500);
- RGB888_color = 255 << 16 | 0 << 8 | 255 << 0;
- for (uint32_t i = 0; i < bufferSize; i++)
- {
- *(uint32_t*)(framebuffer + i)= RGB888_color;
- }
- }
在 main() 中执行的代码:
- /* USER CODE BEGIN 2 */
- // Enable the display with setting high pins
- // for LCD_DISP and LCD_BL_CTRL for STM32H735G-DK
- HAL_GPIO_WritePin(GPIOD, LCD_DISP_Pin,1);
- HAL_GPIO_WritePin(GPIOG, LCD_BL_CTRL_Pin,1);
- // Set frame buffer to LTDC
- HAL_LTDC_SetAddress(&hltdc, (uint32_t)framebuffer, LTDC_LAYER_1);
- /* USER CODE END 2 */
- /* Infinite loop */
- /* USER CODE BEGIN WHILE */
- while (1)
- {
- /* USER CODE END WHILE */
- /* USER CODE BEGIN 3 */
- FillDisplay();
- HAL_Delay(1500);
- }
- /* USER CODE END 3 */
我在这里错过了什么......?