STM32H7S78-DK搭载高性能STM32H7S78 单片机,基于Arm Cortex-M7内核,主频可达600MHz,处理性能高达1284 DMIPS。这为其强大的图形处理能力提供了坚实的硬件基础。图形加速硬件,内置NeoChrom GPU,支持2D和2.5D图形加速,以及JPEG编解码器。这使得STM32H7S78能够轻松应对复杂的图形处理任务,实现高性能ARM A架构处理器效果。灵活的存储解决方案:集成64KB的bootflash存储器,支持多种外部存储接口,如xSPI、SD/SDIO/MMC和FMC。这为用户提供了丰富的存储选择,便于存储和访问大量的图形数据。可以进行流畅的人机交互和丰富的用户界面。 小米SU7很有个性的,车型的中控屏上方配备了用于显示G值的原型码表。这一设计不仅体现了小米汽车对于驾驶体验的重视,也展示了其在智能化、数字化方面的创新实力。通过实时显示G值,驾驶员可以更加直观地了解车辆的加速性能以及行驶状态,从而做出更加精准的驾驶判断。
本次公开一个基于TouchGFX的设计一款G显示副屏,TouchGFX是一款针对STM32微控制器进行了优化的免费高级图形软件框架。它包含易于使用的拖放式图形构建PC工具TouchGFX Designer以及强大的优化图形处理内核TouchGFX引擎,TouchGFX大大简化了GUI开发过程。
开始设计:
思路:首先设计一个背景图,创建小圆点控件。在TouchGFX Designer中,使用圆形控件或其他形状控件来创建小圆点。设置控件的初始属性,如大小、颜色和透明度。添加位置控制逻辑,在TouchGFX的代码中,添加逻辑来处理小圆点的位置控制。可以使用触摸事件监听器来捕捉用户的触摸滑动动作,并根据滑动距离更新小圆点的位置。实现坐标更新:编写代码来更新小圆点的坐标。确保更新后的坐标在屏幕的有效范围内。实际引用是解析车载总线CAN,解析陀螺仪数据。
代码开发:基于freertos 开发,cubeMX 资源配置:
static void MX_LTDC_Init(void)
{
/* USER CODE BEGIN LTDC_Init 0 */
/* USER CODE END LTDC_Init 0 */
LTDC_LayerCfgTypeDef pLayerCfg = {0};
/* USER CODE BEGIN LTDC_Init 1 */
/* USER CODE END LTDC_Init 1 */
hltdc.Instance = LTDC;
hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
hltdc.Init.HorizontalSync = 4;
hltdc.Init.VerticalSync = 4;
hltdc.Init.AccumulatedHBP = 12;
hltdc.Init.AccumulatedVBP = 12;
hltdc.Init.AccumulatedActiveW = 812;
hltdc.Init.AccumulatedActiveH = 492;
hltdc.Init.TotalWidth = 820;
hltdc.Init.TotalHeigh = 506;
hltdc.Init.Backcolor.Blue = 0;
hltdc.Init.Backcolor.Green = 0;
hltdc.Init.Backcolor.Red = 0;
if (HAL_LTDC_Init(&hltdc) != HAL_OK)
{
Error_Handler();
}
pLayerCfg.WindowX0 = 0;
pLayerCfg.WindowX1 = 800;
pLayerCfg.WindowY0 = 0;
pLayerCfg.WindowY1 = 480;
pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
pLayerCfg.Alpha = 255;
pLayerCfg.Alpha0 = 0;
pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
pLayerCfg.FBStartAdress = 0;
pLayerCfg.ImageWidth = 800;
pLayerCfg.ImageHeight = 480;
pLayerCfg.Backcolor.Blue = 0;
pLayerCfg.Backcolor.Green = 0;
pLayerCfg.Backcolor.Red = 0;
if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN LTDC_Init 2 */
/* USER CODE END LTDC_Init 2 */
}
/**
* [url=home.php?mod=space&uid=247401]@brief[/url] GPIO Initialization Function
* @param None
* @retval None
*/
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* USER CODE BEGIN MX_GPIO_Init_1 */
/* USER CODE END MX_GPIO_Init_1 */
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOF_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOF, FRAME_RATE_Pin|RENDER_TIME_Pin|MCU_ACTIVE_Pin|VSYNC_FREQ_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(LCD_EN_GPIO_Port, LCD_EN_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_Port, LCD_BL_CTRL_Pin, GPIO_PIN_SET);
/*Configure GPIO pins : FRAME_RATE_Pin RENDER_TIME_Pin VSYNC_FREQ_Pin */
GPIO_InitStruct.Pin = FRAME_RATE_Pin|RENDER_TIME_Pin|VSYNC_FREQ_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
/*Configure GPIO pin : MCU_ACTIVE_Pin */
GPIO_InitStruct.Pin = MCU_ACTIVE_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(MCU_ACTIVE_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : LCD_EN_Pin */
GPIO_InitStruct.Pin = LCD_EN_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(LCD_EN_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : TP_IRQ_Pin */
GPIO_InitStruct.Pin = TP_IRQ_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(TP_IRQ_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : LCD_BL_CTRL_Pin */
GPIO_InitStruct.Pin = LCD_BL_CTRL_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(LCD_BL_CTRL_GPIO_Port, &GPIO_InitStruct);
/* EXTI interrupt init*/
HAL_NVIC_SetPriority(TP_IRQ_EXTI_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(TP_IRQ_EXTI_IRQn);
/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}
效果展示:
|