Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
Libs/PollSwitch/PollSwitch.cpp@36:0afc0fc8f86b, 2015-01-22 (annotated)
- Committer:
- pspatel321
- Date:
- Thu Jan 22 07:58:51 2015 +0000
- Revision:
- 36:0afc0fc8f86b
- Parent:
- 30:91af74a299e1
Tested in car with other systems. Most features are good to go. Except xbees need work. The DC-DC protection features were giving problems due to spurious current measurements. They have been edited to reduce glitchy errors.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| pspatel321 | 30:91af74a299e1 | 1 | #include "PollSwitch.h" |
| pspatel321 | 30:91af74a299e1 | 2 | |
| pspatel321 | 36:0afc0fc8f86b | 3 | PollSwitch::PollSwitch(DigitalIn *swArr, int numSw){ |
| pspatel321 | 30:91af74a299e1 | 4 | numSwitches = numSw; |
| pspatel321 | 30:91af74a299e1 | 5 | sw = swArr; |
| pspatel321 | 30:91af74a299e1 | 6 | } |
| pspatel321 | 30:91af74a299e1 | 7 | |
| pspatel321 | 30:91af74a299e1 | 8 | char PollSwitch::poll(){ |
| pspatel321 | 30:91af74a299e1 | 9 | char i = 0; |
| pspatel321 | 30:91af74a299e1 | 10 | |
| pspatel321 | 36:0afc0fc8f86b | 11 | // If a low signal is detected, previous switch is broken |
| pspatel321 | 30:91af74a299e1 | 12 | for (i = 0; i < numSwitches; i++) { |
| pspatel321 | 36:0afc0fc8f86b | 13 | if (sw[i].read() == 0) break; |
| pspatel321 | 30:91af74a299e1 | 14 | } |
| pspatel321 | 30:91af74a299e1 | 15 | if (i >= numSwitches) i = 0; |
| pspatel321 | 36:0afc0fc8f86b | 16 | else i++; |
| pspatel321 | 36:0afc0fc8f86b | 17 | return i; |
| pspatel321 | 30:91af74a299e1 | 18 | } |
