63 lines
1.3 KiB
C++
63 lines
1.3 KiB
C++
/*
|
|
* hardware.h
|
|
*
|
|
* Created on: 27.05.2015
|
|
* Author: wn
|
|
*/
|
|
|
|
#ifndef HARDWARE_H_
|
|
#define HARDWARE_H_
|
|
|
|
|
|
const uint8_t NUM_OF_LINES = 8;
|
|
|
|
const uint8_t FEEDBACK_PIN[NUM_OF_LINES] = { 22, 23, 24, 25, 26, 27, 28, 29 };
|
|
const uint8_t BUTTON_PIN[NUM_OF_LINES] = { 30, 31, 32, 33, 34, 35, 36, 37 };
|
|
const uint8_t RELAY_PIN[NUM_OF_LINES] = { 38, 39, 40, 42, 41, 44, 43, 45 };
|
|
const uint8_t LED_PIN[NUM_OF_LINES] = { 46, 47, 48, 49, 50, 51, 52, 53 };
|
|
|
|
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, uint8_t index);
|
|
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;
|
|
|
|
uint8_t m_index;
|
|
|
|
|
|
|
|
|
|
void action();
|
|
};
|
|
|
|
|
|
|
|
#endif /* HARDWARE_H_ */
|