aa
Revision 0:8981bbe3e60e, committed 2016-09-07
- Comitter:
- sakanakuuun
- Date:
- Wed Sep 07 08:00:34 2016 +0000
- Commit message:
- aaa
Changed in this revision
button.cpp | Show annotated file Show diff for this revision Revisions of this file |
button.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 8981bbe3e60e button.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/button.cpp Wed Sep 07 08:00:34 2016 +0000 @@ -0,0 +1,57 @@ +#include "button.h" + +DigitalIn start_button(USER_BUTTON); +DigitalOut beep(PB_10); + +DigitalIn phase1(PA_5); +DigitalIn phase2(PA_6); +DigitalIn phase4(PA_7); +DigitalIn phase8(PB_12); + +DigitalIn teamSW(PC_11); +DigitalOut teamledblue(PC_10); +DigitalOut teamledred(PC_12); + +Serial pc3(SERIAL_TX, SERIAL_RX); + +int phaseSW(void){ + phase1.mode(PullUp); + phase2.mode(PullUp); + phase4.mode(PullUp); + phase8.mode(PullUp); + + int SW=phase1+2*phase2+4*phase4+8*phase8; + pc3.printf("%d\n\r",SW); + return SW; +} + + +int teamLED() +{ + teamSW.mode(PullUp); + if(teamSW) { + teamledblue=1; + teamledred=0; + return -1; + } else { + teamledblue=0; + teamledred=1; + return 1; + } +} + +void buzzer(bool on) +{ + if(on) + beep = 1; + else + beep = 0; +} + +bool start() +{ + if(start_button) + return true; + else + return false; +} \ No newline at end of file
diff -r 000000000000 -r 8981bbe3e60e button.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/button.h Wed Sep 07 08:00:34 2016 +0000 @@ -0,0 +1,9 @@ +#include "mbed.h" + +int phaseSW(void); + +int teamLED(); + +void buzzer(bool on); + +bool start(); \ No newline at end of file