Rewrite button presses in loop to prevent blocking
This commit is contained in:
@@ -17,6 +17,7 @@ static const unsigned char MSG_START[] = {0x08, 0x08, 0x08, 0xfe, 0xc0};
|
||||
static const unsigned char MSG_END[] = {0xc0, 0xce, 0xce, 0xce};
|
||||
static const uint8_t START_LEN=5;
|
||||
static const uint8_t END_LEN=4;
|
||||
static const int DELAY=250; // how long to press/release buttons in ms
|
||||
|
||||
class Hauslane : public Component, public uart::UARTDevice, public api::CustomAPIDevice {
|
||||
public:
|
||||
@@ -40,14 +41,20 @@ class Hauslane : public Component, public uart::UARTDevice, public api::CustomAP
|
||||
void parse_state();
|
||||
void set_state(bool set_light, uint8_t set_speed);
|
||||
bool light_cur=false;
|
||||
bool light_target=false;
|
||||
uint8_t speed=0;
|
||||
uint8_t speed_target=0;
|
||||
bool meet_target=false;
|
||||
bool power=false;
|
||||
unsigned long last_press=0;
|
||||
GPIOPin *pin_timer;
|
||||
GPIOPin *pin_up;
|
||||
GPIOPin *pin_down;
|
||||
GPIOPin *pin_light;
|
||||
GPIOPin *pin_power;
|
||||
GPIOPin *last_button;
|
||||
void command(std::string command);
|
||||
void button_press(GPIOPin *pin);
|
||||
void button_press(GPIOPin *pin, bool val);
|
||||
std::function<void(bool)> send_light_state;
|
||||
std::function<void(int)> send_fan_speed;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user