switch to ESP-IDF
This commit is contained in:
@@ -51,6 +51,10 @@ void Hauslane::loop() {
|
|||||||
} else {
|
} else {
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
} else if (rx_message.size() > MAX_RX) {
|
||||||
|
parse_state();
|
||||||
|
reading = false;
|
||||||
|
pos = 0;
|
||||||
} else {
|
} else {
|
||||||
pos = 0;
|
pos = 0;
|
||||||
}
|
}
|
||||||
@@ -145,7 +149,7 @@ void Hauslane::set_speed(int new_speed) {
|
|||||||
|
|
||||||
// read message on rx line and turn into current state of fan and light
|
// read message on rx line and turn into current state of fan and light
|
||||||
void Hauslane::parse_state() {
|
void Hauslane::parse_state() {
|
||||||
size_t len = rx_message.size()-4;
|
size_t len = rx_message.size()-END_LEN;
|
||||||
std::string msg;
|
std::string msg;
|
||||||
std::vector<uint8_t> msg_hex;
|
std::vector<uint8_t> msg_hex;
|
||||||
|
|
||||||
@@ -161,20 +165,20 @@ void Hauslane::parse_state() {
|
|||||||
// oscilloscope, but as there is only one-way communication from the front
|
// oscilloscope, but as there is only one-way communication from the front
|
||||||
// panel to the main controller board, this would only be useful if
|
// panel to the main controller board, this would only be useful if
|
||||||
// replacing the front panel entirely
|
// replacing the front panel entirely
|
||||||
const std::vector<uint8_t> off_0{0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce};
|
const std::vector<uint8_t> off_0{0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0x00};
|
||||||
const std::vector<uint8_t> on_0{0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6};
|
const std::vector<uint8_t> on_0{0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6, 0xfe};
|
||||||
const std::vector<uint8_t> off_1{0xce, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6, 0xce, 0xce};
|
const std::vector<uint8_t> off_1{0xce, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6, 0xce, 0xce, 0xc0};
|
||||||
const std::vector<uint8_t> on_1{0xce, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xce};
|
const std::vector<uint8_t> on_1{0xce, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xfe};
|
||||||
const std::vector<uint8_t> off_2{0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6, 0xce, 0xce};
|
const std::vector<uint8_t> off_2{0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6, 0xce, 0xce, 0xfe};
|
||||||
const std::vector<uint8_t> on_2{0xce, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6, 0xce, 0xc6};
|
const std::vector<uint8_t> on_2{0xce, 0xce, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6, 0xce, 0xc6, 0xfe};
|
||||||
const std::vector<uint8_t> off_3{0x38, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce};
|
const std::vector<uint8_t> off_3{0xce, 0x38, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6, 0xce, 0xce, 0x00};
|
||||||
const std::vector<uint8_t> on_3{0x38, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xce};
|
const std::vector<uint8_t> on_3{0xce, 0x38, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6, 0xce, 0xfe};
|
||||||
const std::vector<uint8_t> off_4{0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6, 0xce, 0xce, 0xce};
|
const std::vector<uint8_t> off_4{0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6, 0xce, 0xce, 0xce, 0x00};
|
||||||
const std::vector<uint8_t> on_4{0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce};
|
const std::vector<uint8_t> on_4{0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xfe};
|
||||||
const std::vector<uint8_t> off_5{0xc6, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6, 0xc6, 0xce, 0xce};
|
const std::vector<uint8_t> off_5{0xc6, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6, 0xc6, 0xce, 0xce, 0x00};
|
||||||
const std::vector<uint8_t> on_5{0xc6, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xc6};
|
const std::vector<uint8_t> on_5{0xc6, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xc6, 0xce, 0xfe};
|
||||||
const std::vector<uint8_t> off_6{0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0x38, 0xce, 0xce};
|
const std::vector<uint8_t> off_6{0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce, 0x38, 0xce, 0xce, 0x00};
|
||||||
const std::vector<uint8_t> on_6{0xce, 0xc6, 0xce, 0xce, 0xce, 0xce, 0x38};
|
const std::vector<uint8_t> on_6{0xc6, 0xce, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0x38, 0xce, 0xfe};
|
||||||
|
|
||||||
// print out formatted hex string to log
|
// print out formatted hex string to log
|
||||||
char buf[5];
|
char buf[5];
|
||||||
|
|||||||
@@ -15,10 +15,11 @@
|
|||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace hauslane {
|
namespace hauslane {
|
||||||
|
|
||||||
static const unsigned char MSG_START[] = {0x08, 0x08, 0x08, 0xfe, 0xc0};
|
static const unsigned char MSG_START[] = {0x08, 0x08, 0x08, 0xfe, 0x00, 0xc0};
|
||||||
static const unsigned char MSG_END[] = {0xc0, 0xce, 0xce, 0xce};
|
static const unsigned char MSG_END[] = {0xc0, 0xce, 0xce, 0xce, 0xc6};
|
||||||
static const uint8_t START_LEN=5;
|
static const uint8_t START_LEN=6;
|
||||||
static const uint8_t END_LEN=4;
|
static const uint8_t END_LEN=5;
|
||||||
|
static const size_t MAX_RX=30;
|
||||||
static const int DELAY=250; // how long to press/release buttons in ms
|
static const int DELAY=250; // how long to press/release buttons in ms
|
||||||
|
|
||||||
class Hauslane : public Component, public uart::UARTDevice, public api::CustomAPIDevice {
|
class Hauslane : public Component, public uart::UARTDevice, public api::CustomAPIDevice {
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ esphome:
|
|||||||
|
|
||||||
esp32:
|
esp32:
|
||||||
board: esp32-c3-devkitm-1
|
board: esp32-c3-devkitm-1
|
||||||
|
platform:
|
||||||
|
type: esp-idf
|
||||||
|
|
||||||
# Enable logging
|
# Enable logging
|
||||||
logger:
|
logger:
|
||||||
|
|||||||
Reference in New Issue
Block a user