Working read code with mode button
Dependencies: SDFileSystem emic2 mbed-rtos mbed
Fork of BAT_senior_design_Testnew by
button.cpp@12:21268d8bf979, 2017-10-16 (annotated)
- Committer:
- aismail1997
- Date:
- Mon Oct 16 15:45:17 2017 +0000
- Revision:
- 12:21268d8bf979
- Child:
- 15:b80dde24e9bc
moved button code to a separate class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aismail1997 | 12:21268d8bf979 | 1 | #include "mbed.h" |
aismail1997 | 12:21268d8bf979 | 2 | #include "button.h" |
aismail1997 | 12:21268d8bf979 | 3 | |
aismail1997 | 12:21268d8bf979 | 4 | button::button(PwmOut servo, DigitalIn pb) |
aismail1997 | 12:21268d8bf979 | 5 | : servo(servo), pb(pb) {} |
aismail1997 | 12:21268d8bf979 | 6 | |
aismail1997 | 12:21268d8bf979 | 7 | // FUNCTIONS |
aismail1997 | 12:21268d8bf979 | 8 | PwmOut button::getServoPin() |
aismail1997 | 12:21268d8bf979 | 9 | { |
aismail1997 | 12:21268d8bf979 | 10 | return servo; |
aismail1997 | 12:21268d8bf979 | 11 | } |
aismail1997 | 12:21268d8bf979 | 12 | |
aismail1997 | 12:21268d8bf979 | 13 | int button::getState() |
aismail1997 | 12:21268d8bf979 | 14 | { |
aismail1997 | 12:21268d8bf979 | 15 | return state; |
aismail1997 | 12:21268d8bf979 | 16 | } |
aismail1997 | 12:21268d8bf979 | 17 | |
aismail1997 | 12:21268d8bf979 | 18 | void button::moveServoIn() |
aismail1997 | 12:21268d8bf979 | 19 | { |
aismail1997 | 12:21268d8bf979 | 20 | //myled = 1; |
aismail1997 | 12:21268d8bf979 | 21 | // rotate 90 degrees one way |
aismail1997 | 12:21268d8bf979 | 22 | for(int i=3; i<=7; i++) { |
aismail1997 | 12:21268d8bf979 | 23 | servo = i/100.0; |
aismail1997 | 12:21268d8bf979 | 24 | wait(0.01); |
aismail1997 | 12:21268d8bf979 | 25 | } |
aismail1997 | 12:21268d8bf979 | 26 | } |
aismail1997 | 12:21268d8bf979 | 27 | |
aismail1997 | 12:21268d8bf979 | 28 | void button::moveServoOut() |
aismail1997 | 12:21268d8bf979 | 29 | { |
aismail1997 | 12:21268d8bf979 | 30 | //myled = 0; |
aismail1997 | 12:21268d8bf979 | 31 | for(int i=7; i>3; i--) { |
aismail1997 | 12:21268d8bf979 | 32 | servo = i/100.0; |
aismail1997 | 12:21268d8bf979 | 33 | wait(0.01); |
aismail1997 | 12:21268d8bf979 | 34 | } |
aismail1997 | 12:21268d8bf979 | 35 | } |