Announcement

Collapse
No announcement yet.

Trouble with WinButton

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

  • Trouble with WinButton

    I'm using the uLCD-32PTU screen and an arduino uno with the adapter shield rev.2.

    What I want to do is have the winbutton control what is in the strings0 text box. (i.e. if the winbutton is pressed > display "this text") This is the first step that I want to get going. Once I can have that portion working I am going to need to have it set so that once "this text" is displayed that if the winbutton is pressed again it displays a "new text". I'll leave it at that for now, but there is plenty more that I am most likely going to need assistance with for this project.

    I really do appreciate any and all assistance I receive with this.

    Code:
    #include <genieArduino.h>
    
    Genie genie;
    #define RESETLINE 4  // Change this if you are not using an Arduino Adaptor Shield Version 2 (see code below)
    
    // Setup function
    void setup(){
      // NOTE, the genieBegin function (e.g. genieBegin(GENIE_SERIAL_0, 115200)) no longer exists.  
      // Use a Serial Begin and serial port of your choice in your code and use the genie.Begin function to send 
      // it to the Genie library (see this example below)
      // max of 200K Baud is good for most Arduinos. Galileo should use 115200 or below.  
      Serial.begin(115200);  // Serial0 @ 9600 Baud
      genie.Begin(Serial);   // Use Serial0 for talking to the Genie Library, and to the 4D Systems display
    
    genie.AttachEventHandler(myGenieEventHandler);
    
      // Reset the Display (change D4 to D2 if you have original 4D Arduino Adaptor)
      // THIS IS IMPORTANT AND CAN PREVENT OUT OF SYNC ISSUES, SLOW SPEED RESPONSE ETC
      // If NOT using a 4D Arduino Adaptor, digitalWrites must be reversed as Display Reset is Active Low, and
      // the 4D Arduino Adaptors invert this signal so must be Active High.  
      pinMode(RESETLINE, OUTPUT);  // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
      digitalWrite(RESETLINE, 1);  // Reset the Display via D4
      delay(100);
      digitalWrite(RESETLINE, 0);  // unReset the Display via D4
    
      delay (3500); //let the display start up after the reset (This is important) 
    }
    
    
    void loop()
    {
    genie.DoEvents();
    }
    
    void myGenieEventHandler()
    {
      char myArray3[] ={"Power Locks?""\n""Press Pass/Fail"};
      genieFrame Event;
      genie.DequeueEvent(&Event);
    
      if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
        {
          if (Event.reportObject.object == GENIE_OBJ_WINBUTTON)
           {
            if (Event.reportObject.index == 0)
             {
            genie.WriteStr(0, myArray3);
             }
           }
        }
    ///////////////////////////////////////////////////////////////////////////////////////////
    
    }

  • #2
    Hello Piesauce,

    I've tested your code and it works out fine. Maybe its that the baud rate on the display is incorrect, adapter shield jumper connections or some other connection problems.
    You could try implementing a counting routine to your winbutton event report to toggle multiple messages to write on the string, sample code below.
    Code:
    int counter;
    void myGenieEventHandler()
    {
      char myArray1[] ={"First Message"}; // First message
      char myArray2[] ={"Second Message"}; // Second message
      ....................
      genieFrame Event;
      genie.DequeueEvent(&Event);
    
      if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
        {
          if (Event.reportObject.object == GENIE_OBJ_WINBUTTON)
           {
            if (Event.reportObject.index == 0)
             {         
              if(counter == 0){genie.WriteStr(0, myArray1);}
              if(counter == 1){genie.WriteStr(0, myArray2);}
              ................
              counter++;
             }
           }
        }
    }
    Best regards

    Comment


    • #3
      Hey Jerson,

      Thanks for the response.

      I managed to get it to work ONCE and since then it does not want to work again..

      I've quadruple checked my baud rates and my Rx/Tx jumpers and still nothing.

      I just redid everything from scratch.
      - Loaded the example WinButtonSS visi-genie program provided by 4D to the uSD card and Display using the programming cable
      - Opened the Arduino sketch provided with that WinButtonSS program from 4D and uploaded it to the arduino-uno board
      - Checked to make sure that both devices are set to communicate using 9600 baud rate
      - Jumpered the correct pins (10[Rx], 11[Tx]) to the adaptor shield.
      - Ran the devices hooked up.

      Pressing the WinButtons does not show anything in the serial monitor.
      Using the "read 0, read 1, read 2, or read 3" commands in the serial monitor returns errors like "ead 0 is not a valid command. Please try again." The same thing goes for the write commands in teh serial monitor.

      Please help.. I'm using the example program and following it to the T with no luck anymore.

      Comment


      • #4
        I've discovered something new.

        The serial monitor will send commands and the board receives them sometimes. I need to send the same command or different command, it doesn't matter, several times in order for the board to receive it. Not sure why or what is causing this to be so sporadic..

        The display is still not receiving the commands sent or requested through the serial monitor and vice versa (winbutton presses on display not reporting anything to serial monitor).

        Comment


        • #5
          Hello,

          Can you try connecting your display to Workshop 4 without your Arduino attached and your project loaded, thne click on Tools, and then GTX. A new window will appear showing the widgets you have on the Display. This will prove that your display is receiving commands ok. Also if you have any Serial.print or Serial.println commands in your Arduino code, please comment thes out as they will cause sync issues within Genie.

          Best regards

          Paul

          Comment


          • piesauce
            piesauce commented
            Editing a comment
            I actually tried that when I got into work today and it was communicating between GTX and the display so I knew the display was working. Thanks for the response!

        • #6
          I figured it out!

          SoftwareSerial serial(2,3);

          Serial.Begin(9600);
          serial.begin(9600);

          genie.Begin(Serial); //This is how it was written in the example code.
          genie.Being(serial); //This is how it needed to be written....


          I must have changed it and saved the code without realizing it..

          Comment

          Working...
          X