v1.3.1 using float for interval
### Releases v1.3.1 1. Using `float` instead of `ulong` for better interval accuracy
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
Based on BlynkTimer.h
|
||||
Author: Volodymyr Shymanskyy
|
||||
|
||||
Version: 1.3.0
|
||||
Version: 1.3.1
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@@ -35,6 +35,7 @@
|
||||
1.1.1 K Hoang 22/10/2021 Fix platform in library.json for PIO
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error
|
||||
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
|
||||
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@@ -170,7 +171,7 @@ int RPI_PICO_ISR_Timer::findFirstFreeSlot()
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int RPI_PICO_ISR_Timer::setupTimer(const unsigned long& d, void* f, void* p, bool h, const unsigned& n)
|
||||
int RPI_PICO_ISR_Timer::setupTimer(const float& d, void* f, void* p, bool h, const unsigned& n)
|
||||
{
|
||||
int freeTimer;
|
||||
|
||||
@@ -205,49 +206,49 @@ int RPI_PICO_ISR_Timer::setupTimer(const unsigned long& d, void* f, void* p, boo
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int RPI_PICO_ISR_Timer::setTimer(const unsigned long& d, timer_callback f, const unsigned& n)
|
||||
int RPI_PICO_ISR_Timer::setTimer(const float& d, timer_callback f, const unsigned& n)
|
||||
{
|
||||
return setupTimer(d, (void *)f, NULL, false, n);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int RPI_PICO_ISR_Timer::setTimer(const unsigned long& d, timer_callback_p f, void* p, const unsigned& n)
|
||||
int RPI_PICO_ISR_Timer::setTimer(const float& d, timer_callback_p f, void* p, const unsigned& n)
|
||||
{
|
||||
return setupTimer(d, (void *)f, p, true, n);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int RPI_PICO_ISR_Timer::setInterval(const unsigned long& d, timer_callback f)
|
||||
int RPI_PICO_ISR_Timer::setInterval(const float& d, timer_callback f)
|
||||
{
|
||||
return setupTimer(d, (void *)f, NULL, false, RPI_PICO_RUN_FOREVER);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int RPI_PICO_ISR_Timer::setInterval(const unsigned long& d, timer_callback_p f, void* p)
|
||||
int RPI_PICO_ISR_Timer::setInterval(const float& d, timer_callback_p f, void* p)
|
||||
{
|
||||
return setupTimer(d, (void *)f, p, true, RPI_PICO_RUN_FOREVER);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int RPI_PICO_ISR_Timer::setTimeout(const unsigned long& d, timer_callback f)
|
||||
int RPI_PICO_ISR_Timer::setTimeout(const float& d, timer_callback f)
|
||||
{
|
||||
return setupTimer(d, (void *)f, NULL, false, RPI_PICO_RUN_ONCE);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int RPI_PICO_ISR_Timer::setTimeout(const unsigned long& d, timer_callback_p f, void* p)
|
||||
int RPI_PICO_ISR_Timer::setTimeout(const float& d, timer_callback_p f, void* p)
|
||||
{
|
||||
return setupTimer(d, (void *)f, p, true, RPI_PICO_RUN_ONCE);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
bool RPI_PICO_ISR_Timer::changeInterval(const unsigned& numTimer, const unsigned long& d)
|
||||
bool RPI_PICO_ISR_Timer::changeInterval(const unsigned& numTimer, const float& d)
|
||||
{
|
||||
if (numTimer >= RPI_PICO_MAX_TIMERS)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
Based on BlynkTimer.h
|
||||
Author: Volodymyr Shymanskyy
|
||||
|
||||
Version: 1.3.0
|
||||
Version: 1.3.1
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@@ -35,6 +35,7 @@
|
||||
1.1.1 K Hoang 22/10/2021 Fix platform in library.json for PIO
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error
|
||||
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
|
||||
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
+14
-13
@@ -25,7 +25,7 @@
|
||||
Based on BlynkTimer.h
|
||||
Author: Volodymyr Shymanskyy
|
||||
|
||||
Version: 1.3.0
|
||||
Version: 1.3.1
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@@ -35,6 +35,7 @@
|
||||
1.1.1 K Hoang 22/10/2021 Fix platform in library.json for PIO
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error
|
||||
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
|
||||
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@@ -56,13 +57,13 @@
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef RPI_PICO_TIMER_INTERRUPT_VERSION
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION "RPi_Pico_TimerInterrupt v1.3.0"
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION "RPi_Pico_TimerInterrupt v1.3.1"
|
||||
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_MAJOR 1
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_MINOR 3
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_PATCH 0
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_PATCH 1
|
||||
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_INT 1003000
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_INT 1003001
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
@@ -111,35 +112,35 @@ class RPI_PICO_ISR_Timer
|
||||
// Timer will call function 'f' every 'd' milliseconds forever
|
||||
// returns the timer number (numTimer) on success or
|
||||
// -1 on failure (f == NULL) or no free timers
|
||||
int setInterval(const unsigned long& d, timer_callback f);
|
||||
int setInterval(const float& d, timer_callback f);
|
||||
|
||||
// Timer will call function 'f' with parameter 'p' every 'd' milliseconds forever
|
||||
// returns the timer number (numTimer) on success or
|
||||
// -1 on failure (f == NULL) or no free timers
|
||||
int setInterval(const unsigned long& d, timer_callback_p f, void* p);
|
||||
int setInterval(const float& d, timer_callback_p f, void* p);
|
||||
|
||||
// Timer will call function 'f' after 'd' milliseconds one time
|
||||
// returns the timer number (numTimer) on success or
|
||||
// -1 on failure (f == NULL) or no free timers
|
||||
int setTimeout(const unsigned long& d, timer_callback f);
|
||||
int setTimeout(const float& d, timer_callback f);
|
||||
|
||||
// Timer will call function 'f' with parameter 'p' after 'd' milliseconds one time
|
||||
// returns the timer number (numTimer) on success or
|
||||
// -1 on failure (f == NULL) or no free timers
|
||||
int setTimeout(const unsigned long& d, timer_callback_p f, void* p);
|
||||
int setTimeout(const float& d, timer_callback_p f, void* p);
|
||||
|
||||
// Timer will call function 'f' every 'd' milliseconds 'n' times
|
||||
// returns the timer number (numTimer) on success or
|
||||
// -1 on failure (f == NULL) or no free timers
|
||||
int setTimer(const unsigned long& d, timer_callback f, const unsigned& n);
|
||||
int setTimer(const float& d, timer_callback f, const unsigned& n);
|
||||
|
||||
// Timer will call function 'f' with parameter 'p' every 'd' milliseconds 'n' times
|
||||
// returns the timer number (numTimer) on success or
|
||||
// -1 on failure (f == NULL) or no free timers
|
||||
int setTimer(const unsigned long& d, timer_callback_p f, void* p, const unsigned& n);
|
||||
int setTimer(const float& d, timer_callback_p f, void* p, const unsigned& n);
|
||||
|
||||
// updates interval of the specified timer
|
||||
bool changeInterval(const unsigned& numTimer, const unsigned long& d);
|
||||
bool changeInterval(const unsigned& numTimer, const float& d);
|
||||
|
||||
// destroy the specified timer
|
||||
void deleteTimer(const unsigned& numTimer);
|
||||
@@ -183,7 +184,7 @@ class RPI_PICO_ISR_Timer
|
||||
// low level function to initialize and enable a new timer
|
||||
// returns the timer number (numTimer) on success or
|
||||
// -1 on failure (f == NULL) or no free timers
|
||||
int setupTimer(const unsigned long& d, void* f, void* p, bool h, const unsigned& n);
|
||||
int setupTimer(const float& d, void* f, void* p, bool h, const unsigned& n);
|
||||
|
||||
// find the first available slot
|
||||
int findFirstFreeSlot();
|
||||
@@ -194,7 +195,7 @@ class RPI_PICO_ISR_Timer
|
||||
void* callback; // pointer to the callback function
|
||||
void* param; // function parameter
|
||||
bool hasParam; // true if callback takes a parameter
|
||||
unsigned long delay; // delay value
|
||||
float delay; // delay value
|
||||
unsigned maxNumRuns; // number of runs to be executed
|
||||
unsigned numRuns; // number of executed runs
|
||||
bool enabled; // true if enabled
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
Based on BlynkTimer.h
|
||||
Author: Volodymyr Shymanskyy
|
||||
|
||||
Version: 1.3.0
|
||||
Version: 1.3.1
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@@ -36,6 +36,7 @@
|
||||
1.1.1 K Hoang 22/10/2021 Fix platform in library.json for PIO
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error
|
||||
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
|
||||
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@@ -55,13 +56,13 @@
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef RPI_PICO_TIMER_INTERRUPT_VERSION
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION "RPi_Pico_TimerInterrupt v1.3.0"
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION "RPi_Pico_TimerInterrupt v1.3.1"
|
||||
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_MAJOR 1
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_MINOR 3
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_PATCH 0
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_PATCH 1
|
||||
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_INT 1003000
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_INT 1003001
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
@@ -182,7 +183,7 @@ class RPI_PICO_TimerInterrupt
|
||||
|
||||
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
|
||||
// No params and duration now. To be added in the future by adding similar functions here
|
||||
bool setInterval(const unsigned long& interval, pico_timer_callback callback)
|
||||
bool setInterval(const float& interval, pico_timer_callback callback)
|
||||
{
|
||||
return setFrequency((float) (1000000.0f / interval), callback);
|
||||
}
|
||||
@@ -198,7 +199,7 @@ class RPI_PICO_TimerInterrupt
|
||||
|
||||
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
|
||||
// No params and duration now. To be added in the future by adding similar functions here
|
||||
bool attachInterruptInterval(const unsigned long& interval, pico_timer_callback callback)
|
||||
bool attachInterruptInterval(const float& interval, pico_timer_callback callback)
|
||||
{
|
||||
return setFrequency( (float) ( 1000000.0f / interval), callback);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
Based on BlynkTimer.h
|
||||
Author: Volodymyr Shymanskyy
|
||||
|
||||
Version: 1.3.0
|
||||
Version: 1.3.1
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@@ -35,6 +35,7 @@
|
||||
1.1.1 K Hoang 22/10/2021 Fix platform in library.json for PIO
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error
|
||||
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
|
||||
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
Reference in New Issue
Block a user