Skip to content

Commit

Permalink
* v 2.2.0 all methods made 'inline' to support inclusion of TaskSched…
Browse files Browse the repository at this point in the history
…ule.h file into other header files
  • Loading branch information
arkhipenko committed Nov 18, 2016
1 parent 133a651 commit 59bff57
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 32 deletions.
7 changes: 6 additions & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ Redistribution and use in source and binary forms, with or without modification,

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 changes: 23 additions & 4 deletions README
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Task Scheduler – cooperative multitasking for Arduino microcontrollers
Version 2.1.0: 2016-02-01
Version 2.2.0: 2016-11-17

If you find TaskScheduler useful for your Arduino project, please drop me an email: [email protected]
----------------------------------------------------------------------------------------------------------
Expand All @@ -23,33 +23,52 @@ For detailed functionality overview please refer to TaskScheduler documentation

Check out what TaskScheduler can do:
====================================
Endeavor - build a space capable craft, with the ability to maneuver both in and out of atmosphere.
(by Radical Space Technologies
http://radicalspacetechnologies.com/2015/10/01/endeavor-phase-i/

"So after some digging I found TaskScheduler an awesome little library developed by Anatoli Arkhipenko,
his github is here and the documentation is here. Its fantastic, so far I’ve been able to replicate
some things I’ve seen in Ardupilot. ..."
link: http://radicalspacetechnologies.com/2015/10/25/endeavors-code-definitely-progress/


3 Devo - Quality 3D printing filament, now made accessible and affordable
http://3devo.eu/


Houston midi clock project - TaskScheduler with microseconds resolution
(by chaffneue: My first arduino project. It's a multi-master midi controller with a shared clock and
auto count in behaviour. Project files on github: https://github.com/chaffneue/houston
youtube: https://www.youtube.com/watch?v=QRof550TtXo)


Aurora Chaser Cubesat project, University of Sydney (Yay! TaskScheduler goes to space)
(by Jordan Jolly: http://52.35.220.33/blogs/jordan-jolly-cubesat--aero3670--blog)

Hackabot Nano - Compact Plug and Play Arduino compatible robotic kit
(by Funnyvale: http://hackarobot.com/
also: https://www.kickstarter.com/projects/hackarobot/hackabot-nano-compact-plug-and-play-arduino-robot)


Arduino Nano based Hexbug Scarab Robotic Spider
(by arkhipenko: http://www.instructables.com/id/Arduino-Nano-based-Hexbug-Scarab-Robotic-Spider/)


Wave your hand to control OWI Robotic Arm... no strings attached
(by arkhipenko: http://www.instructables.com/id/Wave-your-hand-to-control-OWI-Robotic-Arm-no-strin/)


APIS - Automated Plant Irrigation System
(by arkhipenko: http://www.instructables.com/id/APIS-Automated-Plant-Irrigation-System/)


Interactive Halloween Pumpkin
(by arkhipenko: http://www.instructables.com/id/Interactive-Halloween-Pumpkin/)


Changelog:
=========
v2.2.0:
2016-11-17 - all methods made 'inline' to support inclusion of TaskSchedule.h file into other header files

v2.1.0:
2016-02-01 - support for microsecond resolution
2016-02-02 - added Scheduler baseline start time reset method: startNow()
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=TaskScheduler
version=2.1.0
version=2.2.0
author=Anatoli Arkhipenko <[email protected]>
maintainer=Anatoli Arkhipenko <[email protected]>
sentence=A light-weight cooperative multitasking library for arduino microcontrollers.
Expand Down
55 changes: 29 additions & 26 deletions src/TaskScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
// v2.1.0:
// 2016-02-01 - support for microsecond resolution
// 2016-02-02 - added Scheduler baseline start time reset method: startNow()
//
// v2.2.0:
// 2016-11-17 - all methods made 'inline' to support inclusion of TaskSchedule.h file into other header files

#include <Arduino.h>

Expand Down Expand Up @@ -164,15 +167,15 @@ class StatusRequest {
public:
StatusRequest() {iCount = 0; iStatus = 0; }
inline void setWaiting(unsigned int aCount = 1) { iCount = aCount; iStatus = 0; }
bool signal(int aStatus = 0);
void signalComplete(int aStatus = 0);
inline bool signal(int aStatus = 0);
inline void signalComplete(int aStatus = 0);
inline bool pending() { return (iCount != 0); }
inline bool completed() { return (iCount == 0); }
inline int getStatus() { return iStatus; }

private:
unsigned int iCount; // number of statuses to wait for. waiting for more that 65000 events seems unreasonable: unsigned int should be sufficient
int iStatus; // status of the last completed request. negative = error; zero = OK; >positive = OK with a specific status
int iStatus; // status of the last completed request. negative = error; zero = OK; >positive = OK with a specific status
};
#endif // _TASK_STATUS_REQUEST

Expand Down Expand Up @@ -200,19 +203,19 @@ class Task {
Task(void (*aCallback)()=NULL, Scheduler* aScheduler=NULL, bool (*aOnEnable)()=NULL, void (*aOnDisable)()=NULL);
#endif // _TASK_STATUS_REQUEST

void enable();
bool enableIfNot();
void enableDelayed(unsigned long aDelay=0);
void delay(unsigned long aDelay=0);
void forceNextIteration();
void restart();
void restartDelayed(unsigned long aDelay=0);
bool disable();
inline void enable();
inline bool enableIfNot();
inline void enableDelayed(unsigned long aDelay=0);
inline void delay(unsigned long aDelay=0);
inline void forceNextIteration();
inline void restart();
inline void restartDelayed(unsigned long aDelay=0);
inline bool disable();
inline bool isEnabled() { return iStatus.enabled; }
void set(unsigned long aInterval, long aIterations, void (*aCallback)(),bool (*aOnEnable)()=NULL, void (*aOnDisable)()=NULL);
void setInterval(unsigned long aInterval);
inline void set(unsigned long aInterval, long aIterations, void (*aCallback)(),bool (*aOnEnable)()=NULL, void (*aOnDisable)()=NULL);
inline void setInterval(unsigned long aInterval);
inline unsigned long getInterval() { return iInterval; }
void setIterations(long aIterations);
inline void setIterations(long aIterations);
inline long getIterations() { return iIterations; }
inline unsigned long getRunCounter() { return iRunCounter; }
inline void setCallback(void (*aCallback)()) { iCallback = aCallback; }
Expand All @@ -225,8 +228,8 @@ class Task {
inline bool isFirstIteration() { return (iRunCounter <= 1); }
inline bool isLastIteration() { return (iIterations == 0); }
#ifdef _TASK_STATUS_REQUEST
void waitFor(StatusRequest* aStatusRequest, unsigned long aInterval = 0, long aIterations = 1);
void waitForDelayed(StatusRequest* aStatusRequest, unsigned long aInterval = 0, long aIterations = 1);
inline void waitFor(StatusRequest* aStatusRequest, unsigned long aInterval = 0, long aIterations = 1);
inline void waitForDelayed(StatusRequest* aStatusRequest, unsigned long aInterval = 0, long aIterations = 1);
inline StatusRequest* getStatusRequest() {return iStatusRequest; }
#endif // _TASK_STATUS_REQUEST
#ifdef _TASK_WDT_IDS
Expand All @@ -241,7 +244,7 @@ class Task {
#endif // _TASK_LTS_POINTER

private:
void reset();
inline void reset();

volatile __task_status iStatus;
volatile unsigned long iInterval; // execution interval in milliseconds (or microseconds). 0 - immediate
Expand Down Expand Up @@ -280,16 +283,16 @@ class Scheduler {
friend class Task;
public:
Scheduler();
void init();
void addTask(Task& aTask);
void deleteTask(Task& aTask);
void disableAll(bool aRecursive = true);
void enableAll(bool aRecursive = true);
bool execute(); // Returns true if at none of the tasks' callback methods was invoked (true if idle run)
void startNow(bool aRecursive = true); // reset ALL active tasks to immediate execution NOW.
inline void init();
inline void addTask(Task& aTask);
inline void deleteTask(Task& aTask);
inline void disableAll(bool aRecursive = true);
inline void enableAll(bool aRecursive = true);
inline bool execute(); // Returns true if at none of the tasks' callback methods was invoked (true if idle run)
inline void startNow(bool aRecursive = true); // reset ALL active tasks to immediate execution NOW.
inline Task& currentTask() {return *iCurrent; }
#ifdef _TASK_SLEEP_ON_IDLE_RUN
void allowSleep(bool aState = true);
inline void allowSleep(bool aState = true);
#endif // _TASK_SLEEP_ON_IDLE_RUN
#ifdef _TASK_LTS_POINTER
inline void* currentLts() {return iCurrent->iLTS; }
Expand All @@ -298,7 +301,7 @@ class Scheduler {
inline bool isOverrun() { return (iCurrent->iOverrun < 0); }
#endif // _TASK_TIMECRITICAL
#ifdef _TASK_PRIORITY
void setHighPriorityScheduler(Scheduler* aScheduler);
inline void setHighPriorityScheduler(Scheduler* aScheduler);
static Scheduler& currentScheduler() { return *(iCurrentScheduler); };
#endif // _TASK_PRIORITY

Expand Down

0 comments on commit 59bff57

Please sign in to comment.