main reminder functionality
Dependencies: mbed 4DGL-uLCD-SE SDFileSystem
Diff: main.cpp
- Revision:
- 4:ae6216936ddf
- Parent:
- 3:3eda3d120742
- Child:
- 5:69da174d0f56
--- a/main.cpp Mon Dec 05 20:18:02 2016 +0000 +++ b/main.cpp Tue Dec 06 03:43:30 2016 +0000 @@ -6,12 +6,19 @@ #include "uLCD_4DGL.h" DigitalOut myled(LED1); + +InterruptIn pb1(p21); +InterruptIn pb2(p22); + uLCD_4DGL uLCD(p28,p27,p29); SDFileSystem sd(p5, p6, p7, p8, "sd"); //PinDetect pb1(p21); // receive new schedule Serial pc(USBTX, USBRX); // tx, rx .... for testing purposes (remove later) //Serial blue(p13, p14, 9600); Serial easyVR(p13,p14); +void pb1_hit_interrupt (void); +void pb2_hit_interrupt (void); + // Global vars time_t ct_time; @@ -36,11 +43,16 @@ // in real project, we will set the time via the internet //uLCD.printf("Hello world\n"); // localtime( - //pb1.mode(PullUp); - //pb1.attach_deasserted(&pb1_hit_callback); - //wait(.01); - //pb1.setSampleFrequency(); - //writetest(); + pb1.mode(PullUp); + // Delay for initial pullup to take effect + wait(.01); + // Attach the address of the interrupt handler routine for pushbutton + pb1.fall(&pb1_hit_interrupt); + pb2.mode(PullUp); + wait(.01); + pb2.fall(&pb2_hit_interrupt); + + srand (time(NULL)); // initialize random numbers /* int i = 0; while(1) @@ -134,7 +146,8 @@ } wait(1); } - wait(5); + uLCD.printf("All reminders done for the day\n"); + while(1) {} } } @@ -526,11 +539,11 @@ switch(minutes[0]) { case 0: - // say "OH" - speak(synWords[1]); - wait(0.002); if (minutes[1] == 0) { - // say "clock" + // say "OH" + // speak(synWords[1]); + // wait(0.002); + // say "o'clock" speak(synWords[0]); wait(0.002); } @@ -580,4 +593,62 @@ void pb1_hit_callback (void) { uLCD.printf("push button pressed - receive schedule\n"); receive_schedule(); -}*/ \ No newline at end of file +}*/ + +void pb1_hit_interrupt (void) +{ + uLCD.printf("push button 1 pressed - send schedule\n"); + //receive_schedule(); + packdata(1); +} + +void pb2_hit_interrupt (void) +{ + uLCD.printf("push button 2 pressed - cognitive game\n"); +} + + +void cognitivegame() +{ + /* + vector<string> wordset1; + vector<string> wordset2; + vector<string> wordset3; + vector<string> wordset4; + vector<string> wordset5; + */ + int correct = 0; + int timesplayed; + uLCD.printf("Speak: Your recall wordset will now play\n"); + // speak(recall game) + wait(3); + + int wordset = rand() % 5; // pick random wordset between 1 and 5 + + uLCD.printf("Playing wordset %i\n", wordset); + switch(wordset) { + case 0: { + //speak(wordset1); + break; + } + case 1: { + //speak(wordset2); + break; + } + case 2: { + //speak(wordset3); + break; + } + case 3: { + //speak(wordset4); + break; + } + case 4: { + //speak(wordset5); + break; + } + } + + uLCD.printf("Was _____ the first word in the set?\n"); + uLCD.printf("Was _____ the last word in the set?\n"); +} \ No newline at end of file