Skip to content

Commit 6f1d9c6

Browse files
committed
Define collision fix.
1 parent 11d2f90 commit 6f1d9c6

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SoftTimer
2-
version=3.1.2
2+
version=3.1.3
33
author=Balazs Kelemen <[email protected]>
44
maintainer=Balazs Kelemen <[email protected]>
55
sentence=SoftTimer is a lightweight pseudo multitasking solution for Arduino.

src/BlinkTask.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
#include "BlinkTask.h"
2828
#include "SoftTimer.h"
2929

30+
#define BLINK_STATE_OFF 0
31+
#define BLINK_STATE_ON 1
32+
#define BLINK_STATE_WAIT 2
33+
3034
void BlinkTask::init(byte outPin, unsigned long onMs, unsigned long offMs, byte count, unsigned long delayMs) {
3135
this->onMs = onMs;
3236
this->offMs = offMs;
@@ -58,7 +62,7 @@ BlinkTask::BlinkTask(byte outPin, unsigned long onMs, unsigned long offMs, byte
5862
}
5963

6064
void BlinkTask::start() {
61-
this->_state = STATE_OFF;
65+
this->_state = BLINK_STATE_OFF;
6266
this->_counter = 0;
6367
this->setPeriodMs(0);
6468
SoftTimer.add(this);
@@ -76,15 +80,15 @@ void BlinkTask::stop() {
7680

7781
void BlinkTask::stepState(Task* task) {
7882
BlinkTask* bt = (BlinkTask*)task;
79-
if(bt->_state == STATE_ON) {
83+
if(bt->_state == BLINK_STATE_ON) {
8084
// -- Turn off.
8185
if(bt->onLevel == HIGH) {
8286
*bt->_portRegister &= ~bt->_bitMask;
8387
} else {
8488
*bt->_portRegister |= bt->_bitMask;
8589
}
8690
bt->_counter += 1;
87-
bt->_state = STATE_OFF;
91+
bt->_state = BLINK_STATE_OFF;
8892
bt->setPeriodMs(bt->offMs);
8993
}
9094
else {
@@ -95,7 +99,7 @@ void BlinkTask::stepState(Task* task) {
9599
} else {
96100
*bt->_portRegister &= ~bt->_bitMask;
97101
}
98-
bt->_state = STATE_ON;
102+
bt->_state = BLINK_STATE_ON;
99103
bt->setPeriodMs(bt->onMs);
100104
}
101105
if((bt->count > 0) && (bt->_counter >= bt->count)) {
@@ -104,7 +108,7 @@ void BlinkTask::stepState(Task* task) {
104108

105109
if(bt->delayMs > 0) {
106110
// -- delay was defined.
107-
bt->_state = STATE_WAIT;
111+
bt->_state = BLINK_STATE_WAIT;
108112
bt->setPeriodMs(bt->delayMs);
109113
} else {
110114
bt->stop();

src/BlinkTask.h

-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
#include "Arduino.h"
3232
#include "Task.h"
3333

34-
#define STATE_OFF 0
35-
#define STATE_ON 1
36-
#define STATE_WAIT 2
37-
3834
class BlinkTask : public Task
3935
{
4036
public:

0 commit comments

Comments
 (0)