Skip to content

Commit

Permalink
Fix variable inconsistencies, Closes #9
Browse files Browse the repository at this point in the history
  • Loading branch information
Aasim-A committed Dec 19, 2021
1 parent 432c33b commit ba34024
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.vscode
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "AsyncTimer",
"version": "2.1.2",
"version": "2.1.3",
"description": "JavaScript-like async timing functions (setTimeout, setInterval).",
"keywords": [
"settimeout",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=AsyncTimer
version=2.1.2
version=2.1.3
author=Aasim-A
maintainer=Aasim-A <github.com/Aasim-A>
sentence=JavaScript-like async timing functions (setTimeout, setInterval).
Expand Down
10 changes: 5 additions & 5 deletions src/AsyncTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ unsigned short AsyncTimer::setInterval(void (*callback)(), unsigned long ms) {
}

void AsyncTimer::changeDelay(unsigned short id, unsigned long ms) {
for (short i = 0; i < m_maxArrayLength; i++)
for (unsigned short i = 0; i < m_maxArrayLength; i++)
if (m_callsArray[i].id == id)
m_callsArray[i].delayByMs = ms;
}

void AsyncTimer::delay(unsigned short id, unsigned long ms) {
for (short i = 0; i < m_maxArrayLength; i++)
for (unsigned short i = 0; i < m_maxArrayLength; i++)
if (m_callsArray[i].id == id)
m_callsArray[i].timestamp += ms;
}

void AsyncTimer::reset(unsigned short id) {
for (short i = 0; i < m_maxArrayLength; i++)
for (unsigned short i = 0; i < m_maxArrayLength; i++)
if (m_callsArray[i].id == id)
m_callsArray[i].timestamp = millis();
}

void AsyncTimer::cancel(unsigned short id) {
for (short i = 0; i < m_maxArrayLength; i++) {
for (unsigned short i = 0; i < m_maxArrayLength; i++) {
if (m_callsArray[i].id == id && m_callsArray[i].active) {
m_callsArray[i].active = false;
m_arrayLength--;
Expand All @@ -62,7 +62,7 @@ void AsyncTimer::handle() {
if (m_arrayLength == 0)
return;

for (short i = 0; i < m_maxArrayLength; i++) {
for (unsigned short i = 0; i < m_maxArrayLength; i++) {
unsigned long timestamp = millis();
if (!m_callsArray[i].active || m_callsArray[i].timestamp > timestamp)
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/AsyncTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class AsyncTimer {
m_callsArray = new m_TimerInfo[arrayLength];
m_availableIndicesLength = arrayLength;
m_availableIndices = new unsigned short[arrayLength];
for (short i = 0; i < m_availableIndicesLength; i++)
for (unsigned short i = 0; i < m_availableIndicesLength; i++)
m_availableIndices[i] = i;
}
~AsyncTimer() {
Expand Down

0 comments on commit ba34024

Please sign in to comment.