Enhancement proposal
Opened this issue · 4 comments
Hi,
I'm using your great timer to run a steppermotor (non-blocking) with the esp8266 like:
if (motorTimer.repeat (steps, speed)) {
stepMotorCW();
}
I need however to know whether the repeat is still running and I need to be able to stop the repeat when a limitswitch is reached. I therefor propose 2 more methods to add. You'll find them below.
Kind regards, Ed
boolean repeatRunning();
void repeatStop();
/*
- Checks whether the repeat timer is still running
- Useful to do something during or not during the total repeat period
- Usage:
- if(!timer.repeatRunning()){
- stop blinking that LED or running that motor
- }
*/
boolean Neotimer::repeatRunning(){
if(this->_times > 0){
return true;
}
return false;
}
/*
- Stops a running repeat timer
- Useful to act on a limitswitch or reached condition
- Usage:
- timer.repeatStop()){
*/
void Neotimer::repeatStop(){
this->_times = 0;
}
good library, could insert an option to use different drive intervals in the example repeat; 2000 LED ON, 4000 LED OFF
good library, could insert an option to use different drive intervals in the example repeat; 2000 LED ON, 4000 LED OFF
yeah, i hope too Jrullan
Hi,
I'm using your great timer to run a steppermotor (non-blocking) with the esp8266 like:
if (motorTimer.repeat (steps, speed)) {
stepMotorCW();
}
I need however to know whether the repeat is still running and I need to be able to stop the repeat when a limitswitch is reached. I therefor propose 2 more methods to add. You'll find them below.Kind regards, Ed
boolean repeatRunning(); void repeatStop();
/*
- Checks whether the repeat timer is still running
- Useful to do something during or not during the total repeat period
- Usage:
- if(!timer.repeatRunning()){
- stop blinking that LED or running that motor
- }
*/
boolean Neotimer::repeatRunning(){
if(this->_times > 0){
return true;
}
return false;
}/*
- Stops a running repeat timer
- Useful to act on a limitswitch or reached condition
- Usage:
- timer.repeatStop()){
*/
void Neotimer::repeatStop(){
this->_times = 0;
}
Hi Bro!
i have found new Logical code for start blinking and stop blinking whitin neotimer...
this is my logical sketch code:
#include <neotimer.h>
Neotimer WAOW = Neotimer(1000) ;
const int p = A0;
const int led = 13;
bool p1 = false;
bool p2 = false;
bool p3 = false;
int btn;
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
}
void loop() {
btn = digitalRead(p);
if ((btn == 0) && (p1 == false)) {
p1 = true;
p2 =! p2;
p3 = true;
digitalWrite(led, 1);
}else if (btn == 1){
p1 = false;
}
if (p2 == true){
RUN();
} else {
p3 = false;
digitalWrite(led, 0);
WAOW.stop();
}
Serial.print(p1);
Serial.print("\t");
Serial.print(p2);
Serial.print("\t");
Serial.print(p3);
Serial.print("\t");
Serial.println(digitalRead(led));
}
void RUN(){
if (p3 == true){
WAOW.start();
p3 = false;
}
if(WAOW.done()){
digitalWrite(led, !digitalRead(led));
p3 = true;
}
}
// this sketch is created by aoicomputers [Sep, 26 2018 - 13.45 WIB]
good library, could insert an option to use different drive intervals in the example repeat; 2000 LED ON, 4000 LED OFF
if you want, i can help you for diffrent intervals repeat..
i have found that logic too, within neotimer