EDIT widget enter float value

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

  • EDIT widget enter float value

    Hi,

    I want to introduce the EDIT widget to enter float values.
    I want to use it in two different ways.

    1. Altering the value with the aid of a rotary encoder.
    -> Therefore I use the EDIT widget in Float Mode. ->works like expected

    2. Altering the value with the aid of a keyboard.
    -> If the user presses any numerical button on the keyboard the input method of the widget should change and behave like an ordinary character input widget until the user presses the enter button.
    Therefore I think the GUI_EditFloat() function may be suitable, but I haven't found any example using this function.

    Is the function GUI_EditFloat() able to provide the functionality which I want to achieve in 2. ?

    If yes, can you provide an example how to use this function?
    If no, can you give me an advise how to implement the desired functionality?


    Thank you


    regards
    Thomas
  • Hi Adrian,

    sorry that I did not explain my problem carefully.

    I am planning an user interface for our new product.
    It is a kind of an electronic measurement device.
    One requirement is the ability to enter float values (e.g. sample rate in seconds or a nominal voltage setting).

    The mechanical part of the user interface consists of hardware buttons (0-9, '.', Enter_key, Esc_key) and a rotary encoder (which should simulate the behaviour of an analog potentiometer; e.g. the Voltage setting of a power supply). I want to offer the user two possible ways to enter/alter the float value for the EDIT widget.

    1. Altering the currently displayed float value with the aid of the rotary encoder. (behavior of an analog potentiometer)
    -> According to the rotation direction of the rotary encoder I send the messages GUI_USER_KEY_UP and GUI_USER_KEY_DOWN to the focussed EDIT widget which is configured in float mode. I was already able to implement this way.

    2. Enter a float value with the keyboard. (set a defined float value; e.g. 3.855 V by pressing the corresponding hardware keys '3''.''8''5''5'<ENTER_KEY>)
    ->In this case of user input the EDIT widget should behave like a text input field. Originally I planned to reconfigure the EDIT widgt into text mode after a button press but then I saw the function GUI_EditFloat() which, I guess, provides the desired behavior. But I am not 100 % sure since I can found no example using this function.


    Can you please explain the usage of the function GUI_EditFloat() or provide an example how to use it?

    Hope you understand what I want to do.



    regards
    Thomas
  • Hello Thomas,

    Unfortunately, the function GUI_EditFloat() can not change the value of the EDIT widget.
    It can be used to enter a new floating point number and get the entered value.


    To implement the desired functionality I would suggest you to create your own callback function and react to the WM_KEY event.
    Details on how to create a custom callback function can be found in the emWin user manual in section 18.2 "The Window Manager (WM)" -> "Callback mechanism, invalidation, rendering and keyboard input".

    Best regards,
    Thorsten
  • Hi Thorsten,

    the behavior that you describe is exactly what I need.
    As soon as the user presses a numerical key he wants to enter a new floating point number.

    All I need is an example on how to use the function GUI_EditFloat()....
    Or at least a more detailed description of its usage.


    regards
    Thomas
  • Hello Thomas,

    Please understand that we would require a valid support contract in order to be able to create a sample for you. In any case we are going to improve the description of the function in the emWin user manual.

    If you have any questions regarding the possibilities of a support contract, please contact info@segger.com.

    Best regards,
    Adrian
  • Hello Thomas,

    Yes, I can tell you which information we are going to add to the description of the function GUI_EditFloat().

    This function creates an invisible EDIT widget and starts waiting for user keyboard input. As numeric keys are pressed the EDIT widget is updated. Still it is invisible, so the user will not recognize a change. Once the 'ESC' or 'ENTER' key is pressed, the current value is read from the invisible EDIT widget, before the widget is deleted. The function returns the value of type float.

    Best regards,
    Adrian