Giter VIP home page Giter VIP logo

ptscheduler's Introduction

ptScheduler

Pretty tiny Scheduler

Pretty tiny Scheduler or ptScheduler is a non-preemptive task scheduler library for Arduino that helps you to write non-blocking periodic tasks easily and effectively without using ordinary delay routines or using millis() function on your own.

You won't have to use delay() or millis() functions again.

Under the hood, ptScheduler uses the native millis() implementation. The millis() function is a hardware timer based ISR that increments a global counter variable (unsigned integer) every millisecond.

When you create a new ptScheduler object, you can specify the time intervals and execution modes. All the class member variables and functions are public and therefore gives you full control over your tasks, allowing dynamically changing the behavior of the task.

To run a task, just enclose the call() function inside any conditional statements, either inside your infinite loop or inside a function. Every time you invoke the call() function, it checks if the elapsed time is larger than the preset interval. If yes, it will return true and cause the code under the conditional block to be executed once.

ptScheduler is good mainly for control applications that require the periodic polling of sensors, GPIOs and other IO devices. ptScheduler tasks can coexist with preemptive tasks such as FreeRTOS tasks.

Hello World

Here is the basic Hello World example.

#include "ptScheduler.h"

//create tasks
ptScheduler sayHello = ptScheduler(1000);

//setup function runs once
void setup() {
  Serial.begin(9600);
}

//infinite loop
void loop() {
  if (sayHello.call()) {  //executed every second
    Serial.println("Hello World");
  }

  //add other tasks and non-blocking code here
}

Tutorial and Documentation

Complete tutorial can be found at CIRCUITSTATE

Reference

See the reference of all available functions and variables in the Reference page.

ptscheduler's People

Contributors

vishnumaiea avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.