Comments (7)
Can you explain more about what your are seeing?
from esp8266scheduler.
void foo()
{
delay(10 * 1000); // does not call Task::delay
}
class Foo : public Task {
virtual void loop() final
{
foo();
}
}s_fooTask;
In this code the daly in foo() will not call Task::delay which results in all other tasks being suspended for 10 seconds
from esp8266scheduler.
It would not call Task::delay
as it is not in the task. It is an external method, as therefore would use the external delay. It has no reference to the task.
from esp8266scheduler.
Yeah but thats kinda problematic if you can only call subroutines inside the Task the whole longjmp solution becomes kinda redundant
from esp8266scheduler.
What your proposed solution here?
I tend to disagree with your argument though. Expecting delay
in an external function to suddenly call the Task::delay
would be weird and wrong. The idea is for the each Task
to contain its own logic, hence it has its own setup
and loop
functions. It is meant to be a contained unit.
An example of perhaps what you are perhaps trying to do is as follows:
#ifndef LIGHT_H
#define LIGHT_H
#include <Arduino.h>
#include <Task.h>
#define LIGHT_STATE_ON 930
#define LIGHT_STATE_OFF 0
class Light : public Task {
public:
Light(uint8_t pin) : pin(pin), goal(0), state(0), steps(0), stepDelay(0) {}
void setup() {
pinMode(pin, OUTPUT);
analogWrite(pin, state);
}
void loop() {
int16_t state = state + ((goal - state) / steps);
analogWrite(pin, state);
if (state == goal) {
steps = 0;
return;
}
steps--;
if (steps > 0) {
delay(stepDelay);
}
}
bool shouldRun() {
bool run = Task::shouldRun();
return run && steps > 0;
}
void set(uint16_t goal) {
this->goal = goal;
this->steps = 0;
this->stepDelay = 0;
}
void set(uint16_t goal, uint16_t steps, uint16_t delay) {
this->goal = goal;
this->steps = steps;
this->stepDelay = delay;
}
protected:
uint8_t pin;
uint16_t goal;
uint16_t state;
uint16_t steps;
uint16_t stepDelay;
};
#endif
Does that help perhaps?
from esp8266scheduler.
No that does not help with my case. I have to call external code that calls delay and wanted to run other stuff during that time. Hence the whish for delay to work from any function. I guess I will have to write something myself or try to get this scheduler running
from esp8266scheduler.
Fair enough. Good luck.
from esp8266scheduler.
Related Issues (20)
- Doesnt work if use function => while (Client.connected()) HOT 8
- No removing/stoping task HOT 3
- Problems with: while(WiFiMulti.run() != WL_CONNECTED){} HOT 11
- Overloading loop() HOT 8
- Arduino compatibility HOT 2
- Any online request causing delay on the main loop HOT 5
- Example using delay or yield in class instantiated in task HOT 7
- Removal of main Task to save ram HOT 1
- Allow for an extra "free" task HOT 8
- How can I stop the Task? HOT 1
- Add Scheduler.Stop(); HOT 1
- Documentation has a "typo" HOT 1
- Scheduler v0.1.0 incompatible with ESP8266-core-3.0.0 HOT 7
- Can't work with UniversalTelegramBot lib HOT 1
- non-blocking delay in non-member function HOT 4
- Calling yield and delay outside of tasks HOT 1
- Using ESP8266Scheduler to make HTTPS requests without blocking loop(). HOT 2
- cont_yield with ESP8266 Release 3.1.0 HOT 4
- cont_suspend was not declared in this scope HOT 3
- Build Issue with PlatformIO HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp8266scheduler.