Announcement

Collapse
No announcement yet.

Seeking info on genieArduino Library

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

  • Seeking info on genieArduino Library

    Greetings,

    I have been watching as a new library rolls out with demos such as the calculator and "mood" program. As someone who wouldn't know an unsigned integer from a desert rat, I am in confusion and panic. Is there a guide/manual/instructions for what is new, what has changed, and what is happening?

    Two examples - the RGB LED demo and the "mood" demo both have RGB sliders but the first uses switch/cases routines to read the sliders and I do not understand, at all, how the "mood" program achieves this. The coding in Arduino is totally different, with no way of knowing if or why the mood routine is better than the RGB LED demo.

    So . . . anyone jump in here - which way of capturing PWM control is best - the RGB LED demo or the Mood demo - and why?

    More infuriating is the calculator demo [don't get me wrong - it IS uber cool!]. I thought I could decode some of it to see how the memory + and - buttons could teach me how to enter numbers from the 4D and store them for timing functions on the Arduino. Instead, the calculator seems to use several libraries "include xxx.h" that are not described or detailed. In other words, the calculator demo is great if I want to learn how to make calculators and use math functions in the arduino, but I do not see now I can learn much from it that can be applied to other, generic, projects.

    My angst comes from having demo programs that do not fully explain themselves for the rote beginner (who else needs help, anyway. As follows (from the calculator Arduino code) . . .

    #include // MODIFIED new genieArduino library [modified in what way? What is new? What is different? Does it fully replace arduino.h for the Visi-Genie system? #include // What is this? Why is it here? What does it do?#include ditto#include ditto

    Why and when would I use/include these .h files and how would I know?


    I am mostly learning by elimination . . . removing a section of code to see how it affects the overall program, if it still compiles, how and if it runs, etc.

    I assume that the information I seek is available but not yet clearly posted. If I simply need to wait for the documentor to do their work, so be it.

    Thanks to all - Baran
    /Baran G Galocy/

  • #2


    I'm not completely familiar with this but maybe I can fill in a bit of the 'release' information.

    Some of the very early samples did not use a library at all, everything was coded 'inline', there was no support for events.

    The first library release supported events but some commands were missing (string commands, I think). Under certain circumstances the commands could end up being sent 'ahead' of when they should have been, flooding the display.

    The second library release added the missing commands and supposedly fixed the command flooding. But further testing revealed there was still the possibility for flooding under certain circumstances.

    Thus the third library release was made, and I believe this is current and has no known issues.

    Unfortunately the fixes required some fundamental changes to the way things worked, and I'm not sure if the changes have been implemented in all the demos.

    Hopefully someone will be able to detail things in this area a bit better.
    Mark

    Comment


    • #3


      The RGB LED demo is an older demo using SerialSoftware to interface with a 4D display. Unfortunately, the SoftwareSerial library suffers from serious drawbacks when it comes to transmitting data. Please ignore this demo as it is outdated.

      The latest library and demos are available on github: https://github.com/4dsystems?tab=repositories

      The core Arduino library uses the HardwareSerial library which is very reliable and robust. As such, 4D Systems wrote the latest VisiGenie library for Arduino to make use of the HardwareSerial library.

      A number of helpful App Notes have been posted on 4D System's website: http://www.4dsystems.com.au/appnotes/

      I suggest you read 4D-APN-4017 and 4D-APN-4018 as they specifically refer to the new VisiGenie library.

      The correct demos for this new library are Calculator and Mood. The new library uses three fundamental calls:
      1. genieBegin() which sets the (hardware) serial port on which the 4D display is connected along with the connection baudrate.

      2. genieAttachEventHandler() which sets the (user defined) function that handles "events" and "reports" from the 4D display

      3. genieDoEvents() which is called in a continual manner (in the Loop() function) to process events from the 4D display

      As sliders change or buttons are pushed on the display, the user-defined event handler is called to process those events. In mood this funtion is handleGenieEvent() and it parses the event type to decide what actions to take. The event handler is also called when the display respond with date from a genieReadObject() command.

      Similarly, in the calculator demo, the handleGenieEvent() code passes the key which was pressed to the calculatorKey() function which handles key values using an SWITCH statement, including the memory keys. The variable "memory" is updated based on the memory key pushed.

      The use of a "SWITCH" versus a set of "IF" statements is left to the discretion of the programmer. In the mood demo, a number of cascading "if, else" statements were used for clarity and simplicity.

      The "// MODIFIED" is there since there exists an older mood demo so this indicates the include file has been modified. As for the other included libraries you may find in demos you encounter, I strongly suggest you google their name as these are standard "C" and "C++" include files.

      Please let me know if this is helpful.

      Paul

      Comment


      • #4


        Greetings Moderator & Paul,

        Thank you both for the information and yes, Paul - very helpful. I will still have to digest it in little bits but you have given me hours of illumination.

        One interesting phenomenon is that the old RGB LED demo works just fine when I leave off the SerialSoftware command and simply use pins 0 & 1. I do have the arduino.h library included.

        Can you explain to someone with limited experience but a lot of enthusiasm (that'd be me how the handleGenieEvent() might be used to simply capture key presses and store them as a whole number in a buffer (on the Arduino) once an "enter" key is pressed, while mirroring back the key presses as the calculator demo does? Or is that an entirely wrong track on which to proceed?

        I am hoping to store several sets hour and minute data that will be used with the time t. function for triggering external events.

        Oh, yeah - thanks to everyone who has bitten their lips and NOT called me a neo-whiner. I am overwhelmed by the learning curve and, like everything else, this is just a matter of assimilation.

        Baran
        /Baran G Galocy/

        Comment


        • #5


          Baran,

          Pins 0 & 1 are the hardware UART interface so by using them, you are using the HardwareSerial by default!

          In the calculator demo, you will see in handleGenieEvent() that when a keyboard key is pressed, it creates an "report Object" (this was configured in 4D Workshop for each key). This report is trapped in the lines:

          if (reply.reportObject.object == GENIE_OBJ_KEYBOARD) // If this event is from a Keyboard { if (reply.reportObject.index == 0)// If from Keyboard0 { keyboardValue = genieGetEventData(&reply); // Get data from Keyboard0 calculatorKey (keyboardValue); // pass data to the calculatorKey function for processing }
          The reported "keyboardValue" is passed to the calculatorKey() function where the real action takes place.

          If you look at the top of calculatorKey() the code following "if (isdigit (key))" processes a new number by adding each new key pressed in incrementing powers of 10 as each new keypress shifts digits to the left. The display is updated using updateDisplay() to reflect the shifted digits. This continues until an operator key is pressed, thus using the accumulated number as the operand.

          You could use the same logic for your application.

          Cheers!

          Paul

          Comment

          Working...
          X