2021-07-07 05:05 AM
Hi,
I made a STemWin based application for the STM32H747I-DISCO board. The app is a modified version of the STemWin_HelloWorld and GPIO_EXTI examples. The modification is simple. When the user presses the user button then the next LED is turned on and it prints the "Hello World! LEDx turned on�? message. If all the LEDs are on and the user presses the user button then all LEDs will be turned off and the LCD should show “Hello World! All LEDs turned off�? with white color. The color of the "Hello World! LEDx turned on�? message should be identical with the color of the turned on LED.
Now the problem is: when I launch the app then all the LEDs are turned off and the LCD shows the “Hello World! All LEDs turned off�? with white color. This is the default state. This is good. But if I press the user button then the next LED is turned on but the message on the LCD screen stays unchanged even the LCD screen update code runs fine, it generates the proper message, with the right color.
When the user presses a button then (See the attached picture with the main loop)
The whole thing works fine but only one time, during the startup. The LCD always shows the “Hello World! All LEDs turned off�? with white color and it never changes. It does not matter how many times I press the button.
So can anybody help? What I did wrong?
Many thanks for your help. Best regards,
Louis
2021-07-08 04:14 AM
Hi everybody!
I simplified my question above. I modified the “official�? STemWin_HelloWorld example to print the “Hello World!�? text with 4 colors. The colors are changed in every 2 seconds.
#include "GUI.h"
#include <string.h>
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
// Text to be printed
const char * HELLO_WORLD_TEXT = "Hello World!";
// Colors of text
const GUI_COLOR textColors[] = {GUI_WHITE, GUI_RED, GUI_BLUE, GUI_GREEN};
// Change colors after this time in ms
#define WAIT_TIME 2000
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
GUI_Clear();
GUI_SetFont(&GUI_Font32_1);
//+++++
// TFS20210708-1147 Print "Hello World" with different colors
// changing the screen in every 2 seconds
//-----
// Center horizontal and vertical middle
GUI_RECT textSize;
GUI_GetTextExtend(&textSize, HELLO_WORLD_TEXT, strlen(HELLO_WORLD_TEXT));
int width = textSize.x1 - textSize.x0;
int height = textSize.y1-textSize.y0;
// Calculate horizontal and vertical start coordinates
int xCoord = (LCD_GetXSize() - width) / 2;
int yCoord = (LCD_GetYSize() - height) / 2;
// Initialize colors
int colorIndex = 0;
int numberOfColors = sizeof(textColors) / sizeof(GUI_COLOR);
while (1)
{
// Set current text color
GUI_SetColor(textColors[colorIndex++]);
// Check number of colors
if (colorIndex >= numberOfColors)
colorIndex = 0;
// Print text
GUI_DispStringAt(HELLO_WORLD_TEXT, xCoord, yCoord);
// Wait 2 seconds
GUI_Delay(WAIT_TIME);
}
}
The LCD screen should show the Hello World! text with white, red, blue and green colors, but the text is always printed with white color. It never changes.
Observations:
What is wrong with this code above?
(I hope somebody reads this forum from ST…)
Thanks for your help.
Louis
2022-01-07 06:14 AM
Hi @Louis Balázs
Are you able to solve this problem?
I am also facing a similar problem with STM32F7 Discovery Board.
In my case also if I used GUI_Delay (this works fine), but after the GUI_Delay, I am not able to use any Display String function provided.
In my case even if I use GUI_Delay(1), things are not working.
Another issue in my case is that if I use single step debugging my code is working but I can't see anything on display of LCD.
I would really appreciate if you could share some feedback or your solution with me. Thanks in advance.
2022-01-10 02:55 AM
2022-01-10 10:14 AM
Thanks @Louis Balázs for the program and inputs.
So you are suggesting me to use Windows Manager? (Sorry to say, I don't understood this fully, maybe I need to check more examples provided with emWin)
I posted a reply here because in your post it looks like any emWin API's used after GUI_Delay functions are not working and same is the scenario with me.
The below is the program which I used, in the program "Hello World Again" is not getting displayed after 1second delay, but I remove the GUI_Delay function I can see both of the text on the screen.
void MainTask(void) {
GUI_Clear();
GUI_SetFont(&GUI_Font32_1);
GUI_DispString("Hello World from STM32F7\r\n");
GUI_Delay(1000);
GUI_DispString("Hello World Again\r\n");
while(1)
{
GUI_Delay(100);
}
}
and this GUI_Delay function is working, I mean to say it is not blocking and is giving 1 second delay.
The example you posted is little complex for me at the moment, but eventually as I proceed further with my learning I will be able to understand all of this.
2022-01-12 10:59 AM