Skip to content

Commit

Permalink
Update PollingTimer to v0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hideakitai committed Sep 3, 2021
1 parent 990cab4 commit 53217e1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ Sequence<T>& offset(const double ms);
## Embedded Libraries

- [Easing v0.1.0](https://github.com/hideakitai/Easing)
- [PollingTimer v0.4.1](https://github.com/hideakitai/PollingTimer)
- [PollingTimer v0.4.2](https://github.com/hideakitai/PollingTimer)
- [ArxTypeTraits v0.2.1](https://github.com/hideakitai/ArxTypeTraits)
- [ArxContainer v0.3.14](https://github.com/hideakitai/ArxContainer)
- [ArxSmartPtr v0.2.1](https://github.com/hideakitai/ArxSmartPtr)
Expand Down
12 changes: 11 additions & 1 deletion Tween/util/PollingTimer/IntervalCounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,19 @@ class IntervalCounter : public PollingTimer {
startIntervalUsecForCount(after_us, 1);
}

void stop() {
virtual void stop() override {
cnt = 0;
PollingTimer::stop();
}

virtual void restart() override {
cnt = 0;
PollingTimer::restart();
}

virtual void clear() override {
cnt = 0;
PollingTimer::clear();
}

double count() {
Expand Down
21 changes: 12 additions & 9 deletions Tween/util/PollingTimer/PollingTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PollingTimer {
public:
virtual ~PollingTimer() {}

void start() {
virtual void start() {
startFromForUsec64(0, 0, false);
}

Expand Down Expand Up @@ -82,7 +82,7 @@ class PollingTimer {
b_loop = loop;
}

void stop() {
virtual void stop() {
prev_running = running;
running = false;
prev_us32 = 0;
Expand All @@ -93,7 +93,7 @@ class PollingTimer {
// b_loop
}

void play() {
virtual void play() {
if (isPausing()) {
prev_running = running;
running = true;
Expand All @@ -117,7 +117,7 @@ class PollingTimer {
restart();
}

void pause() {
virtual void pause() {
if (isRunning()) {
microsec();
prev_running = running;
Expand All @@ -133,12 +133,12 @@ class PollingTimer {
}
}

void restart() {
virtual void restart() {
stop();
startFromForUsec64(offset, duration, b_loop);
}

void clear() {
virtual void clear() {
prev_running = false;
running = false;
prev_us32 = 0;
Expand All @@ -156,6 +156,7 @@ class PollingTimer {
bool hasStarted() const { return isRunning() && !prev_running; }
bool hasPaused() const { return isPausing() && prev_running; }
bool hasStopped() const { return isStopping() && prev_running; }
void releaseEventTrigger() { prev_running = running; }

int64_t usec64() { return microsec(); }
double usec() { return (double)microsec(); }
Expand Down Expand Up @@ -253,11 +254,13 @@ class PollingTimer {

int64_t t = elapsed() + offset;
if ((t >= duration) && (duration != 0)) {
t = prev_us64 - origin + offset;
if (b_loop)
if (b_loop) {
t = 0;
restart();
else
} else {
t = prev_us64 - origin + offset;
stop();
}
}
return t;
} else if (isPausing()) {
Expand Down
12 changes: 6 additions & 6 deletions Tween/util/PollingTimer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ void loop() {
### `PollingTimer` (also available on all timer)
```C++
void start();
void stop();
void play();
void pause();
void restart();
void clear();
virtual void start();
virtual void stop();
virtual void play();
virtual void pause();
virtual void restart();
virtual void clear();
void startFromSec(const double from_sec);
void startFromMsec(const double from_ms);
Expand Down
2 changes: 1 addition & 1 deletion Tween/util/PollingTimer/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"url": "https://github.com/hideakitai",
"maintainer": true
},
"version": "0.4.1",
"version": "0.4.2",
"license": "MIT",
"frameworks": "*",
"platforms": "*"
Expand Down
2 changes: 1 addition & 1 deletion Tween/util/PollingTimer/library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=PollingTimer
version=0.4.1
version=0.4.2
author=hideakitai
maintainer=hideakitai
sentence=Arduino library to manage timing and event in a flexible way with polling
Expand Down

0 comments on commit 53217e1

Please sign in to comment.