Library implementing menu system, with RPG interface, navigator system

Dependencies:   Menu RPG TextLCD mbed

Committer:
pyeh9
Date:
Tue Mar 05 22:16:35 2013 +0000
Revision:
3:30dc8952d0ae
Parent:
2:202735df93cd
2nd version - commented

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pyeh9 2:202735df93cd 1 //SDFileSystem sd(p5, p6, p7, p8, "sd");
pyeh9 2:202735df93cd 2
pyeh9 0:10b365b7873b 3 /*
pyeh9 0:10b365b7873b 4 struct dirent *p;
pyeh9 0:10b365b7873b 5 DIR *d = opendir("/sd/mydir");
pyeh9 0:10b365b7873b 6 char line[80];
pyeh9 0:10b365b7873b 7 string filename;
pyeh9 0:10b365b7873b 8
pyeh9 0:10b365b7873b 9 while((p = readdir(d)) != NULL){
pyeh9 0:10b365b7873b 10 menu.push_back(p->d_name);
pyeh9 0:10b365b7873b 11 }
pyeh9 0:10b365b7873b 12
pyeh9 0:10b365b7873b 13 */
pyeh9 0:10b365b7873b 14 //lcd.printf("%s\n", test.getText());
pyeh9 0:10b365b7873b 15
pyeh9 0:10b365b7873b 16 /*lcd.printf(">%s\n", menu[cursor].c_str());
pyeh9 0:10b365b7873b 17 lcd.printf(" %s", menu[cursor+1].c_str());
pyeh9 0:10b365b7873b 18 while(1){
pyeh9 0:10b365b7873b 19 if((dirt = rpg1.dir())!=0){ //Get Dir
pyeh9 0:10b365b7873b 20 wait(0.15);
pyeh9 0:10b365b7873b 21 cursor = cursor + dirt; //Ad Dir to count
pyeh9 0:10b365b7873b 22 if(cursor < 0) cursor = 0;
pyeh9 0:10b365b7873b 23 else if(cursor > 8) cursor = 8;
pyeh9 0:10b365b7873b 24 lcd.cls();
pyeh9 0:10b365b7873b 25 lcd.printf(">%s\n", menu[cursor].c_str());
pyeh9 0:10b365b7873b 26 lcd.printf(" %s", menu[cursor+1].c_str());
pyeh9 0:10b365b7873b 27 }
pyeh9 0:10b365b7873b 28
pyeh9 0:10b365b7873b 29 if (rpg1.pb()){
pyeh9 0:10b365b7873b 30 wait(0.25);
pyeh9 0:10b365b7873b 31 lcd.cls();
pyeh9 0:10b365b7873b 32 filename = "/sd/mydir/"+menu[cursor];
pyeh9 0:10b365b7873b 33 //lcd.printf("%s\n", filename);
pyeh9 0:10b365b7873b 34 FILE *fp = fopen(filename.c_str(), "r");
pyeh9 0:10b365b7873b 35 if(fp == NULL) {
pyeh9 0:10b365b7873b 36 error("Could not open file for reading\n");
pyeh9 0:10b365b7873b 37 }
pyeh9 0:10b365b7873b 38 fgets(line, 80, fp);
pyeh9 0:10b365b7873b 39 lcd.printf("%s\n", line);
pyeh9 0:10b365b7873b 40 fclose(fp);
pyeh9 0:10b365b7873b 41 }
pyeh9 0:10b365b7873b 42 }
pyeh9 0:10b365b7873b 43 */