Exemple orientaiton
Dependencies: C12832 MMA7660 mbed
Fork of app-shield-accelerometer by
main.cpp@6:244758de2362, 2015-11-02 (annotated)
- Committer:
- rtk
- Date:
- Mon Nov 02 15:07:03 2015 +0000
- Revision:
- 6:244758de2362
- Parent:
- 5:636ebfdf373b
DS;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dreschpe | 0:f6a57b843f79 | 1 | #include "mbed.h" |
chris | 3:2db94ee076ee | 2 | #include "C12832.h" |
chris | 5:636ebfdf373b | 3 | #include "MMA7660.h" |
dreschpe | 0:f6a57b843f79 | 4 | |
chris | 4:39c7c31b8fb0 | 5 | // Using Arduino pin notation |
chris | 4:39c7c31b8fb0 | 6 | C12832 lcd(D11, D13, D12, D7, D10); |
rtk | 6:244758de2362 | 7 | MMA7660 MMA(I2C_SDA,I2C_SCL); |
rtk | 6:244758de2362 | 8 | enum Orientation {Up, Down, |
rtk | 6:244758de2362 | 9 | Right, Left, |
rtk | 6:244758de2362 | 10 | Back, Front, |
rtk | 6:244758de2362 | 11 | Unknown |
rtk | 6:244758de2362 | 12 | }; |
dreschpe | 1:1c6a9eaf55b5 | 13 | |
dreschpe | 0:f6a57b843f79 | 14 | int main() |
dreschpe | 0:f6a57b843f79 | 15 | { |
rtk | 6:244758de2362 | 16 | |
dreschpe | 0:f6a57b843f79 | 17 | |
chris | 5:636ebfdf373b | 18 | while(1) { |
rtk | 6:244758de2362 | 19 | lcd.locate(0,0); |
rtk | 6:244758de2362 | 20 | if (MMA.getSide()==Front) { |
rtk | 6:244758de2362 | 21 | lcd.cls(); // pour ne pas avoir Desssus écrit sur Dessous |
rtk | 6:244758de2362 | 22 | lcd.printf("Dessus"); |
rtk | 6:244758de2362 | 23 | } else if (MMA.getSide()==Back) lcd.printf("Dessous"); |
chris | 5:636ebfdf373b | 24 | wait(0.2); |
dreschpe | 0:f6a57b843f79 | 25 | } |
dreschpe | 0:f6a57b843f79 | 26 | } |