void Light::blink(unsigned long on_time, unsigned long off_time, int times) { _forever = false; _on_timer.setTimeout(on_time); _off_timer.setTimeout(off_time); _times = times; _stopEverything(); _startBlinking(); }
void Light::setBrightness(int value, bool _stop_everything) { if(_stop_everything) { _stopEverything(); } if(_pwm_value != value) { _pwm_value = constrain(value, 0, 255); analogWrite(_pin, _pwm_value); } }
void Light::fade(unsigned long up_time, unsigned long on_time, unsigned long down_time, unsigned long off_time, int times) { _forever = false; _up_timer.setTimeout(up_time); _on_timer.setTimeout(on_time); _down_timer.setTimeout(down_time); _off_timer.setTimeout(off_time); _times = times; _stopEverything(); _startFading(); }
void Motor::ramp(int value, unsigned long timeout) { _stopEverything(); _start_speed = getSpeed(); _target_speed = value; if(_speedShouldChange()) { _timer.setTimeout(timeout); _timer.restart(); _startRamping(); } else { _stopRamping(); } }
void Motor::setSpeed(int value, bool _stop_everything) { // default: true if(value > -1 && value < 256) { if(_stop_everything) { _stopEverything(); } else { _stop_events = false; } if(_speed != value) { _speed = value; analogWrite(_pwm_pin, _speed); } } }
void Motor::timedOn(unsigned long timeout) { _stopEverything(); _startTimedOn(); _timer.setTimeout(timeout); _timer.restart(); }