Hey,
You can use the function
strstr to check if one chain is contained into another. I changed the keyboard example for it to check if you entered a smiley face :
- Code: Select all
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;
char text[13] = "Default text";
void setup(){
gb.begin();
gb.titleScreen(F("Keyword example"));
gb.keyboard(text, 13);
}
void loop(){
if(gb.update()){
gb.display.println(F("You wrote:"));
gb.display.println(text);
if(strstr(text,":)")){
gb.display.println(F("Nice Smiley!"));
}
if(gb.buttons.pressed(BTN_C)){
gb.titleScreen(F("Keyword example"));
gb.keyboard(text, 13);
}
}
}
Concerning special characters, you can type them in your source code using the octal value of the character in an
escape sequence ("\" followed by the octal value). Check the
character table to find the code : first is the row number and second the column number. For example "\25\26\27" is the string "A button symbol", "B button symbol", "C button symbol".
- Font5x7.png (4.32 KiB) Viewed 3301 times