Decimal separators in Emwin

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

    • Hi,

      Yes, this is possible. Call this before displaying floating values:

      C Source Code

      1. GUI_SetDecChar(',');

      Unfortunately, this is documented. We will add this to the emWin user manual.

      Regards,
      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • Thank you. I will try this API.

      Every time before displaying the value I need to call this API. If I have some 20 widgets showing floating point value, This API must be called each and every time. Is that correct?
    • Hi,

      Of course not, I just wanted to say that you have to call it before the first time you display a floating value.

      Just once after GUI_Init() and the new separator will be used every time you display a float value.

      Regards,
      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • GUI_SetDecChar(',') will work only if I use api like GUI_DispFloat(). Is that correct?


      I am displaying values using API GUI_DispStringInRect(), Since I need to show the value at particular position on custom button.
      Please check the Code is shared below:

      void YButnCallBack(WM_MESSAGE *pMsg)
      {
      GUI_RECT rect0 = { 10,10,255,70 };
      GUI_RECT rect1 = { 256,10,330,70 };
      GUI_RECT rect2 = { 331,10, 380,70 };

      char strY[5];
      snprintf(strY, sizeof(strY), "%.1f", Ysize); // (YSize is float variable that will keep changing)
      switch (pMsg->MsgId)
      {
      case WM_PAINT:
      if (BUTTON_IsPressed(pMsg->hWin))
      {
      GUI_SetBkColor(AZURE_BLUE);
      GUI_Clear();
      GUI_SetFont(FONT_16);
      GUI_SetColor(GUI_BLACK);
      GUI_DispStringInRect("Y:", &rect0, GUI_TA_LEFT | GUI_TA_BOTTOM);
      }
      else
      {
      GUI_SetBkColor(GUI_BLACK);
      GUI_Clear();
      GUI_SetFont(FONT_16);
      GUI_SetColor(AZURE_BLUE);
      GUI_DispStringInRect("Y:", &rect0, GUI_TA_LEFT | GUI_TA_BOTTOM);
      GUI_SetColor(LIGHT_GREY);
      }
      GUI_DispStringInRect("cm", &rect2, GUI_TA_RIGHT | GUI_TA_BOTTOM);

      GUI_SetFont(FONT_25);
      GUI_DispStringInRect(strY, &rect1, GUI_TA_RIGHT | GUI_TA_BOTTOM);
      break;
      default:
      BUTTON_Callback(pMsg);
      break;
      }
      }
    • Hello,

      In my personal opinion, you do not need to call the GUI_SetDecChar, you have already keep the YSize in the string, so why not to write a function to change "." to ",". this is much faster to solve your problem.
    • Hi,

      if you call GUI_DispStringInRect() it simply displays the string you pass to the function. This is independent of emWin and it is up to you what is inside the the string.

      Regards,
      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.