GUI-O Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    How to display a float number via bluetooth

    Scheduled Pinned Locked Moved
    General Discussion
    3
    8
    483
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      Fehr
      last edited by

      Good evening
      I have only recently started using GUI-O and have not yet been able to understand how I can display a simple float variable on the display if a bluetooth connection is used. Is there perhaps a good example in this forum that explains my problem?
      Thank you very much for your support.
      Regards Fehr

      K 1 Reply Last reply Reply Quote 0
      • K
        kl3m3n @Fehr
        last edited by kl3m3n

        @Fehr
        Hi!

        Glad to have you on-board the GUI-O enthusiasts! 🙂

        You can use a label widget for displaying any kind of text/numeric values.

        After connecting over Bluetooth, you can create a label by sending a string:

        "|LB UID:my_label X:50 Y:50 TXT:\"<your float as string>\"\r\n"
        

        The \ before the double quotes is an escape sequence, so that double quotes are properly interpreted within the command.

        You can build this command by using "snprintf" on a char buffer (this is a c/c++ language standard library function).

        You can check out the examples here:
        https://www.gui-o.com/examples

        Also, the manual describes the label (and other widgets) in more detail. You can download tge manual cia the GUI-O app or from GUI-O website.

        If you need any additional information or help, feel free to ask.

        Best regards,
        Kl3m3n

        F 1 Reply Last reply Reply Quote 0
        • B
          Bernard
          last edited by

          Good morning,
          In the initialization script, simply define a Label:
          |LB UID:your_label X:95 Y:96 W:20 FGC:#fb0001 FSZ:5 FFA:'font8' TXT:'0000'".
          and write from your program In this Label "your_label " in the form of a string.
          I don't know in C but with Bascom:
          Dim Float as single //float variable
          Float=3,414 // Float value
          Dim Value as string *10 // declare Value as string
          Value=Str(Float) // convert in string
          Print "@your_label TXT:" ; Value ; " // print in your_label
          and there you have it!
          It works via Bluetooth or Wifi, it doesn't matter.
          Bernard

          1 Reply Last reply Reply Quote 0
          • F
            Fehr @kl3m3n
            last edited by

            @kl3m3n said in How to display a float number via bluetooth:

            Hi kl3m3n, thank you very much for the quick reply.

            Unfortunately, my char array variable is still not output correctly in the following example. I am currently using an ESP32 as test hardware.

            571ba2f2-dd9e-404f-8a7f-6d6c0682d926-image.png

            I can now generate a correct string with the snprintf function. This is confirmed by the following console output.

            ba9c6102-f598-41ce-a1f4-58f4f075eec9-image.png

            In the GUI display, however, the variable name is still displayed instead of the content of the char array. This is actually my general question, how do I have to pass the content of a string variable (char array) correctly so that I get the same output in the GUI as on the console?

            f3488234-5e8d-4cb9-95f1-95362e141b02-image.png

            Thank you very much for your support.
            Regards Fehr

            F 1 Reply Last reply Reply Quote 0
            • F
              Fehr @Fehr
              last edited by

              @Fehr

              with an update function that retrieves the entire string that needs to be sent, I finally managed to transfer the desired number to the GUI display.

              f0570429-717f-4554-a5d9-d8f0a8ede516-image.png

              The following string is displayed on the Arduino console:

              bb3d0bbc-b64c-4bc2-a93b-6b81142ead68-image.png

              And the desired numbers values are now finally visible in the GUI:

              9b5e94ed-a49b-428c-9ee1-da5759de2777-image.png

              Basically, it works. However, my question now is is there no easier way to achieve the same result? Thank you very much for your feedback and regards.
              Fehr

              K 1 Reply Last reply Reply Quote 0
              • K
                kl3m3n @Fehr
                last edited by kl3m3n

                @Fehr Hi.

                The easier way is to fist create a label (like @Bernard suggested):

                "|LB UID:my_label X:50 Y:50"
                

                Then just modify its TXT property:

                @my_label TXT:\"<value>\"\r\n
                

                If you don't want to use snprintf, you can just use + operator:

                String str = "@my_label TXT:" + "\"" + String(val) + + "\"" + "\n\r";
                

                You can simply create a function to avoid repeating this command with different TXT values.

                P. S. Similar topic:
                https://forum.gui-o.com/post/116

                Best regards,
                Kl3m3n

                F 1 Reply Last reply Reply Quote 0
                • F
                  Fehr @kl3m3n
                  last edited by

                  @kl3m3n
                  Thank you very much for your support.
                  To use a string instead of a char array is even easier 🙂

                  K 1 Reply Last reply Reply Quote 0
                  • K
                    kl3m3n @Fehr
                    last edited by

                    @Fehr No problem!

                    I plan to write a FAQ page on GUI-O website, which will also include this explanation.

                    Best regards,
                    Kl3m3n

                    1 Reply Last reply Reply Quote 0
                    • K kl3m3n referenced this topic on
                    • First post
                      Last post