mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
compile with IDF 5
This commit is contained in:
@@ -147,5 +147,6 @@ double ledcSetup(uint8_t chan, double freq, uint8_t bit_num) {
|
|||||||
void ledcAttachPin(uint8_t pin, uint8_t chan) {};
|
void ledcAttachPin(uint8_t pin, uint8_t chan) {};
|
||||||
void ledcWrite(uint8_t chan, uint32_t duty) {};
|
void ledcWrite(uint8_t chan, uint32_t duty) {};
|
||||||
void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val) {};
|
void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val) {};
|
||||||
|
void rgbLedWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val) {};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -72,6 +72,7 @@ double ledcSetup(uint8_t chan, double freq, uint8_t bit_num);
|
|||||||
void ledcAttachPin(uint8_t pin, uint8_t chan);
|
void ledcAttachPin(uint8_t pin, uint8_t chan);
|
||||||
void ledcWrite(uint8_t chan, uint32_t duty);
|
void ledcWrite(uint8_t chan, uint32_t duty);
|
||||||
void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val);
|
void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val);
|
||||||
|
void rgbLedWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val);
|
||||||
|
|
||||||
#define PROGMEM
|
#define PROGMEM
|
||||||
#define PGM_P const char *
|
#define PGM_P const char *
|
||||||
|
|||||||
@@ -551,7 +551,11 @@ void System::led_init(bool refresh) {
|
|||||||
if (refresh) {
|
if (refresh) {
|
||||||
// disabled old led port before setting new one
|
// disabled old led port before setting new one
|
||||||
if ((led_gpio_ != 0) && is_valid_gpio(led_gpio_)) {
|
if ((led_gpio_ != 0) && is_valid_gpio(led_gpio_)) {
|
||||||
|
#if ESP_ARDUINO_VERSION_MAJOR < 3
|
||||||
led_type_ ? neopixelWrite(led_gpio_, 0, 0, 0) : digitalWrite(led_gpio_, !LED_ON);
|
led_type_ ? neopixelWrite(led_gpio_, 0, 0, 0) : digitalWrite(led_gpio_, !LED_ON);
|
||||||
|
#else
|
||||||
|
led_type_ ? rgbLedWrite(led_gpio_, 0, 0, 0) : digitalWrite(led_gpio_, !LED_ON);
|
||||||
|
#endif
|
||||||
pinMode(led_gpio_, INPUT);
|
pinMode(led_gpio_, INPUT);
|
||||||
}
|
}
|
||||||
reload_settings();
|
reload_settings();
|
||||||
@@ -560,7 +564,11 @@ void System::led_init(bool refresh) {
|
|||||||
if ((led_gpio_ != 0) && is_valid_gpio(led_gpio_)) { // 0 means disabled
|
if ((led_gpio_ != 0) && is_valid_gpio(led_gpio_)) { // 0 means disabled
|
||||||
if (led_type_) {
|
if (led_type_) {
|
||||||
// rgb LED WS2812B, use Neopixel
|
// rgb LED WS2812B, use Neopixel
|
||||||
|
#if ESP_ARDUINO_VERSION_MAJOR < 3
|
||||||
neopixelWrite(led_gpio_, 0, 0, 0);
|
neopixelWrite(led_gpio_, 0, 0, 0);
|
||||||
|
#else
|
||||||
|
rgbLedWrite(led_gpio_, 0, 0, 0);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
pinMode(led_gpio_, OUTPUT);
|
pinMode(led_gpio_, OUTPUT);
|
||||||
digitalWrite(led_gpio_, !LED_ON); // start with LED off
|
digitalWrite(led_gpio_, !LED_ON); // start with LED off
|
||||||
@@ -817,12 +825,20 @@ void System::system_check() {
|
|||||||
if (healthcheck_ == 0) {
|
if (healthcheck_ == 0) {
|
||||||
// everything is healthy, show LED permanently on or off depending on setting
|
// everything is healthy, show LED permanently on or off depending on setting
|
||||||
if (led_gpio_) {
|
if (led_gpio_) {
|
||||||
|
#if ESP_ARDUINO_VERSION_MAJOR < 3
|
||||||
led_type_ ? neopixelWrite(led_gpio_, 0, hide_led_ ? 0 : 128, 0) : digitalWrite(led_gpio_, hide_led_ ? !LED_ON : LED_ON);
|
led_type_ ? neopixelWrite(led_gpio_, 0, hide_led_ ? 0 : 128, 0) : digitalWrite(led_gpio_, hide_led_ ? !LED_ON : LED_ON);
|
||||||
|
#else
|
||||||
|
led_type_ ? rgbLedWrite(led_gpio_, 0, hide_led_ ? 0 : 128, 0) : digitalWrite(led_gpio_, hide_led_ ? !LED_ON : LED_ON);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// turn off LED so we're ready to the flashes
|
// turn off LED so we're ready to the flashes
|
||||||
if (led_gpio_) {
|
if (led_gpio_) {
|
||||||
|
#if ESP_ARDUINO_VERSION_MAJOR < 3
|
||||||
led_type_ ? neopixelWrite(led_gpio_, 0, 0, 0) : digitalWrite(led_gpio_, !LED_ON);
|
led_type_ ? neopixelWrite(led_gpio_, 0, 0, 0) : digitalWrite(led_gpio_, !LED_ON);
|
||||||
|
#else
|
||||||
|
led_type_ ? rgbLedWrite(led_gpio_, 0, 0, 0) : digitalWrite(led_gpio_, !LED_ON);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -882,7 +898,11 @@ void System::led_monitor() {
|
|||||||
// reset the whole sequence
|
// reset the whole sequence
|
||||||
led_long_timer_ = uuid::get_uptime();
|
led_long_timer_ = uuid::get_uptime();
|
||||||
led_flash_step_ = 0;
|
led_flash_step_ = 0;
|
||||||
|
#if ESP_ARDUINO_VERSION_MAJOR < 3
|
||||||
led_type_ ? neopixelWrite(led_gpio_, 0, 0, 0) : digitalWrite(led_gpio_, !LED_ON); // LED off
|
led_type_ ? neopixelWrite(led_gpio_, 0, 0, 0) : digitalWrite(led_gpio_, !LED_ON); // LED off
|
||||||
|
#else
|
||||||
|
led_type_ ? rgbLedWrite(led_gpio_, 0, 0, 0) : digitalWrite(led_gpio_, !LED_ON); // LED off
|
||||||
|
#endif
|
||||||
} else if (led_flash_step_ % 2) {
|
} else if (led_flash_step_ % 2) {
|
||||||
// handle the step events (on odd numbers 3,5,7,etc). see if we need to turn on a LED
|
// handle the step events (on odd numbers 3,5,7,etc). see if we need to turn on a LED
|
||||||
// 1 flash is the EMS bus is not connected
|
// 1 flash is the EMS bus is not connected
|
||||||
@@ -892,17 +912,33 @@ void System::led_monitor() {
|
|||||||
if (led_type_) {
|
if (led_type_) {
|
||||||
if (led_flash_step_ == 3) {
|
if (led_flash_step_ == 3) {
|
||||||
if ((healthcheck_ & HEALTHCHECK_NO_NETWORK) == HEALTHCHECK_NO_NETWORK) {
|
if ((healthcheck_ & HEALTHCHECK_NO_NETWORK) == HEALTHCHECK_NO_NETWORK) {
|
||||||
|
#if ESP_ARDUINO_VERSION_MAJOR < 3
|
||||||
neopixelWrite(led_gpio_, 128, 0, 0); // red
|
neopixelWrite(led_gpio_, 128, 0, 0); // red
|
||||||
|
#else
|
||||||
|
rgbLedWrite(led_gpio_, 128, 0, 0); // red
|
||||||
|
#endif
|
||||||
} else if ((healthcheck_ & HEALTHCHECK_NO_BUS) == HEALTHCHECK_NO_BUS) {
|
} else if ((healthcheck_ & HEALTHCHECK_NO_BUS) == HEALTHCHECK_NO_BUS) {
|
||||||
|
#if ESP_ARDUINO_VERSION_MAJOR < 3
|
||||||
neopixelWrite(led_gpio_, 0, 0, 128); // blue
|
neopixelWrite(led_gpio_, 0, 0, 128); // blue
|
||||||
|
#else
|
||||||
|
rgbLedWrite(led_gpio_, 0, 0, 128); // blue
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (led_flash_step_ == 5 && (healthcheck_ & HEALTHCHECK_NO_NETWORK) == HEALTHCHECK_NO_NETWORK) {
|
if (led_flash_step_ == 5 && (healthcheck_ & HEALTHCHECK_NO_NETWORK) == HEALTHCHECK_NO_NETWORK) {
|
||||||
|
#if ESP_ARDUINO_VERSION_MAJOR < 3
|
||||||
neopixelWrite(led_gpio_, 128, 0, 0); // red
|
neopixelWrite(led_gpio_, 128, 0, 0); // red
|
||||||
|
#else
|
||||||
|
rgbLedWrite(led_gpio_, 128, 0, 0); // red
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if ((led_flash_step_ == 7) && ((healthcheck_ & HEALTHCHECK_NO_NETWORK) == HEALTHCHECK_NO_NETWORK)
|
if ((led_flash_step_ == 7) && ((healthcheck_ & HEALTHCHECK_NO_NETWORK) == HEALTHCHECK_NO_NETWORK)
|
||||||
&& ((healthcheck_ & HEALTHCHECK_NO_BUS) == HEALTHCHECK_NO_BUS)) {
|
&& ((healthcheck_ & HEALTHCHECK_NO_BUS) == HEALTHCHECK_NO_BUS)) {
|
||||||
|
#if ESP_ARDUINO_VERSION_MAJOR < 3
|
||||||
neopixelWrite(led_gpio_, 0, 0, 128); // blue
|
neopixelWrite(led_gpio_, 0, 0, 128); // blue
|
||||||
|
#else
|
||||||
|
rgbLedWrite(led_gpio_, 0, 0, 128); // blue
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((led_flash_step_ == 3)
|
if ((led_flash_step_ == 3)
|
||||||
@@ -926,7 +962,11 @@ void System::led_monitor() {
|
|||||||
} else {
|
} else {
|
||||||
// turn the led off after the flash, on even number count
|
// turn the led off after the flash, on even number count
|
||||||
if (led_on_) {
|
if (led_on_) {
|
||||||
|
#if ESP_ARDUINO_VERSION_MAJOR < 3
|
||||||
led_type_ ? neopixelWrite(led_gpio_, 0, 0, 0) : digitalWrite(led_gpio_, !LED_ON);
|
led_type_ ? neopixelWrite(led_gpio_, 0, 0, 0) : digitalWrite(led_gpio_, !LED_ON);
|
||||||
|
#else
|
||||||
|
led_type_ ? rgbLedWrite(led_gpio_, 0, 0, 0) : digitalWrite(led_gpio_, !LED_ON);
|
||||||
|
#endif
|
||||||
led_on_ = false;
|
led_on_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,14 +73,17 @@ void EMSuart::uart_event_task(void * pvParameters) {
|
|||||||
*/
|
*/
|
||||||
void EMSuart::start(const uint8_t tx_mode, const uint8_t rx_gpio, const uint8_t tx_gpio) {
|
void EMSuart::start(const uint8_t tx_mode, const uint8_t rx_gpio, const uint8_t tx_gpio) {
|
||||||
if (tx_mode_ == 0xFF) {
|
if (tx_mode_ == 0xFF) {
|
||||||
uart_config_t uart_config = {
|
uart_config_t uart_config = {.baud_rate = EMSUART_BAUD,
|
||||||
.baud_rate = EMSUART_BAUD,
|
|
||||||
.data_bits = UART_DATA_8_BITS,
|
.data_bits = UART_DATA_8_BITS,
|
||||||
.parity = UART_PARITY_DISABLE,
|
.parity = UART_PARITY_DISABLE,
|
||||||
.stop_bits = UART_STOP_BITS_1,
|
.stop_bits = UART_STOP_BITS_1,
|
||||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
||||||
.rx_flow_ctrl_thresh = 0, // not used - https://docs.espressif.com/projects/esp-idf/en/v3.3.6/api-reference/peripherals/uart.html
|
.rx_flow_ctrl_thresh = 0,
|
||||||
.source_clk = UART_SCLK_APB,
|
.source_clk = UART_SCLK_APB
|
||||||
|
#if ESP_ARDUINO_VERSION_MAJOR >= 3
|
||||||
|
,
|
||||||
|
.flags = {0, 0}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
#if defined(EMSUART_RX_INVERT)
|
#if defined(EMSUART_RX_INVERT)
|
||||||
inverse_mask |= UART_SIGNAL_RXD_INV;
|
inverse_mask |= UART_SIGNAL_RXD_INV;
|
||||||
|
|||||||
Reference in New Issue
Block a user