void loadPrograme(){
file = SD.open("/classes/basic.txt", FILE_READ);
Serial.print("Reading, Checking and Compiling \n\n\n");
for (int i = 0; i < arraysize; i++) {
while (file.available()) {
character23 = file.read();
if (character23 == '\n') break;
if (character23 != '^') {
content += character23;
}
}
content.trim();
if (content != "") {
result[i] = content;
content = "";
delay(1000);
}
} for (int i = 0; i <arraysize; i++) { if(result[i].substring(0,5) == "print"){ printlnMethod(result[i]);
}
for (int i = 0; i <arraysize; i++) {
if(result[i].substring(0,5) == "print"){
printlnMethod(result[i]);
}else
if(result[i].substring(0,5) == "delay"){
delayMethod(result[i]);
}else
if(result[i].substring(0,11) == "buttonPress"){
buttonMethod(result[i]);
}
}
file.close();
}
void buttonMethod(String s){
s = s.substring(s.indexOf('{') + 1);
s = s.substring(0, s.lastIndexOf('}'));
void buttonMethod(String s){ s = s.substring(s.indexOf('{') + 1); s = s.substring(0, s.lastIndexOf('}')); String btn =" "; String daction = " "; String indaction = " "; btn= s.substring(s.indexOf('"')+1 ); btn= btn.substring(0, btn.lastIndexOf('"')); daction = s.substring(s.indexOf(',')+1); daction = daction.substring(0, daction.lastIndexOf('(')); indaction = s.substring(s.indexOf('~')+1); indaction = indaction.substring(0, indaction.lastIndexOf('~')); int buttonpressed; if(btn == "BUTTON_PIN_ENTER"){ buttonpressed = 2; }else if(btn == "BUTTON_PIN_LEFT"){ buttonpressed = 3; }else if(btn == "BUTTON_PIN_RIGHT"){ buttonpressed = 4; }else if(btn == "BUTTON_PIN_DOWN"){ buttonpressed = 5; }else if(btn == "BUTTON_PIN_UP"){ buttonpressed = 6; }else if(btn == "BUTTON_PIN_ACTION"){ buttonpressed = 7; }
String btn =" ";
String daction = " ";
String indaction = " ";
btn= s.substring(s.indexOf('"')+1 );
btn= btn.substring(0, btn.lastIndexOf('"'));
daction = s.substring(s.indexOf(',')+1);
daction = daction.substring(0, daction.lastIndexOf('('));
indaction = s.substring(s.indexOf('~')+1);
indaction = indaction.substring(0, indaction.lastIndexOf('~'));
int buttonpressed;
if(btn == "BUTTON_PIN_ENTER"){
buttonpressed = 2;
}else if(btn == "BUTTON_PIN_LEFT"){
buttonpressed = 3;
}else if(btn == "BUTTON_PIN_RIGHT"){
buttonpressed = 4;
}else if(btn == "BUTTON_PIN_DOWN"){
buttonpressed = 5;
}else if(btn == "BUTTON_PIN_UP"){
buttonpressed = 6;
}else if(btn == "BUTTON_PIN_ACTION"){
buttonpressed = 7;
}
int btncheck = digitalRead(buttonpressed);
if(btncheck == LOW){
if(daction.substring(0,5) == "print"){
printlnMethod(indaction);
}else if(daction.substring(0,5) == "delay"){
delayMethod(indaction);
}
}
}
}