Penn Electric Racing / Mbed 2 deprecated SystemManagement

Dependencies:   mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP

Fork of SystemManagement by Martin Deng

Libs/PollSwitch/PollSwitch.cpp

Committer:
pspatel321
Date:
2015-01-22
Revision:
36:0afc0fc8f86b
Parent:
30:91af74a299e1

File content as of revision 36:0afc0fc8f86b:

#include "PollSwitch.h"

PollSwitch::PollSwitch(DigitalIn *swArr, int numSw){
    numSwitches = numSw;
    sw = swArr;
}

char PollSwitch::poll(){
    char i = 0;
    
    // If a low signal is detected, previous switch is broken
    for (i = 0; i < numSwitches; i++) {
        if (sw[i].read() == 0) break;
    }
    if (i >= numSwitches) i = 0;
    else i++;
    return i;
}