initial
This commit is contained in:
60
hardware.h
Normal file
60
hardware.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* hardware.h
|
||||
*
|
||||
* Created on: 27.05.2015
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#ifndef HARDWARE_H_
|
||||
#define HARDWARE_H_
|
||||
|
||||
|
||||
const uint8_t NUM_OF_LINES = 4;
|
||||
|
||||
const uint8_t FEEDBACK_PIN[NUM_OF_LINES] = { 22, 23, 24, 25 };
|
||||
const uint8_t BUTTON_PIN[NUM_OF_LINES] = { 30, 31, 32, 33 };
|
||||
const uint8_t RELAY_PIN[NUM_OF_LINES] = { 38, 39, 40, 41 };
|
||||
const uint8_t LED_PIN[NUM_OF_LINES] = { 46, 47, 48, 49 };
|
||||
|
||||
const uint32_t BUTTON_TIME = 1000;
|
||||
const uint32_t BUTTON_COOL_TIME = 5000;
|
||||
const uint32_t BLINK_TIME = 100;
|
||||
|
||||
class Switch {
|
||||
public:
|
||||
Switch();
|
||||
void begin(const uint8_t feedbackPin, const uint8_t buttonPin, const uint8_t relayPin, const uint8_t ledPin);
|
||||
void exec();
|
||||
void toggle();
|
||||
void on();
|
||||
void off();
|
||||
bool getState() const { return m_state; };
|
||||
bool getFeedback() const { return m_feedbackState; };
|
||||
bool getStateConflict() const { return m_stateConflict; };
|
||||
private:
|
||||
uint8_t m_feedbackPin;
|
||||
uint8_t m_buttonPin;
|
||||
uint8_t m_relayPin;
|
||||
uint8_t m_ledPin;
|
||||
|
||||
bool m_state;
|
||||
bool m_feedbackState;
|
||||
bool m_stateConflict;
|
||||
|
||||
bool m_lastButtonState;
|
||||
uint8_t m_buttonEngineState;
|
||||
uint32_t m_buttonTimestamp;
|
||||
|
||||
uint8_t m_ledEngineState;
|
||||
bool m_ledState;
|
||||
uint32_t m_ledTimestamp;
|
||||
|
||||
|
||||
|
||||
|
||||
void action();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* HARDWARE_H_ */
|
Reference in New Issue
Block a user