Announcement

Collapse
No announcement yet.

Need Help for keyboard input

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

  • Vince_4D
    replied
    No worries Huy,

    You can also do like this:
    setting_val = keyvalue[counter] - '0';
    Also, it's still good if you remove the type cast in keyvalue[counter].

    Best regards,

    Leave a comment:


  • huy373
    replied
    Hi Vince,
    My problem is solved. Thank you so much.

    Leave a comment:


  • Vince_4D
    replied
    Hi Huy,

    To convert number character to an integer, you will just have to subtract char '0' to get the equivalent integer of a certain char digit.
    Say for example,
    num = '1';
    num = num - '0'; // getting the integer of char '1'

    Explanation: In ASCII, '1' is equal to 49 dec and '0' is equal to 48 dec

    Hope this helps.

    Best regards,

    Leave a comment:


  • huy373
    replied
    Hi,
    I have a problem with converting char to int. My input from keyboard is char type, but i need to compare with the temperature which is int type. How can I do that? Here is my arduino project.
    Thank you.
    Huy
    Attached Files

    Leave a comment:


  • Vince_4D
    replied
    Hi, welcome to the forum.

    The following application notes will guide you on how to implement the keyboard.

    In Visi:
    https://www.4dsystems.com.au/downloa...0073_R_1_0.pdf
    In ViSi-Genie:
    https://www.4dsystems.com.au/downloa...188_R_1_01.pdf

    When I compile the arduino code, the uLCD 43DT reset automatically.
    May I know what response you are expecting when compiling the Arduino?
    Note that the program must contain reset routine in order for the display to load the needed files and run properly.
    The routine has the following code located in the setup of Arduino.
    Code:
     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)
    Best regards,


    Leave a comment:


  • huy373
    replied
    Hello,
    Can anyone give me the sample code of the keyboard input please? I need to enter the number to the string from the cellphone key. When I compile the arduino code, the uLCD 43DT reset automatically.
    Help me please. Thank you.

    Leave a comment:


  • bernadette
    replied
    Hello Paulkid,

    It's nice that you've figure it out.
    If you have more questions and examples
    you can always reach our forum.

    Best regards,
    Bern

    Leave a comment:


  • paulkid
    replied
    Thank you ADVANCETOM.
    even after all this time yours is the only example of using the keyboard object for Arduino I could find.

    Leave a comment:


  • ADVANCETOM
    replied
    Here is the Video link:
    ENJOY .)


    http://1drv.ms/1j6GSP8

    Leave a comment:


  • ADVANCETOM
    replied
    AHHHHHHHHHHHHHHH

    i found a solution and it works

    i set

    double n;

    in main loop:

    float seaLevelPressure = n;


    But this was the solution


    n = atof (keyvalue); //printout 1022.00 great

    Thats my GenieEventHandler routine for anybody who wants it to use




    void myGenieEventHandler(void)
    {

    genieFrame Event;
    genie.DequeueEvent(&Event);

    //If the cmd received is from a Reported Event (Events triggered from the Events tab of Workshop4 objects)
    if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
    {
    if(Event.reportObject.object == GENIE_OBJ_KEYBOARD)
    {
    if (Event.reportObject.index == 0) // If keyboard0
    {
    temp = genie.GetEventData(&Event);
    if(temp >= 48 && temp <= 110 && counter <=9) // Recognize only number 1-9 change this to 48-122 if using a QWERTY Keyboard
    {
    keyvalue[counter] = temp; // Receive the event data from the keyboard
    genie.WriteStr(3,keyvalue); //prints to String Object
    counter = counter + 1; //increment array
    }
    else if(temp == 8) //check if backspace
    {
    counter--;
    keyvalue[counter] = 0;
    genie.WriteStr(3,keyvalue);
    }
    else if(temp == 13)
    {
    for(int x =0; x<counter ; x++)
    {
    Serial.println(keyvalue[x]); //so you can see the captured string


    }
    Serial.println("DONE");

    n = atof (keyvalue);
    Serial.println(n);

    genie.WriteObject(GENIE_OBJ_FORM,0x05,0);
    }
    }
    }
    }
    }



    PS:Will attach Video soon
    Last edited by ADVANCETOM; 4 October 2015, 05:44 AM.

    Leave a comment:


  • ADVANCETOM
    replied
    Ok the failure with .dot is char 110 but printed as an "n" is that right?

    if(temp >= 48 && temp <= 110 && counter <=9) // Recognize only number 1-9 change this to 48-122 if Qwerty

    1022n00 for 1022.00 ? im confused

    Last edited by ADVANCETOM; 4 October 2015, 03:05 AM.

    Leave a comment:


  • ADVANCETOM
    replied
    Hey my input from keyboard is working (Without dot i need also )and also print out.as keyvalue
    So far so Good, but not changed in Arduino Teensy 3.1 for the new calculation and i dont know how to do that

    My serial Printout from Serial.println(keyvalue[x]);
    -----------------------------------------------------------------------------------
    1
    0
    2
    0
    DONE
    ---------------------------------------------------------------------------------------------

    keyvalue is a char and i wanna change to float sealevelPressure !


    float seaLevelPressure = 1026.70; //edit to SLP for your location wanna also use for genie Input via Keyboard? //


    But how can i do this after this process Arduino Teensy 3.1 should change this to a new calculate for Altitude!


    And how can i use the (. dot) in code? with this code given 0-9 back and return works?


    Need Help




    Here is my code:


    Code:
    void myGenieEventHandler(void)
    {
     
      genieFrame Event;
      genie.DequeueEvent(&Event);
    
      //If the cmd received is from a Reported Event (Events triggered from the Events tab of Workshop4 objects)
      if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
      {
        if(Event.reportObject.object == GENIE_OBJ_KEYBOARD)
        {
          if (Event.reportObject.index == 0)                              // If keyboard0
          {
            temp = genie.GetEventData(&Event); 
            if(temp >= 48 && temp <= 57 && counter <=9)
            {
              keyvalue[counter] = temp;        // Receive the event data from the keyboard
              genie.WriteStr(3,keyvalue);                         //prints to String Object       
              counter = counter + 1; //increment array
            }
            else if(temp == 8)                              //check if backspace
            {
              counter--;
              keyvalue[counter] = 0;
              genie.WriteStr(3,keyvalue);
            }
            else if(temp == 13)
            {
              for(int x =0; x<counter ; x++)
              {
              Serial.println(keyvalue[x]);
                
                
              }
              Serial.print("DONE");
              //Serial.print(String(slp.toFloat());
             // char *keyvalue[x] = slp;
            // float seaLevelPressure = char keyvalue; 
                    
              genie.WriteObject(GENIE_OBJ_FORM,0x05,0);
            }
          }
        }
      }
    }

    Leave a comment:


  • Symon
    replied
    Hi,

    This application note should help you understand arduino printing so string objects via keyboard:

    http://www.4dsystems.com.au/appnote/4D-AN-00188/

    This application note shows how to write a sketch for an Arduino program that prints characters on string object from keyboard object to create a simple Password Implemented Application

    Leave a comment:


  • ADVANCETOM
    started a topic Need Help for keyboard input

    Need Help for keyboard input

    Hey my problem is to change this in my Arduino sketch via the keyboard Input!

    float seaLevelPressure = 1026.70; //edit to SLP for your location wanna also use for genie Input via Keyboard? //

    i know i have to use the event handler , but im stuck here.

    I have created a keyboard input 0-9 and a string Object

Working...
X