Announcement

Collapse
No announcement yet.

Just for beginning.

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

  • Just for beginning.

    Hello
    I had an arduino program that ran with a numeric keypad.
    I wanted to change the keyboard to a 28DT screen, but I can't do it at all.
    I have read lots of documents on your site, lots of examples on the net, but I can't.
    So to start slowly, I made a screen with just a button and a label.
    I would like when I press the button that it writes a predefined text in the label.
    Can you help me ?

    I tried different program, but nothing.
    For example :
    HTML 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)
    int button0;
    
    // Setup function
    void setup()
    {
    // 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.
    // Some Arduino variants use Serial1 for the TX/RX pins, as Serial0 is for USB.
    Serial.begin(19200); // 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)
    }
    
    // Main loop
    void loop()
    {
    //An optional third parameter specifies the base (format) to use; permitted values are BIN (binary, or base 2), OCT (octal, or base 8), DEC (decimal, or base 10), HEX (hexadecimal, or base 16).
    //For floating point numbers, this parameter specifies the number of decimal places to use.
    
    
    genie.DoEvents();
    
    
    }
    
    
    void myGenieEventHandler(void)
    {
    genieFrame Event;
    genie.DequeueEvent(&Event); // Remove the next queued event from the buffer, and process it below
    
    int button0 = 0;
    
    if (genie.EventIs(&Event, GENIE_REPORT_OBJ, GENIE_OBJ_4DBUTTON, 0))
    {
    bool button0 = genie.GetEventData(&Event); // Receive the event data from the UserLed0
    button0 = !button0; // Toggle the state of the User LED Variable
    genie.WriteObject(GENIE_OBJ_4DBUTTON, 0, button0); // Write UserLed0_val value back to UserLed0
    Serial.print("toto");
    String Str1 = "OK";
    genie.WriteInhLabel(0, Str1); //prints String Class
    delay(5000);
    }
    
    
    
    }
    Thank you.
    Wolfen38
    Junior Member
    Last edited by Wolfen38; 16 December 2021, 11:16 PM.

  • #2
    Hi,

    Have you checked if the baud rates are matched between the display and the host?

    Code:
    Serial.begin(19200); // Serial0 @ 9600 Baud
    Also, I have a sample project which is similar to yours. You can refer to the files attached and feel free to modify them.

    Best Regards
    Attached Files

    Comment


    • #3
      Originally posted by ivan_4d View Post
      Hi,

      Have you checked if the baud rates are matched between the display and the host?

      Code:
      Serial.begin(19200); // Serial0 @ 9600 Baud
      Also, I have a sample project which is similar to yours. You can refer to the files attached and feel free to modify them.

      Best Regards
      Sorry, I was on holiday.

      I tried your example, but I have this on arduino :
      C:\Users\fmeasson\Downloads\Toggle_userLed\Toggle_userLed.ino: In function 'void myGenieEventHandler()':
      C:\Users\fmeasson\Downloads\Toggle_userLed\Toggle_userLed.ino:37:33: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
      genie.WriteStr(0, "LED ON");
      ^
      C:\Users\fmeasson\Downloads\Toggle_userLed\Toggle_userLed.ino:41:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
      genie.WriteStr(0, "LED OFF");
      And more, the screen turn off after some seconds...

      Comment


      • #4
        Hi,

        I have tried to run the project on my Arduino and, I didn't encounter such an error. Can you show the whole error message?

        Best Regards

        Comment


        • #5
          Hi

          This is the whole error message.

          Maybe some librairies are missing....

          Comment


          • #6
            Now, no messages.

            But the sreenn turns off after 2 seconds.

            Maybe I don't connect correctly, I use the shield :
            Click image for larger version

Name:	MVIMG_20220112_091301.jpg
Views:	23
Size:	2.98 MB
ID:	77342

            Comment


            • #7
              Hi,

              You can refer to the datasheet of the Arduino Shield for the proper connections: 4D Arduino Adaptor Shield

              Also, you can try to change the resetting of the display in your Arduino code like the snippet below.

              Code:
              pinMode(RESETLINE, OUTPUT);
              digitalWrite(RESETLINE, 1);
              delay(100);
              digitalWrite(RESETLINE, 0);
              delay (5000);
              Best Regards

              Comment


              • #8
                Thanks, it works.

                Comment


                • #9
                  Hi,

                  You're welcome.

                  If you have another inquiries, don't hesitate to ask.

                  You can also raise a ticket in our helpdesk for more inquiries.

                  Best Regards

                  Comment


                  • #10
                    Hi,

                    I have a new question.

                    I use IBUTTONE. I press button to choose buyer, and after I press an other button to go to the next form. When I come back to the first form, the IBUTTONE is always at 'ON', I would like it retunrs to OFF when I go to the second form.

                    Is it possible ?

                    An another question.
                    For my IBUTTONE, I use events 'report message' to keep the value, because if I use 'foractivate' to change form, it dosen't save the value.
                    Is it possivble to do both in same time ? Save the value and change form ?

                    Thanks a lot.

                    Comment

                    Working...
                    X