Working read code with mode button

Dependencies:   SDFileSystem emic2 mbed-rtos mbed

Fork of BAT_senior_design_Testnew by BAT

Committer:
aismail1997
Date:
Sun Oct 22 22:20:11 2017 +0000
Revision:
16:581a3b02f4c3
Parent:
15:b80dde24e9bc
Child:
21:ceac47be2e64
Last working code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aismail1997 12:21268d8bf979 1 #include "mbed.h"
aismail1997 12:21268d8bf979 2 #include "button.h"
aismail1997 12:21268d8bf979 3
aismail1997 15:b80dde24e9bc 4 // button constructor
aismail1997 12:21268d8bf979 5 button::button(PwmOut servo, DigitalIn pb)
aismail1997 12:21268d8bf979 6 : servo(servo), pb(pb) {}
aismail1997 16:581a3b02f4c3 7 //button::button(PwmOut servo, DigitalIn pb, AnalogIn lp)
aismail1997 16:581a3b02f4c3 8 // : servo(servo), pb(pb), linpot(lp), mode(0), state(0) {}
aismail1997 12:21268d8bf979 9
aismail1997 12:21268d8bf979 10 // FUNCTIONS
aismail1997 15:b80dde24e9bc 11
aismail1997 15:b80dde24e9bc 12 // get servo pin
aismail1997 12:21268d8bf979 13 PwmOut button::getServoPin()
aismail1997 12:21268d8bf979 14 {
aismail1997 12:21268d8bf979 15 return servo;
aismail1997 12:21268d8bf979 16 }
aismail1997 12:21268d8bf979 17
aismail1997 16:581a3b02f4c3 18 // get servo pin
aismail1997 16:581a3b02f4c3 19 /*void button::setState(int mystate)
aismail1997 16:581a3b02f4c3 20 {
aismail1997 16:581a3b02f4c3 21 state = mystate;
aismail1997 16:581a3b02f4c3 22 }
aismail1997 16:581a3b02f4c3 23
aismail1997 16:581a3b02f4c3 24 // get servo pin
aismail1997 16:581a3b02f4c3 25 void button::setMode(int mymode)
aismail1997 16:581a3b02f4c3 26 {
aismail1997 16:581a3b02f4c3 27 mode = mymode;
aismail1997 16:581a3b02f4c3 28 }*/
aismail1997 16:581a3b02f4c3 29
aismail1997 15:b80dde24e9bc 30 // get current state of the button
aismail1997 15:b80dde24e9bc 31 /*int button::getState()
aismail1997 12:21268d8bf979 32 {
aismail1997 12:21268d8bf979 33 return state;
aismail1997 15:b80dde24e9bc 34 }*/
aismail1997 12:21268d8bf979 35
aismail1997 15:b80dde24e9bc 36 // move servo into the slot
aismail1997 12:21268d8bf979 37 void button::moveServoIn()
aismail1997 12:21268d8bf979 38 {
aismail1997 12:21268d8bf979 39 //myled = 1;
aismail1997 12:21268d8bf979 40 // rotate 90 degrees one way
aismail1997 12:21268d8bf979 41 for(int i=3; i<=7; i++) {
aismail1997 12:21268d8bf979 42 servo = i/100.0;
aismail1997 12:21268d8bf979 43 wait(0.01);
aismail1997 12:21268d8bf979 44 }
aismail1997 12:21268d8bf979 45 }
aismail1997 12:21268d8bf979 46
aismail1997 15:b80dde24e9bc 47 // move servo out of the slot
aismail1997 12:21268d8bf979 48 void button::moveServoOut()
aismail1997 12:21268d8bf979 49 {
aismail1997 12:21268d8bf979 50 //myled = 0;
aismail1997 12:21268d8bf979 51 for(int i=7; i>3; i--) {
aismail1997 12:21268d8bf979 52 servo = i/100.0;
aismail1997 12:21268d8bf979 53 wait(0.01);
aismail1997 12:21268d8bf979 54 }
aismail1997 12:21268d8bf979 55 }