cancel
Showing results for 
Search instead for 
Did you mean: 

Why does not the LCD update in STM32H747I-DISCO board?

Louie88
Associate III

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 colorChangeRequest variable is set to -1 in the GPIO interrupt handler
  • The ledStateCounter contains the ID of the turned on LED: 1 to 4 or 0 if all the LEDs are turned off.
  • The ledColor variable is set to the color of the turned on LED.
  •  Finally, the little update code runs (once) and it should print the actual message with the right color.
  • I Added GUI_Excec() after GUI_DispStringAt() function. It did not help.

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

5 REPLIES 5
Louie88
Associate III

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:

  1. If I comment out the GUI_Delay() function then the text is printed with “rainbow�? colors as I expected. Parts of the text are white, red, blue or green. But the LCD is updated.
  2. If I set the WAIT_TIME less than 30ms then the LCD still works, I get the “rainbowed�? text.
  3. If the WAIT_TIME is greater than 30ms then the first (white) text is shown. Rest of the colors are still set, the text is printed again, but no change can be found on the LCD screen. The text is always white.
  4. The LCD itself is good. Any other (complicated and impressive) examples run fine. So, this is not a hardware error.

What is wrong with this code above?

(I hope somebody reads this forum from ST…)

Thanks for your help.

Louis

xpress_embedo
Associate III

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.

Hi xpress_embedo!

I had some progress with it but finally we dropped the project.
The thing is you must go back Windows3.1 C++ message handling. You have to use callback functions.

1. In the main.c initialize the LCD
WM_MULTIBUF_Enable(1);
GUI_Init();
2. Then get the destop window handle:
// Get Handle of desktop window
WM_HWIN hDesktopWindow = WM_GetDesktopWindow();
3. Then set a callback for DesktopWindow:
// Set callback function in order to handle, printing or button touches
WM_SetCallback(hDesktopWindow, DesktopWindowCallback);
4. Not you need a function:
Prtotype:
static void DesktopWindowCallback(WM_MESSAGE * pMsg);

/**
* @brief Handles callback messages of the main window (HDesktopWindow)
* @retval None
*/
static void DesktopWindowCallback(WM_MESSAGE * pMsg)
{
int NCode;
int itemId;
switch (pMsg->MsgId)
{
case WM_PAINT:
// Paint text from here intsetad of calling WM_DefaultProc(pMsg)
// WM_DefaultProc(pMsg);
GUI_DispStringAt(“Hello World�?, xCoord, yCoord);
break;
case WM_NOTIFY_PARENT:
// Get ID of item which sent the message
itemId = WM_GetId(pMsg->hWinSrc);
// Get message code
NCode = pMsg->Data.v;
switch(NCode)
{
case WM_NOTIFICATION_RELEASED:
// This happens when you RELEASED an active lement on the screen
// Like buttons, checkboxes, etc. The GUI_ID it the ID of the element when you
// Created the element
switch (itemId)
{
case GUI_ID_STARTENCODER_BUTTON:
// Clear encoder
ClearEncoder();
DisplayEncoderPulses(12, 96);
break;
case GUI_ID_VOL13_BUTTON:
UpdateVolumeSwitches(volume13);
break;
case GUI_ID_VOL12_BUTTON:
UpdateVolumeSwitches(volume12);
break;
case GUI_ID_VOL23_BUTTON:
UpdateVolumeSwitches(volume23);
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
5. Update screen
If you want that your “Hello world�? text be displayed immediately the call UpdateScreen(hDesktopWindow)
/**
* @brief Immediately updates (redraws, paints) then window. Delays 1ms.
* @param WM_HWIN: pointer to windows handle
* @retval null
*/
void UpdateScreen(WM_HWIN hWindow)
{
UpdateScreenEx(hWindow, 1);
}

/**
* @brief Immediately updates (redraws, paints) then window
* @param WM_HWIN: pointer to windows handle
* @param Time to wait in milliseconds
* @retval null
*/
void UpdateScreenEx(WM_HWIN hWindow, int delayMs)
{
// Invalidate window
WM_Invalidate(hWindow);
// Let to do it.
GUI_Delay(delayMs);
}

I hope I could help and I started you on the right path.
Best regards,
Louis

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.

Hi,

Yes, you must use WM (Windows Manger). Among the Segger samples there are a lot – more or less - examples how to use WM. Basically you need to create the main window callback function, and in the callback function check whether the message is WM_PAINT. If it is WM_PAINT then you can print any text you want.

I am sorry, but I am too busy with other projects and as I told you we dropped the STM32 emWIN application a year ago. We do not need touchscreen just a simple 4x20 LCD. The STM32xxx is a very nice processor. Good pick!

Good luck!
Best regards,
Louis