Hello,
I have previously coded the display screen only via arduino and never used the Visi-Genie environment. My arduino interacts with other components so I want to keep coding the final code only in Arduino IDE.
At a moment in my code, I want to display a keyboard, say for example to type a name and enable the arduino to read the name as a string. However, I didn't know where to start so I searched through this forum and came accross this zip project, which enables password authentification by displaying a keypad : 4D-AN-00188_R_1_01.zip
If I understand well, the Visi Genie environment requires a micro SD card and makes it easier to paste the static code of the different forms.
I have different questions regarding the passowrd demo code used in the file. I have added them as questions in the following code :
I know... that's a lot of questions ^^ I'm a novice in the 4Dsystems environment so everything is pretty new to me, I'm sorry for all the spams !
Best regards,
Oumy
I have previously coded the display screen only via arduino and never used the Visi-Genie environment. My arduino interacts with other components so I want to keep coding the final code only in Arduino IDE.
At a moment in my code, I want to display a keyboard, say for example to type a name and enable the arduino to read the name as a string. However, I didn't know where to start so I searched through this forum and came accross this zip project, which enables password authentification by displaying a keypad : 4D-AN-00188_R_1_01.zip
If I understand well, the Visi Genie environment requires a micro SD card and makes it easier to paste the static code of the different forms.
I have different questions regarding the passowrd demo code used in the file. I have added them as questions in the following code :
Code:
#include <genieArduino.h> #define RESETLINE 4 Genie genie; char keyvalue[10]; // This enables to store keyboard values in a char of 10 values maximum ? Can it be less than 10 or just 10 ? char newkeyvalue[10]; //this is for Keyboard1 and the previous one for Keyboard0 right? But why is there two keyboards ? we're only supposed to type password once ? char asterisk[9]; // What is the use of the asterik ? int counter = 0; int counter2 = 0; int temp; int temp2; bool flag; void setup() { Serial.begin(9600); Serial1.begin(9600); genie.Begin(Serial1); genie.AttachEventHandler(myGenieEventHandler); pinMode(RESETLINE, OUTPUT); digitalWrite(RESETLINE, 1); delay(100); digitalWrite(RESETLINE, 0); delay (3500); } void loop() { genie.DoEvents(); } void myGenieEventHandler(void) { genieFrame Event; //What does this do ? genie.DequeueEvent(&Event); if (Event.reportObject.cmd == GENIE_REPORT_EVENT) { if(Event.reportObject.object == GENIE_OBJ_KEYBOARD) //Okay so this sees if there is a change in the keyboard right ? but how do they know how the keyboard looks like ? I haven't seen a line of code prior to that "designing" the code ? Their keypad display only number, but I want a keyboard that displays only letters, a back option and a space option, how can I do that ? { if (Event.reportObject.index == 0) { temp = genie.GetEventData(&Event); //is temp the character typed in the keyboard ? if(temp >= 48 && temp <= 57 && counter <=9) //what does 48 and 57 stand for ? the numbers in ASCII ? what does counter >9 means ? { keyvalue[counter] = temp; // Receive the event data from the keyboard genie.WriteStr(0,keyvalue); //it says that this prints to String Object, but where does it print it ?? counter = counter + 1; } else if(temp == 8) //what does 8 stand for ? { counter--; what does "--" mean ? keyvalue[counter] = 0; genie.WriteStr(0,keyvalue); } else if(temp == 13) //what does 13 stand for ? { for(int x =0; x<counter ; x++) { Serial.println(keyvalue[x]); } Serial.print("DONE"); genie.WriteObject(GENIE_OBJ_FORM,0x01,0); //what is this ? the second keyboard ? what is its use? } } } if (Event.reportObject.index == 1) { temp2 = genie.GetEventData(&Event); //whats the use of having a second keyboard ? if(temp2 >= 48 && temp2 <= 57 && counter2 <=9) { newkeyvalue[counter2] = temp2; asterisk[counter2] = temp2; genie.WriteStr(1,asterisk); asterisk[counter2] = '*'; counter2 = counter2 + 1; delay(200); genie.WriteStr(1,asterisk); } else if(temp2 == 8 && counter2 >0) //check if backspace { counter2--; newkeyvalue[counter2] = 0; asterisk[counter2] = ' '; genie.WriteStr(1,asterisk); } else if(temp2 == 13) { for(int x =0; x<counter ; x++) { Serial.println(newkeyvalue[x]); } Serial.print("DONE"); for(int x=0; x<9;x++) { if(keyvalue[x] == newkeyvalue[x]) //instead of having two keyvalues, can I just keep one keyboard and compare it to a string to see if the "password" is correct ?) { flag = 1; Serial.println("PASSED"); } else { flag = 0; } if(flag == 0) { break; } } if(flag == 0) { genie.WriteStr(2,"INCORRECT PASSWORD"); delay(2000); } else if(flag == 1) { genie.WriteStr(2,"CORRECT PASSWORD"); for(int y=0;y<9;y++) { newkeyvalue[y] = 0; asterisk[y] = 0; } delay(2000); flag = 0; counter2 = 0; genie.WriteStr(1,asterisk); //Why do this ? genie.WriteObject(GENIE_OBJ_FORM,0x01,0); // why do this ? } } } } }
Best regards,
Oumy
Comment