Announcement

Collapse
No announcement yet.

gen4-uLCD-32DCT-CLB writing data to Arduino variables

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

  • pauleilio
    replied
    Hi,

    Would it be possible to send me your complete code. You can send it to paul at 4dsystems dot com dot au if your prefer

    Best regards

    Paul

    Leave a comment:


  • MamoJaLatam
    replied
    Hi,

    The code above does not change anything, but I've made some progress on my own:

    First, I copied a working example keyboard project into mine, while loading just the example file code into arduino -> keyboard works perfectly.
    Then, I started removing some arduino code that was irrelevant for my application -> still fine
    Then, I started adding parts of my own code piece by piece untill fail and the moment I add:

    Code:
    delay(100);
    into my loop function, the reading stops and my debug LED stops showing myEventHandler() being called. I have a few WriteStr() functions that show arduino variables on screen, wanted to have a slight delay, so that the values don't get refreshed too quickly.

    I'll keep investigating. By the way, my keyboard works with the OnChange Event being empty. The funny thing is, the moment I add Report Message Event, it stops working. :D

    Leave a comment:


  • pauleilio
    replied
    Hi,

    Welcome to the forum

    The 48 being printed is actually a sign that it is working. 48 is the ascii value of '0' and I would expect pressing 1 would result in 49 also. The value that you are sending is being printed in the string as a number and not as a string.

    Could you try this code instead.

    keyboardValue = genie.GetEventData(&Event); // Get data from Keyboard0
    String tempchar = "";
    tempchar += (char)keyboardValue;
    genie.WriteStr(9, tempchar);

    It's probably not the most elegant way of doing it but it is taking the value and then turning it a string. I haven't been able to test it. The OnChanged event needs to be set to Report Message.

    Best regards

    Paul

    Leave a comment:


  • MamoJaLatam
    started a topic gen4-uLCD-32DCT-CLB writing data to Arduino variables

    gen4-uLCD-32DCT-CLB writing data to Arduino variables

    Hello,

    I'm trying to create a project involving arduino communication. I've managed to acomplish a few things, but there are still some issues I need help with.

    What I have is a Form with 0-9 + enter keyboard(Object - keyboard0) and string(Object - strings9). What I'd like to achieve is to be able to input a number from keyboard object to string object and write it to arduino with "enter" key. I have seen a few tutorials, example files etc. but can't get it to work. I definetely have the communication/wiring setup correctly, since I am already reading a few variables from arduino and it works like a charm.

    As far as I understand, I need to update my code to invole the following:

    In arduino setup function:
    Code:
     
    Serial.begin(9600);
    genie.Begin(Serial);
    
    genie.AttachEventHandler(myGenieEventHandler);
    
    pinMode(RESETLINE, OUTPUT);
    pinMode(8, OUTPUT);
    digitalWrite(RESETLINE, 0); // Reset
    delay(100);
    digitalWrite(RESETLINE, 1); // unReset
    
    delay (5000);
    In arduino loop function:
    Code:
    genie.DoEvents();
    And the Eventhandler:
    Code:
    void myGenieEventHandler (void)
    {
    int keyboardValue;
    digitalWrite(8, HIGH);
    
    genieFrame Event;
    genie.DequeueEvent(&Event); // Remove this event from the queue
    
    if (Event.reportObject.object == GENIE_OBJ_KEYBOARD) // If this event is from a Keyboard
    {
    if (Event.reportObject.index == 0) // If from Keyboard0
    {
    keyboardValue = genie.GetEventData(&Event); // Get data from Keyboard0
    genie.WriteStr(9, keyboardValue);
    }
    }
    }
    The code tries just to get any data to show on string9 object after pressing keyboard, I'm aware it is not doing exactly what I've described at the beginning.

    I added a simple diode to output 8 to be able to monitor if the handler function is ever called, it is not no matter how hard I mash the keyboard. Now I've seen every tutorial mentions adding the keyboard to "Events" within Workshop software, so right now I have my keyboard0 event set to "OnChanged: Report Message". But every single example file I downloaded doesn't have it set up, so I'm kind of confused. I did manage to get the read ONCE, no idea how, but pressing 0 resulted in 48 written to string9. But after that, no success.
Working...
X