![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Mission Accomplished
main.cpp@0:96cf16c88314, 2016-01-20 (annotated)
- Committer:
- pstephens18
- Date:
- Wed Jan 20 01:01:04 2016 +0000
- Revision:
- 0:96cf16c88314
Final Mission Accomplished
;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pstephens18 | 0:96cf16c88314 | 1 | #include "Compass.h" |
pstephens18 | 0:96cf16c88314 | 2 | #include "Temperature.h" |
pstephens18 | 0:96cf16c88314 | 3 | #include "mbed.h" |
pstephens18 | 0:96cf16c88314 | 4 | #include "Tap.h" |
pstephens18 | 0:96cf16c88314 | 5 | #include "TextLCD.h" |
pstephens18 | 0:96cf16c88314 | 6 | |
pstephens18 | 0:96cf16c88314 | 7 | TextLCD lcd(p19,p20,p21,p22,p23,p24); |
pstephens18 | 0:96cf16c88314 | 8 | I2C acc(p9,p10); |
pstephens18 | 0:96cf16c88314 | 9 | InterruptIn to(p5); |
pstephens18 | 0:96cf16c88314 | 10 | Serial pc(USBTX,USBRX); |
pstephens18 | 0:96cf16c88314 | 11 | |
pstephens18 | 0:96cf16c88314 | 12 | double direction; |
pstephens18 | 0:96cf16c88314 | 13 | float temp2; |
pstephens18 | 0:96cf16c88314 | 14 | float tap; |
pstephens18 | 0:96cf16c88314 | 15 | float test; |
pstephens18 | 0:96cf16c88314 | 16 | void Temperature(float t); |
pstephens18 | 0:96cf16c88314 | 17 | void Direction(double d); |
pstephens18 | 0:96cf16c88314 | 18 | void toggle(void); |
pstephens18 | 0:96cf16c88314 | 19 | void printReading(void); |
pstephens18 | 0:96cf16c88314 | 20 | Ticker t; |
pstephens18 | 0:96cf16c88314 | 21 | bool displayTemperature; |
pstephens18 | 0:96cf16c88314 | 22 | DigitalOut led(LED1); |
pstephens18 | 0:96cf16c88314 | 23 | |
pstephens18 | 0:96cf16c88314 | 24 | int main() |
pstephens18 | 0:96cf16c88314 | 25 | { |
pstephens18 | 0:96cf16c88314 | 26 | displayTemperature = 1; |
pstephens18 | 0:96cf16c88314 | 27 | Tap_init(); |
pstephens18 | 0:96cf16c88314 | 28 | Tap(); |
pstephens18 | 0:96cf16c88314 | 29 | t.attach(&printReading,3); |
pstephens18 | 0:96cf16c88314 | 30 | to.rise(&toggle); |
pstephens18 | 0:96cf16c88314 | 31 | pc.printf("Beginning \n\r"); |
pstephens18 | 0:96cf16c88314 | 32 | while(1) {Tap();} |
pstephens18 | 0:96cf16c88314 | 33 | |
pstephens18 | 0:96cf16c88314 | 34 | } |
pstephens18 | 0:96cf16c88314 | 35 | |
pstephens18 | 0:96cf16c88314 | 36 | |
pstephens18 | 0:96cf16c88314 | 37 | /* |
pstephens18 | 0:96cf16c88314 | 38 | |
pstephens18 | 0:96cf16c88314 | 39 | direction = Compass(); |
pstephens18 | 0:96cf16c88314 | 40 | temp2 = Temperature(); |
pstephens18 | 0:96cf16c88314 | 41 | test = Tap(); |
pstephens18 | 0:96cf16c88314 | 42 | |
pstephens18 | 0:96cf16c88314 | 43 | if(test ==1) |
pstephens18 | 0:96cf16c88314 | 44 | { |
pstephens18 | 0:96cf16c88314 | 45 | Direction(direction); |
pstephens18 | 0:96cf16c88314 | 46 | Temperature(temp2); |
pstephens18 | 0:96cf16c88314 | 47 | } |
pstephens18 | 0:96cf16c88314 | 48 | test =0; |
pstephens18 | 0:96cf16c88314 | 49 | // pc.printf( "%1.2f = Taps, %1.2f = Temp, %1.2f = Direction \n\r" , tap, temp2, direction); |
pstephens18 | 0:96cf16c88314 | 50 | */ |
pstephens18 | 0:96cf16c88314 | 51 | |
pstephens18 | 0:96cf16c88314 | 52 | void printReading() |
pstephens18 | 0:96cf16c88314 | 53 | { |
pstephens18 | 0:96cf16c88314 | 54 | if (displayTemperature){ |
pstephens18 | 0:96cf16c88314 | 55 | Temperature(Temperature());} |
pstephens18 | 0:96cf16c88314 | 56 | else{ |
pstephens18 | 0:96cf16c88314 | 57 | Direction(Compass());} |
pstephens18 | 0:96cf16c88314 | 58 | } |
pstephens18 | 0:96cf16c88314 | 59 | |
pstephens18 | 0:96cf16c88314 | 60 | void Direction(double d) |
pstephens18 | 0:96cf16c88314 | 61 | { |
pstephens18 | 0:96cf16c88314 | 62 | lcd.cls(); |
pstephens18 | 0:96cf16c88314 | 63 | pc.printf( "%1.2f = Direction \n\r" , d); |
pstephens18 | 0:96cf16c88314 | 64 | lcd.printf("%1.2f = Direction" , d); |
pstephens18 | 0:96cf16c88314 | 65 | } |
pstephens18 | 0:96cf16c88314 | 66 | |
pstephens18 | 0:96cf16c88314 | 67 | void Temperature(float t) |
pstephens18 | 0:96cf16c88314 | 68 | { |
pstephens18 | 0:96cf16c88314 | 69 | lcd.cls(); |
pstephens18 | 0:96cf16c88314 | 70 | pc.printf( "%1.2f = Temperature \n\r" , t); |
pstephens18 | 0:96cf16c88314 | 71 | lcd.printf( "%1.2f = Temperature" , t); |
pstephens18 | 0:96cf16c88314 | 72 | } |
pstephens18 | 0:96cf16c88314 | 73 | |
pstephens18 | 0:96cf16c88314 | 74 | void toggle(void) |
pstephens18 | 0:96cf16c88314 | 75 | { |
pstephens18 | 0:96cf16c88314 | 76 | displayTemperature = !displayTemperature; |
pstephens18 | 0:96cf16c88314 | 77 | Tap(); |
pstephens18 | 0:96cf16c88314 | 78 | led=!led; |
pstephens18 | 0:96cf16c88314 | 79 | } |