819 views|0 replies

6822

Posts

11

Resources
The OP
 

【STM32U599J-DK】TouchGFX dynamic temperature curve [Copy link]

TouchGFX temperature curve
【Foreword】
touchGFX has powerful chart functions, especially dynamic chart controls, which can display data curves. Today, we will use this control to realize real-time temperature curves.
【hardware】
  1. STM32U599J-DK development board.
  2. Developed on the stts22h temperature sensor.
【develop software】
  1. stm32CubeIDE.
  2. VScode
  3. TouchGFX 4.22.1
【Study Materials】
【Implementation steps】
  1. Create a blank project:
  2. Add dynamic chart tools to the project:
  3. You can add background images and text (omitted) as you like.
  4. To modify the properties of a chart:
The graphical interface design is now complete. You can refer to the tutorial for specific setting parameters.
【Code writing】
  1. Use stm32cubeIDE to open i2c3 and load the stts22h driver library into the project, add the driver compilation file and path:
  2. Add the stts22h driver header file back to app_freertos.c, and declare a global function to pass the obtained temperature value. Read the value of stts22h in a task in a loop.

    I will attach the source code of the specific driver library for reading, you can check it yourself, it is not the focus of this article.
  3. According to the principle of Model->Presenter->View, add the codes back one by one.
    1. In model.hpp, we add variables to store temperature and functions to get and save temperature:
    2. In the tick function of model.cpp, we update the temperature value every 20 ticks.
    3. In screen1Presenter.hpp we implement a function to get the temperature value:
      float getTemp()
      {
      return model->getTemp();
      }
    4. Add the handleTickEvent virtual function to screen1View.hpp and implement it in screen1Presenter.cpp
    5. In screen1View.cpp, add a temperature value data point to the graphics control every 60 ticks:
void Screen1View::handleTickEvent()
{
tickCount++;
if(tickCount == 60)
{
dynamicGraph1.addDataPoint((int)presenter->getTemp());
tickCount = 0;
}
}
Now our code and graphical interface are designed, compile and download in touchGFX Designer.
【Effects achieved】
Attached project source code:
MyTEMP.zip (97.52 MB, downloads: 2, 售价: 1 分芯积分)
This post is from stm32/stm8
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list