59 lines
1.0 KiB
C++
59 lines
1.0 KiB
C++
#ifndef DOUGH_LED_H
|
|
#define DOUGH_LED_H
|
|
|
|
// Delay times for blinking, flashing and dipping.
|
|
#define LED_TRANSITION_TIME_SLOW 400
|
|
#define LED_TRANSITION_TIME_DEFAULT 250
|
|
#define LED_TRANSITION_TIME_FAST 100
|
|
|
|
#include <Arduino.h>
|
|
|
|
typedef enum
|
|
{
|
|
ON,
|
|
OFF,
|
|
BLINK_ON,
|
|
BLINK_OFF,
|
|
FLASH,
|
|
DIP,
|
|
PULSE
|
|
} DoughLEDState;
|
|
|
|
/**
|
|
* This class provides a set of basic LED lighting patterns, which can
|
|
* be used in an async way.
|
|
*/
|
|
class DoughLED
|
|
{
|
|
public:
|
|
DoughLED(int pin);
|
|
void setup();
|
|
void loop();
|
|
void on();
|
|
void off();
|
|
DoughLED *blink();
|
|
DoughLED *blink(int onStep, int ofSteps);
|
|
DoughLED *flash();
|
|
DoughLED *dip();
|
|
void pulse();
|
|
void slow();
|
|
void fast();
|
|
bool isOn();
|
|
bool isOff();
|
|
|
|
private:
|
|
int _pin;
|
|
int _pinState = LOW;
|
|
DoughLEDState _state = OFF;
|
|
void _setPin(int high_or_low);
|
|
unsigned long _timer;
|
|
unsigned int _time;
|
|
int _blinkOnStep;
|
|
int _blinkOfSteps;
|
|
int _blinkStep;
|
|
int _brightness;
|
|
int _pulseStep;
|
|
};
|
|
|
|
#endif
|