How to update WindowDLG.c text field from main.c (generated from CubeMX)

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • How to update WindowDLG.c text field from main.c (generated from CubeMX)

      Hi,

      I've been working with Arduino and it's simple graphics libraries for many years, and I'm finally moving up to proper hardware (STM32), and proper graphics (emWin!).
      Apologies if my question is dumb and perhaps highlights my lack of C knowledge.

      Working with an STM32F469-Discovery board.

      I have generated a STM32CubeMX project as a starting point and all the MCU stuff is working great, I'm receiving UART data coming in to an array and flashing some LEDs.

      I then generated a dialog using the emWin GUI designer, copied the generated files into my project (WindowDLG.c, GUI.h/c, GUI_App.h/c and all the core files).

      My main.c just has

      GRAPHICS_HW_Init();
      GRAPHICS_Init();
      TouchTimer_Init();
      GRAPHICS_MainTask();

      And I call GUI_Delay(25); from the while(1) loop in main.c

      The emWin graphics are all working, live and I have touch stuff happening.


      My aim at the moment is to simply update a text field based on latest UART data.

      I'm trying to update the text field from the UART interrupt handler function in my main.c with the following. I know it's bad form to do this from an ISR but just trying to get it working:

      Source Code

      1. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
      2. TEXT_SetText(hItem, rxData[1]);
      But obviously it fails to compile because the emWin objects are undeclared in my main.c

      Then I #include WindowDLG.c into my main.c, but then hItem is undeclared. If i declare "WM_HWIN hItem;", I get loads of multiple definition compile errors presumably because I shouldn't have #included WindowDLG.c.

      What is the proper procedure to get this working in my scenario?

      Thanks for any help

      The post was edited 2 times, last by loopyengineeringco: extra detail ().

    • Thanks to @volodymyr's advice in this thread, I was able to piece together a working system.

      I couldn't find a way to force an update of the text widget (any suggestions are still welcome!), but there is a way to create a timer to send a message to the callback function to regularly update the text with a variable - WM_CreateTimer().
      This timer is started in the CreateWindow function, and is continuously restarted when the program reaches the callback function. It pulls the variable from main.c - in my case some serial data. Seems to be working well.
      I wonder if the same thing could be achieved on-demand by using WM_SendMessageNoPara()? Will try soon.