aa

button.cpp

Committer:
sakanakuuun
Date:
2016-09-07
Revision:
0:8981bbe3e60e

File content as of revision 0:8981bbe3e60e:

#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;
}