Not able to run on its own but useful

Dependencies:   mbed

main.cpp

Committer:
maxmbrown
Date:
2016-11-10
Revision:
0:7d5e19fe3578

File content as of revision 0:7d5e19fe3578:

#include "mbed.h"

int yes = 0;
int no = 0;
int response = 0;

//1 2 3 4 5 6 7 8 9 10 11 12 15 50 40 30 20
times vector = [11, 19, 16, 7, 5, 21, 13, 1, 8, 14, 2, 17, 3, 4, 6, 15, 18];

//o'clock, OH, reminder, appointment, AM, PM, Taken Meds?, Thank You
words vector = [9, 10, 11, 20 ,22, 24, 23, 25]

//determine reminder type (app or rem)
if(rem_type == "app"){
    speak(words[3]);
    wait(0.001);
else
    //reminder
    speak(words[2]);
    wait(0.001);
    //ask if they've taken their medication
    speak(words[6]);
    wait(0.001);
    //intake and process yes/no response
    device.putc('d');
    wait(.001);
        device.putc('B');
        while (device.readable()!=0) {}
        rchar=device.getc();
        pc.putc(rchar);
    //for a yes response
    if (rchar=='A'){
        yes++;
        response++;
        }
    if (rchar == 'B'){
        no++;
        response++;
        }
    
    //thank the user
    speak(words[7]);
    wait(0.001);
}

//determine am or pm
ampm = 0;
if(hour >= 12){
    hour = hour % 12;
    ampm = 24;
else
    ampm = 22;
}

//two switch case statements: one for if the second number is a 5, one if it's a 0
if(minutes(1) == "5"){
    switch(minutes(0))
        //say "OH 5"
        case "0": speak(words[1]);
            wait(0.001);
            speak(times[5-1]);
            wait(0.001);
        //say "fifteen"
        case "1" : speak(times[13-1]);
            wait(0.001);
        //say "twenty-five"
        case "2" : speak(times[17-1]);
            wait(0.001);
            speak(times[5-1]);
            wait(0.001);
        //say "thirty-five"
        case "3" : speak(times[16-1]);
            wait(0.001);
            speak(times[5-1]);
            wait(0.001);
        //say "forty-five"
        case "4" : speak(times[15-1]);
            wait(0.001);
            speak(times[5-1]);
            wait(0.001);
        //say "fifty-five"
        case "5" : speak(times[14-1]);
            wait(0.001);
            speak(times[5-1]);
            wait(0.001);
        }
else
    switch(minutes(0)){
        //say "O'clock"
        case "0": speak(words[0]);
            wait(0.001);
        //say "ten"
        case "1" : speak(times[10-1]);
            wait(0.001);
        //say "twenty"
        case "2" : speak(times[17-1]);
            wait(0.001);
        //say "thirty"
        case "3" : speak(times[16-1]);
            wait(0.001);
        //say "forty"
        case "4" : speak(times[15-1]);
            wait(0.001);
        //say "fifty"
        case "5" : speak(times[14-1]);
            wait(0.001);
        }        
}
speak(ampm);