Problem with GUI_DispDecAt()

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

  • Problem with GUI_DispDecAt()

    Hello,

    I have some problem with GUI_DispDecAt() function.
    I use next code:
    GUI_DispDecAt(AddNum, WinRect.x1-16,WinRect.y1-17, 1);

    If AddNum > 0 and AddNum < 11 Emwin draw 0,1,2,3, ... 9,1
    But If AddNum > 10 Emwin not display decimal number, why it happen?
  • Hello,

    GUI_DispDecAt is declared as follow : void GUI_DispDecAt(I32 v, I16P x, I16P y, U8 Len);
    Len is the length displayed on screen.
    In your exemple, Len =1 , so only one digit will be shown.

    If you want AddNum >10 , then Len should be > 2

    so : GUI_DispDecAt(AddNum, WinRect.x1-16,WinRect.y1-17, X);

    where X is the number of digit to be displayed.

    The c implementation with math.h would be with X = floor (log10 (abs (AddNum ))) + 1

    so you could try

    C Source Code

    1. GUI_DispDecAt(AddNum, WinRect.x1-16,WinRect.y1-17, (floor(log10 (abs (AddNum ))) + 1))
    with math.h declared

    edit: Tested on Win32,

    Edit 2 : Tested On STM32F469-NI Disco with correct value displayed with :

    The Can Value being <hex> 12c % , i get 300/10 = 30 % so 2 digits

    C Source Code

    1. GUI_DispDecAt((CanHandle.pRxMsg->Data[0]<<2|CanHandle.pRxMsg->Data[1]>>6)/10,500, 420,floor (log10 (abs ((CanHandle.pRxMsg->Data[0]<<2|CanHandle.pRxMsg->Data[1]>>6)/10 ))) + 1);


    Cheers,

    The post was edited 5 times, last by Schrödinger ().

  • Thank you for interesting answer. But I consider that if i.e. AddNum = 21, I hope that with function GUI_DispDecAt() I could write one digit "2" or "1" on the display.
    This example not draw any symbol on the display:

    C Source Code

    1. GUI_DispDecAt(21, WinRect.x1-16,WinRect.y1-17, 1))
  • Dear Krufter :


    "If AddNum > 0 and AddNum < 11 Emwin draw 0,1,2,3, ... 9,1
    But If AddNum > 10 Emwin not display decimal number, why it happen? "


    If you only want to print "2" or "1" then will have either :
    • for "2" :

      C Source Code

      1. GUI_DispDecAt(2, WinRect.x1-16,WinRect.y1-17, 1))

    • for "1" :

      C Source Code

      1. GUI_DispDecAt(1, WinRect.x1-16,WinRect.y1-17, 1))

    • C Source Code

      1. GUI_DispDecAt(21, WinRect.x1-16,WinRect.y1-17, 2))
      It print 21.



    Gui_DispDecAt() only display the "Len" length of the value.
    User's guide description is "Displays a value in decimal form with a specified number of characters at a specified
    position, in the current window using the current font."

    Your exemple of usage does not respect function's specifications of application :
    It does not filter which digit you wish to display, you have to pre-filter the value beforehand, either mask'it away or math'it away or create a new function to do so.


    Regards,
    Schrödinger