Sat Nov 14, 2015 12:36 am
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;
#define STATE_PROMPT 0
#define STATE_KEYBOARD 1
short state = 0;
char *prompt = "*******PROMPT*******\nPress A to type a\ncommand.\nType the command\n'commands' to show\na list of commands.";
void setup()
{
gb.begin();
gb.titleScreen(F("Calculator"));
}
char *commands[3] = {
"sin", "cos", "tan"
};
void loop()
{
if(gb.update()) {
switch(state) {
case STATE_PROMPT: {
if(!gb.buttons.pressed(BTN_A)) {
gb.display.println(prompt);
} else {
state = STATE_KEYBOARD;
}
break;
}
case STATE_KEYBOARD: {
char* command = "";
gb.keyboard(command, 4);
while(true) {
for(int i = 0;i < 3;i++) {
char other[4];
for(int i = 0;i < 3;i++) {
other[i] = commands[0][i];
}
other[3] = '\0';
if(command == (other)) {
gb.display.println("Hello World");
}
}
gb.update();
}
break;
}
}
}
}
Sat Nov 14, 2015 1:02 am