你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

分享解决TouchGFX仪表盘设计的指针不显示问题。

[复制链接]
STMWoodData 发布时间:2026-9-11 10:56

最近发现使用touchgfx直接生成的项目仪表盘可以显示指针,但是使用STM32CUBEMX生成的touchgfx项目的仪表盘指针不显示问题。原因是CubeMX 可能默认没有启用 Texture Mapper。正常情况在FrontendApplicationBase.cpp文件中会有touchgfx自动添加的启动代码。

Texture Mapper(纹理映射器)在 STM32CubeMX 生成的项目中可能默认未被启用 ,这是导致指针不显示的一个非常隐蔽的原因。Texture Mapper 是 Gauge 指针实现旋转动画的底层依赖。它默认是关闭状态以节省代码空间。虽然 TouchGFX Designer 在生成新项目时会自动插入启用代码,但 STM32CubeMX 的生成流程有时会遗漏这一步,导致指针因为缺乏底层的渲染支持而无法绘制。

解决方法是在文件FrontendApplication.cpp手动添加代码:

#ifndef SIMULATOR
#include <platform/driver/lcd/LCD16bppSerialFlash.hpp>
#endif
#ifdef SIMULATOR
#include <platform/driver/lcd/LCD16bpp.hpp>
#endif

FrontendApplication::FrontendApplication(Model& m, FrontendHeap& heap)
    : FrontendApplicationBase(m, heap)
{
#ifndef SIMULATOR
    reinterpret_cast<touchgfx::LCD16bppSerialFlash&>(touchgfx::HAL::lcd()).enableTextureMapperAll();
    reinterpret_cast<touchgfx::LCD16bppSerialFlash&>(touchgfx::HAL::lcd()).enableDecompressorL8_All();
    reinterpret_cast<touchgfx::LCD16bppSerialFlash&>(touchgfx::HAL::lcd()).enableDecompressorRGB();
#endif
#ifdef SIMULATOR
    reinterpret_cast<touchgfx::LCD16bpp&>(touchgfx::HAL::lcd()).enableTextureMapperAll();
    reinterpret_cast<touchgfx::LCD16bpp&>(touchgfx::HAL::lcd()).enableDecompressorL8_All();
    reinterpret_cast<touchgfx::LCD16bpp&>(touchgfx::HAL::lcd()).enableDecompressorRGB();
#endif
}
收藏 评论0 发布时间:2026-9-11 10:56

举报

0个回答

所属标签

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版