Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit 6b319e5

Browse files
authored
v1.3.1 using float for interval
### Releases v1.3.1 1. Using `float` instead of `ulong` for better interval accuracy
1 parent b7d8f4b commit 6b319e5

10 files changed

+71
-60
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Arduino IDE version: 1.8.19
3131
RP2040 core v2.5.4
3232
RASPBERRY_PI_PICO Module
3333
OS: Ubuntu 20.04 LTS
34-
Linux xy-Inspiron-3593 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
34+
Linux xy-Inspiron-3593 5.15.0-48-generic #54~20.04.1-Ubuntu SMP Thu Sep 1 16:17:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3535
3636
Context:
3737
I encountered a crash while using this library

README.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ The current library implementation, using `xyz-Impl.h` instead of standard `xyz.
220220

221221
You can include these `.hpp` or `.h` files
222222

223-
```
223+
```C++
224224
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
225225
#include "RPi_Pico_TimerInterrupt.h" //https://github.com/khoih-prog/RPI_PICO_TimerInterrupt
226226

@@ -230,7 +230,7 @@ You can include these `.hpp` or `.h` files
230230

231231
in many files. But be sure to use the following `.h` file **in just 1 `.h`, `.cpp` or `.ino` file**, which must **not be included in any other file**, to avoid `Multiple Definitions` Linker Error
232232

233-
```
233+
```C++
234234
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
235235
#include "RPi_Pico_ISR_Timer.h" //https://github.com/khoih-prog/RPI_PICO_TimerInterrupt
236236
```
@@ -271,7 +271,7 @@ Before using any Timer, you have to make sure the Timer has not been used by any
271271

272272
### 1.1 Init Hardware Timer
273273

274-
```
274+
```C++
275275
// Select the timer you're using, from ITimer0(0)-ITimer3(3)
276276
// Init RPI_PICO_Timer
277277
RPI_PICO_Timer ITimer1(1);
@@ -281,7 +281,7 @@ RPI_PICO_Timer ITimer1(1);
281281
282282
Use one of these functions with **interval in unsigned long microseconds**
283283
284-
```
284+
```C++
285285
// interval (in us), callback is ISR
286286
bool setInterval(unsigned long interval, pico_timer_callback callback);
287287
@@ -291,7 +291,7 @@ bool attachInterruptInterval(unsigned long interval, pico_timer_callback callbac
291291

292292
as follows
293293

294-
```
294+
```C++
295295
void TimerHandler()
296296
{
297297
// Doing something here inside ISR
@@ -318,7 +318,7 @@ void setup()
318318
319319
Use one of these functions with **frequency in float Hz**
320320
321-
```
321+
```C++
322322
// frequency (in Hz), callback is ISR
323323
bool setFrequency(float frequency, pico_timer_callback callback)
324324
@@ -328,7 +328,7 @@ bool attachInterrupt(float frequency, timer_callback callback);
328328

329329
as follows
330330

331-
```
331+
```C++
332332
void TimerHandler()
333333
{
334334
// Doing something here inside ISR
@@ -360,7 +360,7 @@ The 16 ISR_based Timers, designed for long timer intervals, only support using *
360360
361361
### 2.2 Init Hardware Timer and ISR-based Timer
362362
363-
```
363+
```C++
364364
// Init RPI_PICO_Timer
365365
RPI_PICO_Timer ITimer1(1);
366366
@@ -371,7 +371,7 @@ RPI_PICO_ISR_Timer ISR_timer;
371371

372372
### 2.3 Set Hardware Timer Interval and attach Timer Interrupt Handler functions
373373

374-
```
374+
```C++
375375
void TimerHandler()
376376
{
377377
ISR_timer.run();
@@ -448,7 +448,7 @@ void setup()
448448

449449
### Example [ISR_Timers_Array_Simple](examples/ISR_Timers_Array_Simple)
450450

451-
https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/blob/f2ca9ced6ef985653cb234a3268b237b0fa257f1/examples/ISR_Timers_Array_Simple/ISR_Timers_Array_Simple.ino#L23-L166
451+
https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/blob/b7d8f4b4b7eabec8c140fc55d88efb82939a6ad6/examples/ISR_Timers_Array_Simple/ISR_Timers_Array_Simple.ino#L23-L168
452452

453453
---
454454
---
@@ -462,9 +462,8 @@ The following is the sample terminal output when running example [ISR_Timers_Arr
462462
While software timer, **programmed for 2s, is activated after more than 10.000s !!!**
463463

464464
```
465-
466465
Starting ISR_Timers_Array_Simple on RASPBERRY_PI_PICO
467-
RPi_Pico_TimerInterrupt v1.3.0
466+
RPi_Pico_TimerInterrupt v1.3.1
468467
CPU Frequency = 125 MHz
469468
[TISR] _timerNo = 1, Clock (Hz) = 1000000.00, _fre (Hz) = 1000.00
470469
[TISR] _count = 0-1000
@@ -489,7 +488,7 @@ The following is the sample terminal output when running example [TimerInterrupt
489488

490489
```
491490
Starting TimerInterruptTest on RASPBERRY_PI_PICO
492-
RPi_Pico_TimerInterrupt v1.3.0
491+
RPi_Pico_TimerInterrupt v1.3.1
493492
CPU Frequency = 125 MHz
494493
[TISR] _timerNo = 0, Clock (Hz) = 1000000.00, _fre (Hz) = 1.00
495494
[TISR] _count = 0-1000000
@@ -533,7 +532,7 @@ The following is the sample terminal output when running example [Change_Interva
533532

534533
```
535534
Starting Change_Interval on RASPBERRY_PI_PICO
536-
RPi_Pico_TimerInterrupt v1.3.0
535+
RPi_Pico_TimerInterrupt v1.3.1
537536
CPU Frequency = 125 MHz
538537
[TISR] _timerNo = 0, Clock (Hz) = 1000000.00, _fre (Hz) = 0.50
539538
[TISR] _count = 0-2000000
@@ -614,7 +613,7 @@ The following is the sample terminal output when running example [SwitchDebounce
614613

615614
```
616615
Starting SwitchDebounce on RASPBERRY_PI_PICO
617-
RPi_Pico_TimerInterrupt v1.3.0
616+
RPi_Pico_TimerInterrupt v1.3.1
618617
CPU Frequency = 125 MHz
619618
[TISR] _timerNo = 1, Clock (Hz) = 1000000.00, _fre (Hz) = 50.00
620619
[TISR] _count = 0-20000
@@ -639,7 +638,7 @@ The following is the sample terminal output when running example [ISR_Timers_Arr
639638

640639
```
641640
Starting ISR_Timers_Array_Simple on RASPBERRY_PI_PICO
642-
RPi_Pico_TimerInterrupt v1.3.0
641+
RPi_Pico_TimerInterrupt v1.3.1
643642
CPU Frequency = 125 MHz
644643
[TISR] _timerNo = 1, Clock (Hz) = 1000000.00, _fre (Hz) = 1000.00
645644
[TISR] _count = 0-1000
@@ -662,7 +661,7 @@ The following is the sample terminal output when running example [ISR_16_Timers_
662661

663662
```
664663
Starting ISR_16_Timers_Array_Complex on RASPBERRY_PI_PICO
665-
RPi_Pico_TimerInterrupt v1.3.0
664+
RPi_Pico_TimerInterrupt v1.3.1
666665
CPU Frequency = 125 MHz
667666
[TISR] _timerNo = 1, Clock (Hz) = 1000000.00, _fre (Hz) = 100.00
668667
[TISR] _count = 0-10000
@@ -815,7 +814,7 @@ Debug is enabled by default on Serial.
815814

816815
You can also change the debugging level (_TIMERINTERRUPT_LOGLEVEL_) from 0 to 4
817816

818-
```cpp
817+
```C++
819818
// These define's must be placed at the beginning before #include "RPI_PICO_TimerInterrupt.h"
820819
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
821820
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
@@ -850,15 +849,17 @@ Submit issues to: [RPI_PICO_TimerInterrupt issues](https://github.com/khoih-prog
850849

851850
## DONE
852851

853-
1. Basic hardware timers for **RP2040-based boards such as RASPBERRY_PI_PICO**, using [**Earle Philhower's arduino-pico** core](https://github.com/earlephilhower/arduino-pico)
854-
2. More hardware-initiated software-enabled timers
855-
3. Longer time interval
856-
4. Add Version String
857-
5. Add Table of Contents
858-
6. Add support to new boards (**ADAFRUIT_ITSYBITSY_RP2040, ADAFRUIT_QTPY_RP2040, ADAFRUIT_STEMMAFRIEND_RP2040, ADAFRUIT_TRINKEYQT_RP2040, ADAFRUIT_MACROPAD_RP2040, SPARKFUN_PROMICRO_RP2040, Nano_RP2040_Connect, etc.**) using the arduino-pico core
859-
7. Fix `multiple-definitions` linker error
860-
8. Optimize library code by using `reference-passing` instead of `value-passing`
861-
9. Fix severe bug affecting time between the starts. Check [Enable fixed timing between timer calls (vs fixed time btw. end of timer call and next call as implemented) #3](https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/issues/3)
852+
1. Basic hardware timers for **RP2040-based boards such as RASPBERRY_PI_PICO**, using [**Earle Philhower's arduino-pico** core](https://github.com/earlephilhower/arduino-pico)
853+
2. More hardware-initiated software-enabled timers
854+
3. Longer time interval
855+
4. Add Version String
856+
5. Add Table of Contents
857+
6. Add support to new boards (**ADAFRUIT_ITSYBITSY_RP2040, ADAFRUIT_QTPY_RP2040, ADAFRUIT_STEMMAFRIEND_RP2040, ADAFRUIT_TRINKEYQT_RP2040, ADAFRUIT_MACROPAD_RP2040, SPARKFUN_PROMICRO_RP2040, Nano_RP2040_Connect, etc.**) using the arduino-pico core
858+
7. Fix `multiple-definitions` linker error
859+
8. Optimize library code by using `reference-passing` instead of `value-passing`
860+
9. Fix severe bug affecting time between the starts. Check [Enable fixed timing between timer calls (vs fixed time btw. end of timer call and next call as implemented) #3](https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/issues/3)
861+
10. Using `float` instead of `ulong` for better interval accuracy
862+
862863

863864
---
864865
---

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
## Table of Contents
1313

1414
* [Changelog](#changelog)
15+
* [Releases v1.3.1](#releases-v131)
1516
* [Releases v1.3.0](#releases-v130)
1617
* [Releases v1.2.0](#releases-v120)
1718
* [Releases v1.1.1](#releases-v111)
@@ -25,6 +26,10 @@
2526

2627
## Changelog
2728

29+
### Releases v1.3.1
30+
31+
1. Using `float` instead of `ulong` for better interval accuracy
32+
2833
### Releases v1.3.0
2934

3035
1. Fix severe bug affecting time between the starts. Check [Enable fixed timing between timer calls (vs fixed time btw. end of timer call and next call as implemented) #3](https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/issues/3)

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "RPI_PICO_TimerInterrupt",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"keywords": "timing, device, control, timer, interrupt, hardware, isr, isr-based, hardware-timer, mission-critical, accuracy, non-blocking, raspberry-pico, rpi-pico, pico, rp2040, arduino-pico, rp2040w, raspberry-pico-w, pico-w",
55
"description": "This library enables you to use Interrupt from Hardware Timers on RP2040-based boards such as RASPBERRY_PI_PICO. It now supports 16 ISR-based timers, while consuming only 1 Hardware Timer. Timers' interval is very long (ulong millisecs). The most important feature is they're ISR-based timers. Therefore, their executions are not blocked by bad-behaving functions or tasks. This important feature is absolutely necessary for mission-critical tasks. These hardware timers, using interrupt, still work even if other functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software timers using millis() or micros(). That's necessary if you need to measure some data requiring better accuracy.",
66
"authors":

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=RPI_PICO_TimerInterrupt
2-
version=1.3.0
2+
version=1.3.1
33
author=Khoi Hoang <khoih.prog@gmail.com>
44
maintainer=Khoi Hoang <khoih.prog@gmail.com>
55
sentence=This library enables you to use Interrupt from Hardware Timers on RP2040-based boards such as RASPBERRY_PI_PICO

src/RPi_Pico_ISR_Timer-Impl.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
Based on BlynkTimer.h
2626
Author: Volodymyr Shymanskyy
2727
28-
Version: 1.3.0
28+
Version: 1.3.1
2929
3030
Version Modified By Date Comments
3131
------- ----------- ---------- -----------
@@ -35,6 +35,7 @@
3535
1.1.1 K Hoang 22/10/2021 Fix platform in library.json for PIO
3636
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error
3737
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
38+
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
3839
*****************************************************************************************************************************/
3940

4041
#pragma once
@@ -170,7 +171,7 @@ int RPI_PICO_ISR_Timer::findFirstFreeSlot()
170171

171172
////////////////////////////////////////////////////////////////
172173

173-
int RPI_PICO_ISR_Timer::setupTimer(const unsigned long& d, void* f, void* p, bool h, const unsigned& n)
174+
int RPI_PICO_ISR_Timer::setupTimer(const float& d, void* f, void* p, bool h, const unsigned& n)
174175
{
175176
int freeTimer;
176177

@@ -205,49 +206,49 @@ int RPI_PICO_ISR_Timer::setupTimer(const unsigned long& d, void* f, void* p, boo
205206

206207
////////////////////////////////////////////////////////////////
207208

208-
int RPI_PICO_ISR_Timer::setTimer(const unsigned long& d, timer_callback f, const unsigned& n)
209+
int RPI_PICO_ISR_Timer::setTimer(const float& d, timer_callback f, const unsigned& n)
209210
{
210211
return setupTimer(d, (void *)f, NULL, false, n);
211212
}
212213

213214
////////////////////////////////////////////////////////////////
214215

215-
int RPI_PICO_ISR_Timer::setTimer(const unsigned long& d, timer_callback_p f, void* p, const unsigned& n)
216+
int RPI_PICO_ISR_Timer::setTimer(const float& d, timer_callback_p f, void* p, const unsigned& n)
216217
{
217218
return setupTimer(d, (void *)f, p, true, n);
218219
}
219220

220221
////////////////////////////////////////////////////////////////
221222

222-
int RPI_PICO_ISR_Timer::setInterval(const unsigned long& d, timer_callback f)
223+
int RPI_PICO_ISR_Timer::setInterval(const float& d, timer_callback f)
223224
{
224225
return setupTimer(d, (void *)f, NULL, false, RPI_PICO_RUN_FOREVER);
225226
}
226227

227228
////////////////////////////////////////////////////////////////
228229

229-
int RPI_PICO_ISR_Timer::setInterval(const unsigned long& d, timer_callback_p f, void* p)
230+
int RPI_PICO_ISR_Timer::setInterval(const float& d, timer_callback_p f, void* p)
230231
{
231232
return setupTimer(d, (void *)f, p, true, RPI_PICO_RUN_FOREVER);
232233
}
233234

234235
////////////////////////////////////////////////////////////////
235236

236-
int RPI_PICO_ISR_Timer::setTimeout(const unsigned long& d, timer_callback f)
237+
int RPI_PICO_ISR_Timer::setTimeout(const float& d, timer_callback f)
237238
{
238239
return setupTimer(d, (void *)f, NULL, false, RPI_PICO_RUN_ONCE);
239240
}
240241

241242
////////////////////////////////////////////////////////////////
242243

243-
int RPI_PICO_ISR_Timer::setTimeout(const unsigned long& d, timer_callback_p f, void* p)
244+
int RPI_PICO_ISR_Timer::setTimeout(const float& d, timer_callback_p f, void* p)
244245
{
245246
return setupTimer(d, (void *)f, p, true, RPI_PICO_RUN_ONCE);
246247
}
247248

248249
////////////////////////////////////////////////////////////////
249250

250-
bool RPI_PICO_ISR_Timer::changeInterval(const unsigned& numTimer, const unsigned long& d)
251+
bool RPI_PICO_ISR_Timer::changeInterval(const unsigned& numTimer, const float& d)
251252
{
252253
if (numTimer >= RPI_PICO_MAX_TIMERS)
253254
{

src/RPi_Pico_ISR_Timer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
Based on BlynkTimer.h
2626
Author: Volodymyr Shymanskyy
2727
28-
Version: 1.3.0
28+
Version: 1.3.1
2929
3030
Version Modified By Date Comments
3131
------- ----------- ---------- -----------
@@ -35,6 +35,7 @@
3535
1.1.1 K Hoang 22/10/2021 Fix platform in library.json for PIO
3636
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error
3737
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
38+
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
3839
*****************************************************************************************************************************/
3940

4041
#pragma once

0 commit comments

Comments
 (0)