vishnumaiea / ptscheduler Goto Github PK
View Code? Open in Web Editor NEWPretty tiny Scheduler or ptScheduler is an Arduino library for writing non-blocking periodic tasks easily.
License: MIT License
Pretty tiny Scheduler or ptScheduler is an Arduino library for writing non-blocking periodic tasks easily.
License: MIT License
Firstly, love ptScheduler !!
I'm sending messages over serial between two Arduinos on the same schedule (say 100ms) but would like to ensure they don't all fire at the same time in a 'feast and famine' style which is hard on my receiver device.
How can I introduce a one time offset when my scheduler objects are created or similar so that i spread the load but maintain the timing of tasks ? ie: Two tasks scheduled at 100ms with a 50ms offset would result in alternating tasks triggering every 50ms.
Cheers !!
When the sequence repetition is set to 1 with the help of setSequenceRepetition()
function, the task run indefinitely. The correct behavior should be the should stop after executing the sequence only once.
I'm working on an automotive project and would like to alter the frequency of my ptScheduler task (ptCalculateRpm) based on engine RPM. When I implement this as shown below the Arduino goes into a reset loop ... something is not happy.
Is this an edge case anti-pattern or am I missing something ?
The definition of the object is:
ptScheduler ptCalculateRpm = ptScheduler(PT_TIME_200MS);
The code that contains my desires is:
if (ptCalculateRpm.call()) {
detachInterrupt(digitalPinToInterrupt(rpmSignalPin));
currentRpm = calculateRpm();
attachInterrupt(digitalPinToInterrupt(rpmSignalPin), updateRpmPulse, RISING);
// Change frequency of rpm calculation depending on RPM to avoid high error
if (currentRpm > 1500) {
ptCalculateRpm = ptScheduler(PT_TIME_50MS);
} else {
ptCalculateRpm = ptScheduler(PT_TIME_200MS);
}
}
ptScheduler/src/ptScheduler.cpp
Line 261 in 0e61517
The issue is obvious on this line. skipIntervalSet
appears twice in the conditional statement.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.