12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include "all-headers.h"
- uint32_t antiBlinkBuffer;
- const uint32_t bufferEmpty(0);
- const uint32_t bufferFull(~ bufferEmpty);
- bool buttonReleased;
- bool actionDone;
- DigitalPort LED[5];
- void setup (USER_MODE) {
-
- digitalWrite(L0_LED, true);
- antiBlinkBuffer = 0;
- buttonReleased = digitalRead(P0_PUSH_BUTTON);
- actionDone = false;
- LED[0] = L0_LED;
- LED[1] = L1_LED;
- LED[2] = L2_LED;
- LED[3] = L3_LED;
- LED[4] = L4_LED;
- }
- void loop (USER_MODE) {
-
- antiBlinkBuffer <<= 1;
- if (digitalRead(P0_PUSH_BUTTON))
- antiBlinkBuffer |= 0x01;
-
- if (antiBlinkBuffer == bufferEmpty) {
- buttonReleased = false;
- }
- else if (antiBlinkBuffer == bufferFull) {
- buttonReleased = true;
- actionDone = false;
- }
- if (!buttonReleased && !actionDone) {
- digitalToggle(L0_LED);
- actionDone = true;
- }
- }
|