Announcement

Collapse
No announcement yet.

How to understand the calculator demo

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to understand the calculator demo

    Hi,

    Is there a documentation that explains how the communication between the display and the Pi in the calculator example works?

    I can't find how where...

    Thanks !

  • #2
    Posted in the wrong section Baxter

    This is legacy stuff. Moving to Raspberry PI section.
    James

    Comment


    • #3
      ok thanks !

      Comment


      • #4
        What exactly are you wanting to find out?

        The Calculator Demo uses ViSi-Genie, so the communication for ViSi-Genie is outlined in the ViSi-Genie User Guide and ViSi-Genie Reference Manual.
        They are not specific to the Raspberry Pi library, but it outlines the communications protocol.
        Both of these documents can be found on the Workshop4 Product Page, under the Downloads section.

        http://www.4dsystems.com.au/product/4D_Workshop_4_IDE

        Is that what you are wanting to know?

        Regards
        James

        Comment


        • #5
          Hi,

          Sorry, just realized I wasn't very precise. So I look at the main function in calculator.c and then I see something like

          genieWriteObj(GENIE_OBJ_FORM, 0, 0) which selects the form 0 but why?

          Is there a documentation that explains why the code is FORM, 0, 0 ?

          or the handleGenieEvent method, is there any documetn that explains what happening ?

          Thanks!

          Comment


          • #6
            What I am trying to do is I want to run a simple keyboard program. Screen starts, user sees a keyboard, types his name in. That's it. I am trying to do it in C now since the calculator example works.

            So now I am trying to understand what's going on and I can't find a doc that explains how the signals are communicated.

            Thanks !
            Last edited by baxter stockman; 23rd October 2015, 09:06 AM.

            Comment


            • #7
              Hi Baxter,

              The application note

              ViSi-Genie Connecting a 4D Display to the Raspberry Pi
              http://www.4dsystems.com.au/appnote/4D-AN-00023/

              may partially answer your questions. On page 24 for example, it describes the line

              Code:
              genieWriteObj(GENIE_OBJ_COOL_CAUGE, 0x00, gaugeVal);
              This function is used to change the status of an object by writing values to
              it. GENIE_OBJ_COOL_GAUGE is the object’s ID or type, 0x00 is the
              index, and gaugeVal is the value to be written to the object. Note that
              gaugeVal is incremented or decremented by step. Also gaugeVal is
              limited to a value between and including 0 and 99. Remember that the
              cool gauge in the display module has minimum and maximum values of 0
              and 100.
              It is possible to change the status of any object as long as the object ID and
              index are known. The image below lists the object types or IDs already
              defined in the ViSi-Genie-RaspPi library. All of the objects can be written to
              except GENIE_OBJ_KEYBOARD and GENIE_OBJ_STATIC_TEXT.

              The handleGenieEvent function is described on page 27.

              The current Pi library is based on the old Arduino library, but the Arduino library has since been updated and is now different in a number of ways, but some of the core working are still similar. Looking at the basic examples/docs for Arduino may also help.

              ViSi-Genie Connecting a 4D Display to an Arduino Host
              http://www.4dsystems.com.au/appnote/4D-AN-00017/

              You might also want to take a look at the library files "geniePi.h" and "geniePi.c". The ViSi-Genie-RaspPi library is currently being updated. Hopefully more documentation will become available also.

              Hope the above helps and regards.
              Doff

              Comment


              • #8
                This definitely helps a lot, thanks!

                I almost understoof everything. The only thing left is the keyboard.

                So I understand if I press a button it sends a number (through the data variable) to calculatorKey(int key)

                and then we have the different cases (128,129,130...) for M+, M-, etc.

                But how does the program know that 1 = 1 ?

                If I create a calculator and test it I get a data value of 53 when I press 5 for example. ?

                Comment


                • #9
                  Open the calculator demo in Workshop and select the keyboard object.
                  Double click on the 'KeyboardType' property

                  See the key '5', the 'key value' is -1, this means the 'key' is sent wen the key is presssed, ASCII '5' is 0x35 which is decimal 53, your number above.

                  If you want the 5 key to return something else, then just replace the -1 with the desired decimal number (0 to 255).
                  Mark

                  Comment


                  • #10
                    ahh, got itt thank you !!!!

                    Comment


                    • #11
                      Ok, one more question, I didn't understand how the the calculator displays all the input in one line (for example if I type '1', '0', '0', it shows '100'. So I understand that when I use the calculator keyboard, void calculatorKey (int key) is being called.

                      And in this function updateDisplay() is called.

                      So I am assuming this deals with the the StringText Label:
                      sprintf (buf, "%11.9g", display) ;
                      printf ("%s\n", buf) ;
                      }
                      genieWriteStr (0, buf) ; // Text box number 0
                      genieWriteStr writes the text to the StringText Label. But what does "%11.9g" do?



                      Comment


                      • #12
                        Hi Baxter,

                        The line displays the float content of 'display' into the terminal with specified precision.

                        http://www.tutorialspoint.com/c_stan...on_sprintf.htm



                        Regards,
                        Bryan

                        Comment


                        • #13
                          Ok great thanks, then two more questions. I am wondering how the special keys works. For example the shift key, I couldnt find that, is there a documentation on that.

                          I am asking becasue I want to create a something similar to a smartphone keyboard where you click on a symbols button and then you get numbers and symbols. What would you suggest? Should I just use a second form with a customized keyboard and switch between them each time the button is clicked or is there a more elegant way?

                          Thanks !

                          Comment


                          • #14
                            When you press the shift key the keyboard changes to its shifted state (i.e. rather than the 'key' value being displayed the 'shift key' is displayed) after the next key is pressed it reverts to the unshifted keyboard. So I expect you can do what you want with just one keyboard

                            There are a couple of app notes that describe various keyboard options http://www.4dsystems.com.au/appnote/4D-AN-00073/
                            Mark

                            Comment


                            • #15
                              i have a question regarding to calculator .
                              How to make a simple calculator.
                              i am using visi genie environment and 35dct module and gen4-PA.and arduino mega.
                              please Guide me.

                              seggi

                              Comment

                            Working...
                            X