Git Product home page Git Product logo

ticker's Introduction

Ticker

Build Status GitHub release License: Apache 2.0 Donate

Ticker is a helper library, which allows you to write non-blocking Arduino code without calls to delay().

There are two common ways, how to use the library. Let's say you want to trigger an event after five seconds:

#include <Ticker.h>

#define TRIGGER_PERIOD 5000 // milliseconds

// Create a ticker
jsc::Ticker ticker(TRIGGER_PERIOD);

void setup() {
    ...
}

void loop() {
    if (ticker.elapsedTicks() > 0) {
        // TODO: Trigger an event

        // Reset ticker
        ticker.restart();
    }
}

In another example, we want to trigger an event after five seconds, as in first case. However, Ticker will increment its counter after 10 milliseconds, which is a default value. To determine, whether a time period has elapsed, you need to divide overall time period by partial time periods. This value represents expected counter value. Let's see an example:

#include <Ticker.h>

// Create a ticker with a tick period of 10 ms
jsc::Ticker ticker();

void setup() {
    ...
}

void loop() {
	// Trigger an event after five seconds
    if (ticker.elapsedTicks() > (5000 / 10)) {
        // TODO: Trigger an event

        // Reset ticker
        ticker.restart();
    }
}

Documentation

Contributing

There are many ways in which you can participate in the project, for example:

Please read contributing rules for more details.

License

Copyright © 2020 JSC electronics. All rights reserved.

Licensed under the Apache-2.0 license.

Support

We hope our library helped to speed up your project development. You can support our effort to convert coffe and pizza into a code with a small donation. Any support is much appreciated.

paypal

ticker's People

Contributors

robert-faltus avatar vzahradnik 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.