2025-02-24 02:57 AM
Hello,
I am working on a TouchGFX project using the STM32H7S78-DK board and implementing dynamic text updates on the display. The text fields should display data read from Flash memory, such as firmware version, name, and model. However, the text is not updating as expected.
I have followed various examples and modified my implementation accordingly.
Here is my code,
/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#ifndef ABOUTVIEWBASE_HPP
#define ABOUTVIEWBASE_HPP
#include <gui/common/FrontendApplication.hpp>
#include <mvp/View.hpp>
#include <gui/about_screen/AboutPresenter.hpp>
#include <touchgfx/widgets/Box.hpp>
#include <touchgfx/EasingEquations.hpp>
#include <touchgfx/mixins/FadeAnimator.hpp>
#include <touchgfx/widgets/TextArea.hpp>
#include <touchgfx/widgets/Image.hpp>
#include <touchgfx/widgets/TextAreaWithWildcard.hpp>
class AboutViewBase : public touchgfx::View<AboutPresenter>
{
public:
AboutViewBase();
virtual ~AboutViewBase();
virtual void setupScreen();
void setNameText(const Unicode::UnicodeChar* text);
void setModelText(const Unicode::UnicodeChar* text);
void setFirmwareVersionText(const Unicode::UnicodeChar* text);
protected:
FrontendApplication& application() {
return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance());
}
/*
* Member Declarations
*/
touchgfx::Box __background;
touchgfx::FadeAnimator< touchgfx::Box > box1;
touchgfx::TextArea textArea1;
touchgfx::TextArea textArea1_1;
touchgfx::Image image1;
// touchgfx::TextArea textArea1_2;
// touchgfx::TextArea textArea1_2_1;
touchgfx::TextArea textArea1_2_4_1;
touchgfx::TextArea textArea1_2_1_1;
touchgfx::TextArea textArea1_2_4_1_2;
touchgfx::TextArea textArea1_2_1_1_1;
touchgfx::TextArea textArea1_2_4_1_2_1;
touchgfx::TextArea textArea1_2_1_1_1_1;
touchgfx::TextArea textArea1_2_4_1_2_1_1;
// touchgfx::TextArea textArea1_2_1_1_2;
touchgfx::TextArea textArea1_2_4_1_2_2;
touchgfx::TextArea textArea1_2_1_1_1_2;
touchgfx::TextArea textArea1_2_4_1_2_1_2;
touchgfx::TextArea textArea1_2_1_1_1_1_1;
touchgfx::TextArea textArea1_2_4_1_2_1_1_1;
touchgfx::TextArea textArea1_2_4_1_1;
touchgfx::TextAreaWithOneWildcard textArea1_2_1;
touchgfx::TextAreaWithOneWildcard textArea1_2;
touchgfx::TextAreaWithOneWildcard textArea1_2_1_1_2;
private:
};
#endif // ABOUTVIEWBASE_HPP
/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#include <gui_generated/about_screen/AboutViewBase.hpp>
#include <touchgfx/Color.hpp>
#include <texts/TextKeysAndLanguages.hpp>
#include <images/BitmapDatabase.hpp>
#include <texts/TextKeysAndLanguages.hpp>
#include <touchgfx/Unicode.hpp>
#include "stdio.h"
#include <string.h>
#include "touchgfx/widgets/TextAreaWithWildcard.hpp"
static Unicode::UnicodeChar unicodeName[25];
static Unicode::UnicodeChar unicodeModel[25];
static Unicode::UnicodeChar unicodeFirmwareVersion[25];
AboutViewBase::AboutViewBase()
{
printf("AboutViewBase::AboutViewBase\n");
__background.setPosition(0, 0, 800, 480);
__background.setColor(touchgfx::Color::getColorFromRGB(0, 0, 0));
add(__background);
box1.setPosition(0, 0, 800, 480);
box1.setColor(touchgfx::Color::getColorFromRGB(27, 27, 27));
add(box1);
textArea1.setXY(41, 87);
textArea1.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1.setLinespacing(0);
textArea1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_7DB4));
add(textArea1);
textArea1_1.setXY(41, 120);
textArea1_1.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_1.setLinespacing(0);
textArea1_1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_TOPK));
add(textArea1_1);
image1.setXY(27, 153);
image1.setBitmap(touchgfx::Bitmap(BITMAP_FRAME_427324379_ID));
add(image1);
// change model text
textArea1_2.setXY(63, 231);
textArea1_2.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2.setLinespacing(0);
// textArea1_2.setWideTextAction(WIDE_TEXT_WORDWRAP);
textArea1_2.setWildcard(unicodeModel);
textArea1_2.setTypedText(touchgfx::TypedText(T___SINGLEUSE_JUPU));
add(textArea1_2);
// change name text
textArea1_2_1.setXY(63, 196);
textArea1_2_1.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_1.setLinespacing(0);
// textArea1_2_1.setWideTextAction(WIDE_TEXT_WORDWRAP);
textArea1_2_1.setWildcard(unicodeName);
textArea1_2_1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_IHOU));
add(textArea1_2_1);
textArea1_2_4_1.setXY(63, 183);
textArea1_2_4_1.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_4_1.setLinespacing(0);
textArea1_2_4_1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_NX7D));
add(textArea1_2_4_1);
textArea1_2_1_1.setXY(299, 220);
textArea1_2_1_1.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_1_1.setLinespacing(0);
textArea1_2_1_1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_UOB0));
add(textArea1_2_1_1);
textArea1_2_4_1_2.setXY(299, 189);
textArea1_2_4_1_2.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_4_1_2.setLinespacing(0);
textArea1_2_4_1_2.setTypedText(touchgfx::TypedText(T___SINGLEUSE_TZKJ));
add(textArea1_2_4_1_2);
textArea1_2_1_1_1.setXY(467, 220);
textArea1_2_1_1_1.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_1_1_1.setLinespacing(0);
textArea1_2_1_1_1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_UP52));
add(textArea1_2_1_1_1);
textArea1_2_4_1_2_1.setXY(467, 189);
textArea1_2_4_1_2_1.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_4_1_2_1.setLinespacing(0);
textArea1_2_4_1_2_1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_R4N3));
add(textArea1_2_4_1_2_1);
textArea1_2_1_1_1_1.setXY(637, 220);
textArea1_2_1_1_1_1.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_1_1_1_1.setLinespacing(0);
textArea1_2_1_1_1_1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_C1SQ));
add(textArea1_2_1_1_1_1);
textArea1_2_4_1_2_1_1.setXY(637, 189);
textArea1_2_4_1_2_1_1.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_4_1_2_1_1.setLinespacing(0);
textArea1_2_4_1_2_1_1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_5FL9));
add(textArea1_2_4_1_2_1_1);
// change firmware version text
textArea1_2_1_1_2.setXY(299, 343);
textArea1_2_1_1_2.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_1_1_2.setLinespacing(0);
// textArea1_2_1_1_2.setWideTextAction(WIDE_TEXT_WORDWRAP);
textArea1_2_1_1_2.setWildcard(unicodeFirmwareVersion);
textArea1_2_1_1_2.setTypedText(touchgfx::TypedText(T___SINGLEUSE_SZM2));
add(textArea1_2_1_1_2);
textArea1_2_4_1_2_2.setXY(299, 312);
textArea1_2_4_1_2_2.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_4_1_2_2.setLinespacing(0);
textArea1_2_4_1_2_2.setTypedText(touchgfx::TypedText(T___SINGLEUSE_W78I));
add(textArea1_2_4_1_2_2);
textArea1_2_1_1_1_2.setXY(467, 343);
textArea1_2_1_1_1_2.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_1_1_1_2.setLinespacing(0);
textArea1_2_1_1_1_2.setTypedText(touchgfx::TypedText(T___SINGLEUSE_64P8));
add(textArea1_2_1_1_1_2);
textArea1_2_4_1_2_1_2.setXY(467, 312);
textArea1_2_4_1_2_1_2.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_4_1_2_1_2.setLinespacing(0);
textArea1_2_4_1_2_1_2.setTypedText(touchgfx::TypedText(T___SINGLEUSE_4KJX));
add(textArea1_2_4_1_2_1_2);
textArea1_2_1_1_1_1_1.setXY(637, 343);
textArea1_2_1_1_1_1_1.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_1_1_1_1_1.setLinespacing(0);
textArea1_2_1_1_1_1_1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_EAIP));
add(textArea1_2_1_1_1_1_1);
textArea1_2_4_1_2_1_1_1.setXY(637, 312);
textArea1_2_4_1_2_1_1_1.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_4_1_2_1_1_1.setLinespacing(0);
textArea1_2_4_1_2_1_1_1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_X662));
add(textArea1_2_4_1_2_1_1_1);
textArea1_2_4_1_1.setXY(63, 218);
textArea1_2_4_1_1.setColor(touchgfx::Color::getColorFromRGB(249, 249, 249));
textArea1_2_4_1_1.setLinespacing(0);
textArea1_2_4_1_1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_OIVS));
add(textArea1_2_4_1_1);
}
AboutViewBase::~AboutViewBase()
{
}
void AboutViewBase::setupScreen()
{
printf("AboutViewBase::setupScreen:\n");
size_t namelen = Unicode::strlen(unicodeName);
size_t modellen = Unicode::strlen(unicodeModel);
size_t fwlen = Unicode::strlen(unicodeFirmwareVersion);
for (size_t i = 0; i < namelen; i++)
{
printf("%c", (char)unicodeName[i]);
}
printf("\n");
for (size_t i = 0; i < modellen; i++)
{
printf("%c", (char)unicodeModel[i]);
}
printf("\n");
for (size_t i = 0; i < fwlen; i++)
{
printf("%c", (char)unicodeFirmwareVersion[i]);
}
printf("\n");
Unicode::snprintf(unicodeName, namelen, "%s", unicodeName);
textArea1_2_1.invalidate();
textArea1_2_1.resizeToCurrentText();
textArea1_2_1.invalidate();
Unicode::snprintf(unicodeModel, modellen, "%s", unicodeModel);
textArea1_2.invalidate();
textArea1_2.resizeToCurrentText();
textArea1_2.invalidate();
Unicode::snprintf(unicodeFirmwareVersion, fwlen, "%s", unicodeFirmwareVersion);
textArea1_2_1_1_2.invalidate();
textArea1_2_1_1_2.resizeToCurrentText();
textArea1_2_1_1_2.invalidate();
}
void AboutViewBase::setNameText(const Unicode::UnicodeChar* text)
{
printf("setNameText\n");
Unicode::strncpy(unicodeName, text, sizeof(unicodeName) / sizeof(Unicode::UnicodeChar) - 1);
unicodeName[sizeof(unicodeName) / sizeof(Unicode::UnicodeChar) - 1] = '\0';
}
void AboutViewBase::setModelText(const Unicode::UnicodeChar* text)
{
printf("setModelText\n");
Unicode::strncpy(unicodeModel, text, sizeof(unicodeModel) / sizeof(Unicode::UnicodeChar) - 1);
unicodeModel[sizeof(unicodeModel) / sizeof(Unicode::UnicodeChar) - 1] = '\0';
}
void AboutViewBase::setFirmwareVersionText(const Unicode::UnicodeChar* text)
{
printf("setFirmwareVersionText\n");
Unicode::strncpy(unicodeFirmwareVersion, text, sizeof(unicodeFirmwareVersion) / sizeof(Unicode::UnicodeChar) - 1);
unicodeFirmwareVersion[sizeof(unicodeFirmwareVersion) / sizeof(Unicode::UnicodeChar) - 1] = '\0';
setupScreen();
}
I need assistance in correctly implementing dynamic text updates in TouchGFX. Please help me resolve this issue.
Board: STM32H7S78-DK
Tools Used: STM32CubeIDE, TouchGFX
Thank you.
/Mehul