add gain=2, non-blocking operation, led abstracted
This commit is contained in:
32
led.h
Normal file
32
led.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef _LED_H_
|
||||
#define _LED_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class LED {
|
||||
public:
|
||||
LED() : m_state(0) {};
|
||||
void begin(const uint8_t pin) {
|
||||
m_pin = pin;
|
||||
pinMode(m_pin, OUTPUT);
|
||||
digitalWrite(m_pin, m_state);
|
||||
};
|
||||
void on() {
|
||||
m_state = 1;
|
||||
digitalWrite(m_pin, m_state);
|
||||
}
|
||||
void off() {
|
||||
m_state = 0;
|
||||
digitalWrite(m_pin, m_state);
|
||||
}
|
||||
void toggle() {
|
||||
m_state ^= 1;
|
||||
digitalWrite(m_pin, m_state);
|
||||
}
|
||||
private:
|
||||
uint8_t m_state;
|
||||
uint8_t m_pin;
|
||||
}
|
||||
|
||||
#endif // _LED_H_
|
Reference in New Issue
Block a user