mirror of
https://github.com/esphome/esphome.git
synced 2024-12-12 00:14:53 +01:00
Merge pull request #7929 from esphome/bump-2024.11.3
Some checks failed
CI / Check pyupgrade (push) Has been cancelled
CI / Create common environment (push) Has been cancelled
YAML lint / yamllint (push) Has been cancelled
CI / Test split components (push) Has been cancelled
CI / Check black (push) Has been cancelled
CI / Check flake8 (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (push) Has been cancelled
CI / Check clang-format (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / list-components (push) Has been cancelled
CI / Component test (push) Has been cancelled
CI / Split components for testing into 20 groups maximum (push) Has been cancelled
CI / CI Status (push) Has been cancelled
Some checks failed
CI / Check pyupgrade (push) Has been cancelled
CI / Create common environment (push) Has been cancelled
YAML lint / yamllint (push) Has been cancelled
CI / Test split components (push) Has been cancelled
CI / Check black (push) Has been cancelled
CI / Check flake8 (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (push) Has been cancelled
CI / Check clang-format (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / list-components (push) Has been cancelled
CI / Component test (push) Has been cancelled
CI / Split components for testing into 20 groups maximum (push) Has been cancelled
CI / CI Status (push) Has been cancelled
2024.11.3
This commit is contained in:
commit
4c87658503
18 changed files with 100 additions and 82 deletions
|
@ -363,7 +363,7 @@ def upload_program(config, args, host):
|
||||||
|
|
||||||
from esphome import espota2
|
from esphome import espota2
|
||||||
|
|
||||||
remote_port = ota_conf[CONF_PORT]
|
remote_port = int(ota_conf[CONF_PORT])
|
||||||
password = ota_conf.get(CONF_PASSWORD, "")
|
password = ota_conf.get(CONF_PASSWORD, "")
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -60,9 +60,7 @@ ESPTime DateTimeEntity::state_as_esptime() const {
|
||||||
obj.hour = this->hour_;
|
obj.hour = this->hour_;
|
||||||
obj.minute = this->minute_;
|
obj.minute = this->minute_;
|
||||||
obj.second = this->second_;
|
obj.second = this->second_;
|
||||||
obj.day_of_week = 1; // Required to be valid for recalc_timestamp_local but not used.
|
obj.recalc_timestamp_local();
|
||||||
obj.day_of_year = 1; // Required to be valid for recalc_timestamp_local but not used.
|
|
||||||
obj.recalc_timestamp_local(false);
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -355,24 +355,20 @@ def _detect_variant(value):
|
||||||
|
|
||||||
|
|
||||||
def final_validate(config):
|
def final_validate(config):
|
||||||
if CONF_PLATFORMIO_OPTIONS not in fv.full_config.get()[CONF_ESPHOME]:
|
if not (
|
||||||
|
pio_options := fv.full_config.get()[CONF_ESPHOME].get(CONF_PLATFORMIO_OPTIONS)
|
||||||
|
):
|
||||||
|
# Not specified or empty
|
||||||
return config
|
return config
|
||||||
|
|
||||||
pio_flash_size_key = "board_upload.flash_size"
|
pio_flash_size_key = "board_upload.flash_size"
|
||||||
pio_partitions_key = "board_build.partitions"
|
pio_partitions_key = "board_build.partitions"
|
||||||
if (
|
if CONF_PARTITIONS in config and pio_partitions_key in pio_options:
|
||||||
CONF_PARTITIONS in config
|
|
||||||
and pio_partitions_key
|
|
||||||
in fv.full_config.get()[CONF_ESPHOME][CONF_PLATFORMIO_OPTIONS]
|
|
||||||
):
|
|
||||||
raise cv.Invalid(
|
raise cv.Invalid(
|
||||||
f"Do not specify '{pio_partitions_key}' in '{CONF_PLATFORMIO_OPTIONS}' with '{CONF_PARTITIONS}' in esp32"
|
f"Do not specify '{pio_partitions_key}' in '{CONF_PLATFORMIO_OPTIONS}' with '{CONF_PARTITIONS}' in esp32"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (
|
if pio_flash_size_key in pio_options:
|
||||||
pio_flash_size_key
|
|
||||||
in fv.full_config.get()[CONF_ESPHOME][CONF_PLATFORMIO_OPTIONS]
|
|
||||||
):
|
|
||||||
raise cv.Invalid(
|
raise cv.Invalid(
|
||||||
f"Please specify {CONF_FLASH_SIZE} within esp32 configuration only"
|
f"Please specify {CONF_FLASH_SIZE} within esp32 configuration only"
|
||||||
)
|
)
|
||||||
|
|
|
@ -38,7 +38,7 @@ def literal(arg):
|
||||||
def call_lambda(lamb: LambdaExpression):
|
def call_lambda(lamb: LambdaExpression):
|
||||||
expr = lamb.content.strip()
|
expr = lamb.content.strip()
|
||||||
if expr.startswith("return") and expr.endswith(";"):
|
if expr.startswith("return") and expr.endswith(";"):
|
||||||
return expr[7:][:-1]
|
return expr[6:][:-1].strip()
|
||||||
return f"{lamb}()"
|
return f"{lamb}()"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,9 @@ static const display::ColorBitness LV_BITNESS = display::ColorBitness::COLOR_BIT
|
||||||
inline void lv_img_set_src(lv_obj_t *obj, esphome::image::Image *image) {
|
inline void lv_img_set_src(lv_obj_t *obj, esphome::image::Image *image) {
|
||||||
lv_img_set_src(obj, image->get_lv_img_dsc());
|
lv_img_set_src(obj, image->get_lv_img_dsc());
|
||||||
}
|
}
|
||||||
|
inline void lv_disp_set_bg_image(lv_disp_t *disp, esphome::image::Image *image) {
|
||||||
|
lv_disp_set_bg_image(disp, image->get_lv_img_dsc());
|
||||||
|
}
|
||||||
#endif // USE_LVGL_IMAGE
|
#endif // USE_LVGL_IMAGE
|
||||||
|
|
||||||
// Parent class for things that wrap an LVGL object
|
// Parent class for things that wrap an LVGL object
|
||||||
|
|
|
@ -35,6 +35,11 @@ LINE_SCHEMA = {
|
||||||
cv.GenerateID(CONF_POINT_LIST_ID): cv.declare_id(lv_point_t),
|
cv.GenerateID(CONF_POINT_LIST_ID): cv.declare_id(lv_point_t),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LINE_MODIFY_SCHEMA = {
|
||||||
|
cv.Optional(CONF_POINTS): cv_point_list,
|
||||||
|
cv.GenerateID(CONF_POINT_LIST_ID): cv.declare_id(lv_point_t),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class LineType(WidgetType):
|
class LineType(WidgetType):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -43,6 +48,7 @@ class LineType(WidgetType):
|
||||||
LvType("lv_line_t"),
|
LvType("lv_line_t"),
|
||||||
(CONF_MAIN,),
|
(CONF_MAIN,),
|
||||||
LINE_SCHEMA,
|
LINE_SCHEMA,
|
||||||
|
modify_schema=LINE_MODIFY_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def to_code(self, w: Widget, config):
|
async def to_code(self, w: Widget, config):
|
||||||
|
|
|
@ -29,7 +29,7 @@ from ..lvcode import (
|
||||||
)
|
)
|
||||||
from ..schemas import STYLE_SCHEMA, STYLED_TEXT_SCHEMA, container_schema, part_schema
|
from ..schemas import STYLE_SCHEMA, STYLED_TEXT_SCHEMA, container_schema, part_schema
|
||||||
from ..types import LV_EVENT, char_ptr, lv_obj_t
|
from ..types import LV_EVENT, char_ptr, lv_obj_t
|
||||||
from . import Widget, set_obj_properties
|
from . import Widget, add_widgets, set_obj_properties
|
||||||
from .button import button_spec
|
from .button import button_spec
|
||||||
from .buttonmatrix import (
|
from .buttonmatrix import (
|
||||||
BUTTONMATRIX_BUTTON_SCHEMA,
|
BUTTONMATRIX_BUTTON_SCHEMA,
|
||||||
|
@ -119,6 +119,7 @@ async def msgbox_to_code(top_layer, conf):
|
||||||
button_style = {CONF_ITEMS: button_style}
|
button_style = {CONF_ITEMS: button_style}
|
||||||
await set_obj_properties(buttonmatrix_widget, button_style)
|
await set_obj_properties(buttonmatrix_widget, button_style)
|
||||||
await set_obj_properties(msgbox_widget, conf)
|
await set_obj_properties(msgbox_widget, conf)
|
||||||
|
await add_widgets(msgbox_widget, conf)
|
||||||
async with LambdaContext(EVENT_ARG, where=messagebox_id) as close_action:
|
async with LambdaContext(EVENT_ARG, where=messagebox_id) as close_action:
|
||||||
outer_widget.add_flag("LV_OBJ_FLAG_HIDDEN")
|
outer_widget.add_flag("LV_OBJ_FLAG_HIDDEN")
|
||||||
if close_button:
|
if close_button:
|
||||||
|
|
|
@ -49,6 +49,10 @@ void PngDecoder::prepare(uint32_t download_size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int HOT PngDecoder::decode(uint8_t *buffer, size_t size) {
|
int HOT PngDecoder::decode(uint8_t *buffer, size_t size) {
|
||||||
|
if (!this->pngle_) {
|
||||||
|
ESP_LOGE(TAG, "PNG decoder engine not initialized!");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (size < 256 && size < this->download_size_ - this->decoded_bytes_) {
|
if (size < 256 && size < this->download_size_ - this->decoded_bytes_) {
|
||||||
ESP_LOGD(TAG, "Waiting for data");
|
ESP_LOGD(TAG, "Waiting for data");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -138,7 +138,7 @@ OpenthermHub::OpenthermHub() : Component(), in_pin_{}, out_pin_{} {}
|
||||||
void OpenthermHub::process_response(OpenthermData &data) {
|
void OpenthermHub::process_response(OpenthermData &data) {
|
||||||
ESP_LOGD(TAG, "Received OpenTherm response with id %d (%s)", data.id,
|
ESP_LOGD(TAG, "Received OpenTherm response with id %d (%s)", data.id,
|
||||||
this->opentherm_->message_id_to_str((MessageId) data.id));
|
this->opentherm_->message_id_to_str((MessageId) data.id));
|
||||||
ESP_LOGD(TAG, "%s", this->opentherm_->debug_data(data).c_str());
|
this->opentherm_->debug_data(data);
|
||||||
|
|
||||||
switch (data.id) {
|
switch (data.id) {
|
||||||
OPENTHERM_SENSOR_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_RESPONSE_MESSAGE, OPENTHERM_MESSAGE_RESPONSE_ENTITY, ,
|
OPENTHERM_SENSOR_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_RESPONSE_MESSAGE, OPENTHERM_MESSAGE_RESPONSE_ENTITY, ,
|
||||||
|
@ -315,7 +315,7 @@ void OpenthermHub::start_conversation_() {
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Sending request with id %d (%s)", request.id,
|
ESP_LOGD(TAG, "Sending request with id %d (%s)", request.id,
|
||||||
this->opentherm_->message_id_to_str((MessageId) request.id));
|
this->opentherm_->message_id_to_str((MessageId) request.id));
|
||||||
ESP_LOGD(TAG, "%s", this->opentherm_->debug_data(request).c_str());
|
this->opentherm_->debug_data(request);
|
||||||
// Send the request
|
// Send the request
|
||||||
this->last_conversation_start_ = millis();
|
this->last_conversation_start_ = millis();
|
||||||
this->opentherm_->send(request);
|
this->opentherm_->send(request);
|
||||||
|
@ -340,19 +340,18 @@ void OpenthermHub::stop_opentherm_() {
|
||||||
this->opentherm_->stop();
|
this->opentherm_->stop();
|
||||||
this->last_conversation_end_ = millis();
|
this->last_conversation_end_ = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenthermHub::handle_protocol_write_error_() {
|
void OpenthermHub::handle_protocol_write_error_() {
|
||||||
ESP_LOGW(TAG, "Error while sending request: %s",
|
ESP_LOGW(TAG, "Error while sending request: %s",
|
||||||
this->opentherm_->operation_mode_to_str(this->opentherm_->get_mode()));
|
this->opentherm_->operation_mode_to_str(this->opentherm_->get_mode()));
|
||||||
ESP_LOGW(TAG, "%s", this->opentherm_->debug_data(this->last_request_).c_str());
|
this->opentherm_->debug_data(this->last_request_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenthermHub::handle_protocol_read_error_() {
|
void OpenthermHub::handle_protocol_read_error_() {
|
||||||
OpenThermError error;
|
OpenThermError error;
|
||||||
this->opentherm_->get_protocol_error(error);
|
this->opentherm_->get_protocol_error(error);
|
||||||
ESP_LOGW(TAG, "Protocol error occured while receiving response: %s", this->opentherm_->debug_error(error).c_str());
|
ESP_LOGW(TAG, "Protocol error occured while receiving response: %s",
|
||||||
|
this->opentherm_->protocol_error_to_to_str(error.error_type));
|
||||||
|
this->opentherm_->debug_error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenthermHub::handle_timeout_error_() {
|
void OpenthermHub::handle_timeout_error_() {
|
||||||
ESP_LOGW(TAG, "Receive response timed out at a protocol level");
|
ESP_LOGW(TAG, "Receive response timed out at a protocol level");
|
||||||
this->stop_opentherm_();
|
this->stop_opentherm_();
|
||||||
|
|
|
@ -15,15 +15,11 @@
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#endif
|
#endif
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
|
||||||
#include <bitset>
|
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace opentherm {
|
namespace opentherm {
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::bitset;
|
|
||||||
using std::stringstream;
|
|
||||||
using std::to_string;
|
using std::to_string;
|
||||||
|
|
||||||
static const char *const TAG = "opentherm";
|
static const char *const TAG = "opentherm";
|
||||||
|
@ -224,7 +220,7 @@ void IRAM_ATTR OpenTherm::bit_read_(uint8_t value) {
|
||||||
this->bit_pos_++;
|
this->bit_pos_++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolErrorType OpenTherm::verify_stop_bit_(uint8_t value) {
|
ProtocolErrorType IRAM_ATTR OpenTherm::verify_stop_bit_(uint8_t value) {
|
||||||
if (value) { // stop bit detected
|
if (value) { // stop bit detected
|
||||||
return check_parity_(this->data_) ? ProtocolErrorType::NO_ERROR : ProtocolErrorType::PARITY_ERROR;
|
return check_parity_(this->data_) ? ProtocolErrorType::NO_ERROR : ProtocolErrorType::PARITY_ERROR;
|
||||||
} else { // no stop bit detected, error
|
} else { // no stop bit detected, error
|
||||||
|
@ -369,7 +365,7 @@ void IRAM_ATTR OpenTherm::stop_timer_() {
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
// 5 kHz timer_
|
// 5 kHz timer_
|
||||||
void OpenTherm::start_read_timer_() {
|
void IRAM_ATTR OpenTherm::start_read_timer_() {
|
||||||
InterruptLock const lock;
|
InterruptLock const lock;
|
||||||
timer1_attachInterrupt(OpenTherm::esp8266_timer_isr);
|
timer1_attachInterrupt(OpenTherm::esp8266_timer_isr);
|
||||||
timer1_enable(TIM_DIV16, TIM_EDGE, TIM_LOOP); // 5MHz (5 ticks/us - 1677721.4 us max)
|
timer1_enable(TIM_DIV16, TIM_EDGE, TIM_LOOP); // 5MHz (5 ticks/us - 1677721.4 us max)
|
||||||
|
@ -377,14 +373,14 @@ void OpenTherm::start_read_timer_() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2 kHz timer_
|
// 2 kHz timer_
|
||||||
void OpenTherm::start_write_timer_() {
|
void IRAM_ATTR OpenTherm::start_write_timer_() {
|
||||||
InterruptLock const lock;
|
InterruptLock const lock;
|
||||||
timer1_attachInterrupt(OpenTherm::esp8266_timer_isr);
|
timer1_attachInterrupt(OpenTherm::esp8266_timer_isr);
|
||||||
timer1_enable(TIM_DIV16, TIM_EDGE, TIM_LOOP); // 5MHz (5 ticks/us - 1677721.4 us max)
|
timer1_enable(TIM_DIV16, TIM_EDGE, TIM_LOOP); // 5MHz (5 ticks/us - 1677721.4 us max)
|
||||||
timer1_write(2500); // 2kHz
|
timer1_write(2500); // 2kHz
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenTherm::stop_timer_() {
|
void IRAM_ATTR OpenTherm::stop_timer_() {
|
||||||
InterruptLock const lock;
|
InterruptLock const lock;
|
||||||
timer1_disable();
|
timer1_disable();
|
||||||
timer1_detachInterrupt();
|
timer1_detachInterrupt();
|
||||||
|
@ -393,7 +389,7 @@ void OpenTherm::stop_timer_() {
|
||||||
#endif // END ESP8266
|
#endif // END ESP8266
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/21617970/how-to-check-if-value-has-even-parity-of-bits-or-odd
|
// https://stackoverflow.com/questions/21617970/how-to-check-if-value-has-even-parity-of-bits-or-odd
|
||||||
bool OpenTherm::check_parity_(uint32_t val) {
|
bool IRAM_ATTR OpenTherm::check_parity_(uint32_t val) {
|
||||||
val ^= val >> 16;
|
val ^= val >> 16;
|
||||||
val ^= val >> 8;
|
val ^= val >> 8;
|
||||||
val ^= val >> 4;
|
val ^= val >> 4;
|
||||||
|
@ -545,29 +541,17 @@ const char *OpenTherm::message_id_to_str(MessageId id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string OpenTherm::debug_data(OpenthermData &data) {
|
void OpenTherm::debug_data(OpenthermData &data) {
|
||||||
stringstream result;
|
ESP_LOGD(TAG, "%s %s %s %s", format_bin(data.type).c_str(), format_bin(data.id).c_str(),
|
||||||
result << bitset<8>(data.type) << " " << bitset<8>(data.id) << " " << bitset<8>(data.valueHB) << " "
|
format_bin(data.valueHB).c_str(), format_bin(data.valueLB).c_str());
|
||||||
<< bitset<8>(data.valueLB) << "\n";
|
ESP_LOGD(TAG, "type: %s; id: %s; HB: %s; LB: %s; uint_16: %s; float: %s",
|
||||||
result << "type: " << this->message_type_to_str((MessageType) data.type) << "; ";
|
this->message_type_to_str((MessageType) data.type), to_string(data.id).c_str(),
|
||||||
result << "id: " << to_string(data.id) << "; ";
|
to_string(data.valueHB).c_str(), to_string(data.valueLB).c_str(), to_string(data.u16()).c_str(),
|
||||||
result << "HB: " << to_string(data.valueHB) << "; ";
|
to_string(data.f88()).c_str());
|
||||||
result << "LB: " << to_string(data.valueLB) << "; ";
|
|
||||||
result << "uint_16: " << to_string(data.u16()) << "; ";
|
|
||||||
result << "float: " << to_string(data.f88());
|
|
||||||
|
|
||||||
return result.str();
|
|
||||||
}
|
}
|
||||||
std::string OpenTherm::debug_error(OpenThermError &error) {
|
void OpenTherm::debug_error(OpenThermError &error) const {
|
||||||
stringstream result;
|
ESP_LOGD(TAG, "data: %s; clock: %s; capture: %s; bit_pos: %s", format_hex(error.data).c_str(),
|
||||||
result << "type: " << this->protocol_error_to_to_str(error.error_type) << "; ";
|
to_string(clock_).c_str(), format_bin(error.capture).c_str(), to_string(error.bit_pos).c_str());
|
||||||
result << "data: ";
|
|
||||||
result << format_hex(error.data);
|
|
||||||
result << "; clock: " << to_string(clock_);
|
|
||||||
result << "; capture: " << bitset<32>(error.capture);
|
|
||||||
result << "; bit_pos: " << to_string(error.bit_pos);
|
|
||||||
|
|
||||||
return result.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float OpenthermData::f88() { return ((float) this->s16()) / 256.0; }
|
float OpenthermData::f88() { return ((float) this->s16()) / 256.0; }
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include "esphome/core/hal.h"
|
#include "esphome/core/hal.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include "esphome/core/helpers.h"
|
||||||
|
|
||||||
#if defined(ESP32) || defined(USE_ESP_IDF)
|
#if defined(ESP32) || defined(USE_ESP_IDF)
|
||||||
#include "driver/timer.h"
|
#include "driver/timer.h"
|
||||||
|
@ -318,8 +317,8 @@ class OpenTherm {
|
||||||
|
|
||||||
OperationMode get_mode() { return mode_; }
|
OperationMode get_mode() { return mode_; }
|
||||||
|
|
||||||
std::string debug_data(OpenthermData &data);
|
void debug_data(OpenthermData &data);
|
||||||
std::string debug_error(OpenThermError &error);
|
void debug_error(OpenThermError &error) const;
|
||||||
|
|
||||||
const char *protocol_error_to_to_str(ProtocolErrorType error_type);
|
const char *protocol_error_to_to_str(ProtocolErrorType error_type);
|
||||||
const char *message_type_to_str(MessageType message_type);
|
const char *message_type_to_str(MessageType message_type);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "st7920.h"
|
#include "st7920.h"
|
||||||
#include "esphome/core/log.h"
|
|
||||||
#include "esphome/core/application.h"
|
|
||||||
#include "esphome/components/display/display_buffer.h"
|
#include "esphome/components/display/display_buffer.h"
|
||||||
|
#include "esphome/core/application.h"
|
||||||
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace st7920 {
|
namespace st7920 {
|
||||||
|
@ -118,7 +118,6 @@ size_t ST7920::get_buffer_length_() {
|
||||||
|
|
||||||
void HOT ST7920::draw_absolute_pixel_internal(int x, int y, Color color) {
|
void HOT ST7920::draw_absolute_pixel_internal(int x, int y, Color color) {
|
||||||
if (x >= this->get_width_internal() || x < 0 || y >= this->get_height_internal() || y < 0) {
|
if (x >= this->get_width_internal() || x < 0 || y >= this->get_height_internal() || y < 0) {
|
||||||
ESP_LOGW(TAG, "Position out of area: %dx%d", x, y);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int width = this->get_width_internal() / 8u;
|
int width = this->get_width_internal() / 8u;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Constants used by esphome."""
|
"""Constants used by esphome."""
|
||||||
|
|
||||||
__version__ = "2024.11.2"
|
__version__ = "2024.11.3"
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||||
|
|
|
@ -397,6 +397,18 @@ std::string format_hex_pretty(const uint16_t *data, size_t length) {
|
||||||
}
|
}
|
||||||
std::string format_hex_pretty(const std::vector<uint16_t> &data) { return format_hex_pretty(data.data(), data.size()); }
|
std::string format_hex_pretty(const std::vector<uint16_t> &data) { return format_hex_pretty(data.data(), data.size()); }
|
||||||
|
|
||||||
|
std::string format_bin(const uint8_t *data, size_t length) {
|
||||||
|
std::string result;
|
||||||
|
result.resize(length * 8);
|
||||||
|
for (size_t byte_idx = 0; byte_idx < length; byte_idx++) {
|
||||||
|
for (size_t bit_idx = 0; bit_idx < 8; bit_idx++) {
|
||||||
|
result[byte_idx * 8 + bit_idx] = ((data[byte_idx] >> (7 - bit_idx)) & 1) + '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
ParseOnOffState parse_on_off(const char *str, const char *on, const char *off) {
|
ParseOnOffState parse_on_off(const char *str, const char *on, const char *off) {
|
||||||
if (on == nullptr && strcasecmp(str, "on") == 0)
|
if (on == nullptr && strcasecmp(str, "on") == 0)
|
||||||
return PARSE_ON;
|
return PARSE_ON;
|
||||||
|
|
|
@ -420,6 +420,14 @@ template<typename T, enable_if_t<std::is_unsigned<T>::value, int> = 0> std::stri
|
||||||
return format_hex_pretty(reinterpret_cast<uint8_t *>(&val), sizeof(T));
|
return format_hex_pretty(reinterpret_cast<uint8_t *>(&val), sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Format the byte array \p data of length \p len in binary.
|
||||||
|
std::string format_bin(const uint8_t *data, size_t length);
|
||||||
|
/// Format an unsigned integer in binary, starting with the most significant byte.
|
||||||
|
template<typename T, enable_if_t<std::is_unsigned<T>::value, int> = 0> std::string format_bin(T val) {
|
||||||
|
val = convert_big_endian(val);
|
||||||
|
return format_bin(reinterpret_cast<uint8_t *>(&val), sizeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
/// Return values for parse_on_off().
|
/// Return values for parse_on_off().
|
||||||
enum ParseOnOffState {
|
enum ParseOnOffState {
|
||||||
PARSE_NONE = 0,
|
PARSE_NONE = 0,
|
||||||
|
|
|
@ -5,20 +5,18 @@
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
|
||||||
bool is_leap_year(uint32_t year) { return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0); }
|
|
||||||
|
|
||||||
uint8_t days_in_month(uint8_t month, uint16_t year) {
|
uint8_t days_in_month(uint8_t month, uint16_t year) {
|
||||||
static const uint8_t DAYS_IN_MONTH[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
static const uint8_t DAYS_IN_MONTH[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||||
uint8_t days = DAYS_IN_MONTH[month];
|
if (month == 2 && (year % 4 == 0))
|
||||||
if (month == 2 && is_leap_year(year))
|
|
||||||
return 29;
|
return 29;
|
||||||
return days;
|
return DAYS_IN_MONTH[month];
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ESPTime::strftime(char *buffer, size_t buffer_len, const char *format) {
|
size_t ESPTime::strftime(char *buffer, size_t buffer_len, const char *format) {
|
||||||
struct tm c_tm = this->to_c_tm();
|
struct tm c_tm = this->to_c_tm();
|
||||||
return ::strftime(buffer, buffer_len, format, &c_tm);
|
return ::strftime(buffer, buffer_len, format, &c_tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
ESPTime ESPTime::from_c_tm(struct tm *c_tm, time_t c_time) {
|
ESPTime ESPTime::from_c_tm(struct tm *c_tm, time_t c_time) {
|
||||||
ESPTime res{};
|
ESPTime res{};
|
||||||
res.second = uint8_t(c_tm->tm_sec);
|
res.second = uint8_t(c_tm->tm_sec);
|
||||||
|
@ -33,6 +31,7 @@ ESPTime ESPTime::from_c_tm(struct tm *c_tm, time_t c_time) {
|
||||||
res.timestamp = c_time;
|
res.timestamp = c_time;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tm ESPTime::to_c_tm() {
|
struct tm ESPTime::to_c_tm() {
|
||||||
struct tm c_tm {};
|
struct tm c_tm {};
|
||||||
c_tm.tm_sec = this->second;
|
c_tm.tm_sec = this->second;
|
||||||
|
@ -46,6 +45,7 @@ struct tm ESPTime::to_c_tm() {
|
||||||
c_tm.tm_isdst = this->is_dst;
|
c_tm.tm_isdst = this->is_dst;
|
||||||
return c_tm;
|
return c_tm;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ESPTime::strftime(const std::string &format) {
|
std::string ESPTime::strftime(const std::string &format) {
|
||||||
std::string timestr;
|
std::string timestr;
|
||||||
timestr.resize(format.size() * 4);
|
timestr.resize(format.size() * 4);
|
||||||
|
@ -142,6 +142,7 @@ void ESPTime::increment_second() {
|
||||||
this->year++;
|
this->year++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESPTime::increment_day() {
|
void ESPTime::increment_day() {
|
||||||
this->timestamp += 86400;
|
this->timestamp += 86400;
|
||||||
|
|
||||||
|
@ -159,23 +160,22 @@ void ESPTime::increment_day() {
|
||||||
this->year++;
|
this->year++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESPTime::recalc_timestamp_utc(bool use_day_of_year) {
|
void ESPTime::recalc_timestamp_utc(bool use_day_of_year) {
|
||||||
time_t res = 0;
|
time_t res = 0;
|
||||||
|
|
||||||
if (!this->fields_in_range()) {
|
if (!this->fields_in_range()) {
|
||||||
this->timestamp = -1;
|
this->timestamp = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1970; i < this->year; i++)
|
for (int i = 1970; i < this->year; i++)
|
||||||
res += is_leap_year(i) ? 366 : 365;
|
res += (i % 4 == 0) ? 366 : 365;
|
||||||
|
|
||||||
if (use_day_of_year) {
|
if (use_day_of_year) {
|
||||||
res += this->day_of_year - 1;
|
res += this->day_of_year - 1;
|
||||||
} else {
|
} else {
|
||||||
for (int i = 1; i < this->month; i++)
|
for (int i = 1; i < this->month; i++)
|
||||||
res += days_in_month(i, this->year);
|
res += days_in_month(i, this->year);
|
||||||
|
|
||||||
res += this->day_of_month - 1;
|
res += this->day_of_month - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,13 +188,17 @@ void ESPTime::recalc_timestamp_utc(bool use_day_of_year) {
|
||||||
this->timestamp = res;
|
this->timestamp = res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESPTime::recalc_timestamp_local(bool use_day_of_year) {
|
void ESPTime::recalc_timestamp_local() {
|
||||||
this->recalc_timestamp_utc(use_day_of_year);
|
struct tm tm;
|
||||||
this->timestamp -= ESPTime::timezone_offset();
|
|
||||||
ESPTime temp = ESPTime::from_epoch_local(this->timestamp);
|
tm.tm_year = this->year - 1900;
|
||||||
if (temp.is_dst) {
|
tm.tm_mon = this->month - 1;
|
||||||
this->timestamp -= 3600;
|
tm.tm_mday = this->day_of_month;
|
||||||
}
|
tm.tm_hour = this->hour;
|
||||||
|
tm.tm_min = this->minute;
|
||||||
|
tm.tm_sec = this->second;
|
||||||
|
|
||||||
|
this->timestamp = mktime(&tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ESPTime::timezone_offset() {
|
int32_t ESPTime::timezone_offset() {
|
||||||
|
|
|
@ -9,8 +9,6 @@ namespace esphome {
|
||||||
|
|
||||||
template<typename T> bool increment_time_value(T ¤t, uint16_t begin, uint16_t end);
|
template<typename T> bool increment_time_value(T ¤t, uint16_t begin, uint16_t end);
|
||||||
|
|
||||||
bool is_leap_year(uint32_t year);
|
|
||||||
|
|
||||||
uint8_t days_in_month(uint8_t month, uint16_t year);
|
uint8_t days_in_month(uint8_t month, uint16_t year);
|
||||||
|
|
||||||
/// A more user-friendly version of struct tm from time.h
|
/// A more user-friendly version of struct tm from time.h
|
||||||
|
@ -100,7 +98,7 @@ struct ESPTime {
|
||||||
void recalc_timestamp_utc(bool use_day_of_year = true);
|
void recalc_timestamp_utc(bool use_day_of_year = true);
|
||||||
|
|
||||||
/// Recalculate the timestamp field from the other fields of this ESPTime instance assuming local fields.
|
/// Recalculate the timestamp field from the other fields of this ESPTime instance assuming local fields.
|
||||||
void recalc_timestamp_local(bool use_day_of_year = true);
|
void recalc_timestamp_local();
|
||||||
|
|
||||||
/// Convert this ESPTime instance back to a tm struct.
|
/// Convert this ESPTime instance back to a tm struct.
|
||||||
struct tm to_c_tm();
|
struct tm to_c_tm();
|
||||||
|
|
|
@ -109,6 +109,10 @@ lvgl:
|
||||||
close_button: true
|
close_button: true
|
||||||
title: Messagebox
|
title: Messagebox
|
||||||
bg_color: 0xffff
|
bg_color: 0xffff
|
||||||
|
widgets:
|
||||||
|
- label:
|
||||||
|
text: Hello Msgbox
|
||||||
|
id: msgbox_label
|
||||||
body:
|
body:
|
||||||
text: This is a sample messagebox
|
text: This is a sample messagebox
|
||||||
bg_color: 0x808080
|
bg_color: 0x808080
|
||||||
|
@ -137,6 +141,9 @@ lvgl:
|
||||||
- lvgl.widget.focus: mark
|
- lvgl.widget.focus: mark
|
||||||
- lvgl.widget.redraw: hello_label
|
- lvgl.widget.redraw: hello_label
|
||||||
- lvgl.widget.redraw:
|
- lvgl.widget.redraw:
|
||||||
|
- lvgl.label.update:
|
||||||
|
id: msgbox_label
|
||||||
|
text: Unloaded
|
||||||
on_all_events:
|
on_all_events:
|
||||||
logger.log:
|
logger.log:
|
||||||
format: "Event %s"
|
format: "Event %s"
|
||||||
|
@ -333,7 +340,7 @@ lvgl:
|
||||||
id: button_button
|
id: button_button
|
||||||
width: 20%
|
width: 20%
|
||||||
height: 10%
|
height: 10%
|
||||||
transform_angle: !lambda return 180*100;
|
transform_angle: !lambda return(180*100);
|
||||||
arc_width: !lambda return 4;
|
arc_width: !lambda return 4;
|
||||||
border_width: !lambda return 6;
|
border_width: !lambda return 6;
|
||||||
shadow_ofs_x: !lambda return 6;
|
shadow_ofs_x: !lambda return 6;
|
||||||
|
@ -577,7 +584,7 @@ lvgl:
|
||||||
- 180, 60
|
- 180, 60
|
||||||
- 240, 10
|
- 240, 10
|
||||||
on_click:
|
on_click:
|
||||||
- lvgl.widget.update:
|
- lvgl.line.update:
|
||||||
id: lv_line_id
|
id: lv_line_id
|
||||||
line_color: 0xFFFF
|
line_color: 0xFFFF
|
||||||
- lvgl.page.next:
|
- lvgl.page.next:
|
||||||
|
|
Loading…
Reference in a new issue