Skip to content

Commit 9b918d6

Browse files
committed
bump version
1 parent 02ce663 commit 9b918d6

File tree

4 files changed

+56
-45
lines changed

4 files changed

+56
-45
lines changed

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22

33
## v2.0.0
44

5-
- Simplified API
5+
This is a breaking release! Please have a look at the new API interface.
6+
Also feel free to open an issue if you have trouble while migrating!
7+
8+
- Changed interface:
9+
- Added `void pause()`
10+
- Added `void resume()`
11+
- Removed constructor `Timeout(unsigned long duration)`
12+
- Removed `void prepare(unsigned long duration)`
13+
- Removed `void start()` without arguments
14+
- Removed `bool periodic()` without arguments
615
- Improved tests
7-
- Add `pause` and `resume`
816
- Fixed rollover issues
17+
18+
## v1.x
19+
20+
- Initial release

README.md

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ _This is a library I use in almost all of my projects. It is fully unit-tested a
1010

1111
### Example 1: A simple timeout
1212

13-
The LED will turn on after 2 seconds.
13+
The LED will turn off after 2 seconds.
1414

1515
```cpp
16-
#include <timeout.h>
16+
#include <Timeout.h>
1717

1818
const int LED_PIN = 13;
19-
Timeout timeout;
19+
Timeout timer;
2020

2121
void setup()
2222
{
23-
pinMode(LED_PIN, OUTPUT);
24-
timeout.start(2000);
23+
pinMode(LED_PIN, OUTPUT);
24+
timer.start(2000);
2525
}
2626

2727
void loop()
2828
{
29-
digitalWrite(LED_PIN, timeout.time_over());
29+
digitalWrite(LED_PIN, !timer.time_over());
3030
}
3131
```
3232

@@ -37,7 +37,7 @@ Press the button to turn on the LED.
3737
Failing to press the button for more than one second switches off the LED.
3838

3939
```cpp
40-
#include <timeout.h>
40+
#include <Timeout.h>
4141

4242
const int LED_PIN = 13;
4343
const int BUTTON_PIN = 12;
@@ -46,20 +46,16 @@ Timeout heartbeat;
4646

4747
void setup()
4848
{
49-
pinMode(LED_PIN, OUTPUT);
50-
pinMode(BUTTON_PIN, INPUT);
51-
52-
heartbeat.prepare(1000);
49+
pinMode(LED_PIN, OUTPUT);
50+
pinMode(BUTTON_PIN, INPUT);
5351
}
5452

5553
void loop()
5654
{
57-
if (digitalRead(BUTTON_PIN))
58-
{
59-
heartbeat.start();
60-
}
61-
62-
digitalWrite(LED_PIN, !heartbeat.time_over());
55+
if (digitalRead(BUTTON_PIN)) {
56+
heartbeat.start(1000);
57+
}
58+
digitalWrite(LED_PIN, !heartbeat.time_over());
6359
}
6460
```
6561

@@ -68,7 +64,7 @@ void loop()
6864
Toggles the LED every 200 milliseconds.
6965

7066
```cpp
71-
#include <timeout.h>
67+
#include <Timeout.h>
7268

7369
const int LED_PIN = 13;
7470
bool led_on = false;
@@ -77,17 +73,15 @@ Timeout timer;
7773

7874
void setup()
7975
{
80-
pinMode(LED_PIN, OUTPUT);
81-
timer.start(200);
76+
pinMode(LED_PIN, OUTPUT);
8277
}
8378

8479
void loop()
8580
{
86-
if (timer.periodic())
87-
{
88-
led_on = !led_on;
89-
digitalWrite(LED_PIN, led_on);
90-
}
81+
if (timer.periodic(200)) {
82+
led_on = !led_on;
83+
digitalWrite(LED_PIN, led_on);
84+
}
9185
}
9286
```
9387

@@ -96,23 +90,25 @@ void loop()
9690
`Timeout` instances have the following methods:
9791

9892
```cpp
99-
// setup duration but don't start (time_over() will return true)
100-
// then call `start()` somewhere else in your code to start the timer.
101-
void prepare(unsigned long duration);
93+
// set the timer to `time_ms` and start ticking
94+
void start(uint32_t time_ms);
95+
96+
// returns a single true when time runs out and then resets to `time_ms`.
97+
bool periodic(uint32_t time_ms);
10298

103-
// setup duration and start the timer (time_over() is false
104-
// for the next `duration` milliseconds)
105-
void start(unsigned long duration);
99+
// pause and resume the timer
100+
void pause(void);
101+
void resume(void);
106102

107-
// returns true if time ran out, false otherwise
108-
bool time_over();
103+
// runs out the timer so `time_over()` returns true
104+
void expire(void);
109105

110-
// winds up the timer to last known duration
111-
void start();
106+
// returns whether the time ran out
107+
bool time_over(void);
112108

113-
// runs out the timer so time_over() is true
114-
void expire();
109+
// returns whether the timer is paused
110+
bool is_paused(void);
115111

116-
// returns a single true when time runs out then automatically resets itself
117-
bool periodic();
112+
// returns the milliseconds until the timer runs out
113+
uint32_t time_left_ms(void);
118114
```

keywords.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ Timeout KEYWORD1
1111
#######################################
1212
# Methods and Functions (KEYWORD2)
1313
#######################################
14-
prepare KEYWORD2
1514
start KEYWORD2
16-
time_over KEYWORD2
17-
expire KEYWORD2
1815
periodic KEYWORD2
16+
pause KEYWORD2
17+
resume KEYWORD2
18+
expire KEYWORD2
19+
time_over KEYWORD2
20+
is_paused KEYWORD2
21+
time_left_ms KEYWORD2
1922

2023
#######################################
2124
# Constants (LITERAL1)

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SimpleTimeout
2-
version=1.5.0
2+
version=2.0.0
33
author=Thomas Feldmann <mail@tfeldmann.de>
44
maintainer=Thomas Feldmann <mail@tfeldmann.de>
55
sentence=Minimal, production-ready timeout library for Arduino.

0 commit comments

Comments
 (0)