mirror of
https://github.com/esphome/esphome.git
synced 2024-12-23 05:54:56 +01:00
commit
29249cdc1b
13 changed files with 138 additions and 16 deletions
|
@ -131,7 +131,7 @@ esphome/components/i2s_audio/* @jesserockz
|
|||
esphome/components/i2s_audio/media_player/* @jesserockz
|
||||
esphome/components/i2s_audio/microphone/* @jesserockz
|
||||
esphome/components/i2s_audio/speaker/* @jesserockz
|
||||
esphome/components/ili9xxx/* @nielsnl68
|
||||
esphome/components/ili9xxx/* @clydebarrow @nielsnl68
|
||||
esphome/components/improv_base/* @esphome/core
|
||||
esphome/components/improv_serial/* @esphome/core
|
||||
esphome/components/ina260/* @mreditor97
|
||||
|
|
|
@ -25,7 +25,7 @@ def AUTO_LOAD():
|
|||
return []
|
||||
|
||||
|
||||
CODEOWNERS = ["@nielsnl68"]
|
||||
CODEOWNERS = ["@nielsnl68", "@clydebarrow"]
|
||||
|
||||
ili9XXX_ns = cg.esphome_ns.namespace("ili9xxx")
|
||||
ili9XXXSPI = ili9XXX_ns.class_(
|
||||
|
@ -42,6 +42,7 @@ MODELS = {
|
|||
"ILI9341": ili9XXX_ns.class_("ILI9XXXILI9341", ili9XXXSPI),
|
||||
"ILI9342": ili9XXX_ns.class_("ILI9XXXILI9342", ili9XXXSPI),
|
||||
"ILI9481": ili9XXX_ns.class_("ILI9XXXILI9481", ili9XXXSPI),
|
||||
"ILI9481-18": ili9XXX_ns.class_("ILI9XXXILI948118", ili9XXXSPI),
|
||||
"ILI9486": ili9XXX_ns.class_("ILI9XXXILI9486", ili9XXXSPI),
|
||||
"ILI9488": ili9XXX_ns.class_("ILI9XXXILI9488", ili9XXXSPI),
|
||||
"ILI9488_A": ili9XXX_ns.class_("ILI9XXXILI9488A", ili9XXXSPI),
|
||||
|
@ -140,8 +141,6 @@ async def to_code(config):
|
|||
rhs = []
|
||||
for x in range(256):
|
||||
rhs.extend([HexInt(x), HexInt(x), HexInt(x)])
|
||||
prog_arr = cg.progmem_array(config[CONF_RAW_DATA_ID], rhs)
|
||||
cg.add(var.set_palette(prog_arr))
|
||||
elif config[CONF_COLOR_PALETTE] == "IMAGE_ADAPTIVE":
|
||||
cg.add(var.set_buffer_color_mode(ILI9XXXColorMode.BITS_8_INDEXED))
|
||||
from PIL import Image
|
||||
|
@ -178,6 +177,4 @@ async def to_code(config):
|
|||
if rhs is not None:
|
||||
prog_arr = cg.progmem_array(config[CONF_RAW_DATA_ID], rhs)
|
||||
cg.add(var.set_palette(prog_arr))
|
||||
|
||||
spi_data_rate = str(spi.SPI_DATA_RATE_OPTIONS[config[CONF_DATA_RATE]])
|
||||
cg.add_define("ILI9XXXDisplay_DATA_RATE", cg.RawExpression(spi_data_rate))
|
||||
cg.add(var.set_data_rate(config[CONF_DATA_RATE]))
|
||||
|
|
|
@ -59,6 +59,7 @@ void ILI9XXXDisplay::dump_config() {
|
|||
if (this->is_18bitdisplay_) {
|
||||
ESP_LOGCONFIG(TAG, " 18-Bit Mode: YES");
|
||||
}
|
||||
ESP_LOGCONFIG(TAG, " Data rate: %dMHz", (unsigned) (this->data_rate_ / 1000000));
|
||||
|
||||
LOG_PIN(" Reset Pin: ", this->reset_pin_);
|
||||
LOG_PIN(" DC Pin: ", this->dc_pin_);
|
||||
|
@ -387,6 +388,17 @@ void ILI9XXXILI9481::initialize() {
|
|||
}
|
||||
}
|
||||
|
||||
void ILI9XXXILI948118::initialize() {
|
||||
this->init_lcd_(INITCMD_ILI9481_18);
|
||||
if (this->width_ == 0) {
|
||||
this->width_ = 320;
|
||||
}
|
||||
if (this->height_ == 0) {
|
||||
this->height_ = 480;
|
||||
}
|
||||
this->is_18bitdisplay_ = true;
|
||||
}
|
||||
|
||||
// 35_TFT display
|
||||
void ILI9XXXILI9486::initialize() {
|
||||
this->init_lcd_(INITCMD_ILI9486);
|
||||
|
|
|
@ -120,6 +120,12 @@ class ILI9XXXILI9481 : public ILI9XXXDisplay {
|
|||
void initialize() override;
|
||||
};
|
||||
|
||||
//----------- ILI9481 in 18 bit mode --------------
|
||||
class ILI9XXXILI948118 : public ILI9XXXDisplay {
|
||||
protected:
|
||||
void initialize() override;
|
||||
};
|
||||
|
||||
//----------- ILI9XXX_35_TFT rotated display --------------
|
||||
class ILI9XXXILI9486 : public ILI9XXXDisplay {
|
||||
protected:
|
||||
|
|
|
@ -94,12 +94,36 @@ static const uint8_t PROGMEM INITCMD_ILI9481[] = {
|
|||
ILI9XXX_IFCTR , 1, 0x83,
|
||||
ILI9XXX_GMCTR ,12, 0x00, 0x26, 0x21, 0x00, 0x00, 0x1F, 0x65, 0x23, 0x77, 0x00, 0x0F, 0x00,
|
||||
ILI9XXX_IFMODE , 1, 0x00, // CommandAccessProtect
|
||||
ILI9XXX_PTLAR , 4, 0, 0, 1, 0xDF,
|
||||
0xE4 , 1, 0xA0,
|
||||
ILI9XXX_MADCTL , 1, MADCTL_MV | MADCTL_BGR, // Memory Access Control
|
||||
ILI9XXX_CSCON , 1, 0x01,
|
||||
ILI9XXX_PIXFMT, 1, 0x55, // 16 bit mode
|
||||
ILI9XXX_INVON, 0,
|
||||
ILI9XXX_DISPON, 0x80, // Set display on
|
||||
0x00 // end
|
||||
};
|
||||
|
||||
static const uint8_t PROGMEM INITCMD_ILI9481_18[] = {
|
||||
ILI9XXX_SLPOUT , 0x80, // Exit sleep mode
|
||||
ILI9XXX_PWSET , 3, 0x07, 0x41, 0x1D,
|
||||
ILI9XXX_VMCTR , 3, 0x00, 0x1C, 0x1F,
|
||||
ILI9XXX_PWSETN , 2, 0x01, 0x11,
|
||||
ILI9XXX_PWCTR1 , 5, 0x10, 0x3B, 0x00, 0x02, 0x11,
|
||||
ILI9XXX_VMCTR1 , 1, 0x03,
|
||||
ILI9XXX_IFCTR , 1, 0x83,
|
||||
ILI9XXX_GMCTR ,12, 0x00, 0x26, 0x21, 0x00, 0x00, 0x1F, 0x65, 0x23, 0x77, 0x00, 0x0F, 0x00,
|
||||
ILI9XXX_IFMODE , 1, 0x00, // CommandAccessProtect
|
||||
ILI9XXX_PTLAR , 4, 0, 0, 1, 0xDF,
|
||||
0xE4 , 1, 0xA0,
|
||||
ILI9XXX_MADCTL , 1, MADCTL_MX| MADCTL_BGR, // Memory Access Control
|
||||
ILI9XXX_CSCON , 1, 0x01,
|
||||
ILI9XXX_PIXFMT, 1, 0x66, // 18 bit mode
|
||||
ILI9XXX_INVON, 0,
|
||||
ILI9XXX_DISPON, 0x80, // Set display on
|
||||
0x00 // end
|
||||
};
|
||||
|
||||
static const uint8_t PROGMEM INITCMD_ILI9486[] = {
|
||||
ILI9XXX_SLPOUT, 0x80,
|
||||
ILI9XXX_PIXFMT, 1, 0x55,
|
||||
|
|
|
@ -170,7 +170,7 @@ def _notify_old_style(config):
|
|||
ARDUINO_VERSIONS = {
|
||||
"dev": (cv.Version(0, 0, 0), "https://github.com/libretiny-eu/libretiny.git"),
|
||||
"latest": (cv.Version(0, 0, 0), None),
|
||||
"recommended": (cv.Version(1, 4, 0), None),
|
||||
"recommended": (cv.Version(1, 4, 1), None),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ CONFIG_SCHEMA = cv.All(
|
|||
}
|
||||
),
|
||||
validate_config,
|
||||
cv.only_on(["esp32", "esp8266"]),
|
||||
cv.only_on(["esp32", "esp8266", "bk72xx"]),
|
||||
)
|
||||
|
||||
|
||||
|
@ -271,10 +271,10 @@ def exp_mqtt_message(config):
|
|||
async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
# Add required libraries for ESP8266
|
||||
if CORE.is_esp8266:
|
||||
# Add required libraries for ESP8266 and LibreTiny
|
||||
if CORE.is_esp8266 or CORE.is_libretiny:
|
||||
# https://github.com/heman/async-mqtt-client/blob/master/library.json
|
||||
cg.add_library("heman/AsyncMqttClient-esphome", "1.0.0")
|
||||
cg.add_library("heman/AsyncMqttClient-esphome", "2.0.0")
|
||||
|
||||
cg.add_define("USE_MQTT")
|
||||
cg.add_global(mqtt_ns.using)
|
||||
|
|
74
esphome/components/mqtt/mqtt_backend_libretiny.h
Normal file
74
esphome/components/mqtt/mqtt_backend_libretiny.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef USE_LIBRETINY
|
||||
|
||||
#include "mqtt_backend.h"
|
||||
#include <AsyncMqttClient.h>
|
||||
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
|
||||
class MQTTBackendLibreTiny final : public MQTTBackend {
|
||||
public:
|
||||
void set_keep_alive(uint16_t keep_alive) final { mqtt_client_.setKeepAlive(keep_alive); }
|
||||
void set_client_id(const char *client_id) final { mqtt_client_.setClientId(client_id); }
|
||||
void set_clean_session(bool clean_session) final { mqtt_client_.setCleanSession(clean_session); }
|
||||
void set_credentials(const char *username, const char *password) final {
|
||||
mqtt_client_.setCredentials(username, password);
|
||||
}
|
||||
void set_will(const char *topic, uint8_t qos, bool retain, const char *payload) final {
|
||||
mqtt_client_.setWill(topic, qos, retain, payload);
|
||||
}
|
||||
void set_server(network::IPAddress ip, uint16_t port) final {
|
||||
mqtt_client_.setServer(IPAddress(static_cast<uint32_t>(ip)), port);
|
||||
}
|
||||
void set_server(const char *host, uint16_t port) final { mqtt_client_.setServer(host, port); }
|
||||
#if ASYNC_TCP_SSL_ENABLED
|
||||
void set_secure(bool secure) { mqtt_client.setSecure(secure); }
|
||||
void add_server_fingerprint(const uint8_t *fingerprint) { mqtt_client.addServerFingerprint(fingerprint); }
|
||||
#endif
|
||||
|
||||
void set_on_connect(std::function<on_connect_callback_t> &&callback) final {
|
||||
this->mqtt_client_.onConnect(std::move(callback));
|
||||
}
|
||||
void set_on_disconnect(std::function<on_disconnect_callback_t> &&callback) final {
|
||||
auto async_callback = [callback](AsyncMqttClientDisconnectReason reason) {
|
||||
// int based enum so casting isn't a problem
|
||||
callback(static_cast<MQTTClientDisconnectReason>(reason));
|
||||
};
|
||||
this->mqtt_client_.onDisconnect(std::move(async_callback));
|
||||
}
|
||||
void set_on_subscribe(std::function<on_subscribe_callback_t> &&callback) final {
|
||||
this->mqtt_client_.onSubscribe(std::move(callback));
|
||||
}
|
||||
void set_on_unsubscribe(std::function<on_unsubscribe_callback_t> &&callback) final {
|
||||
this->mqtt_client_.onUnsubscribe(std::move(callback));
|
||||
}
|
||||
void set_on_message(std::function<on_message_callback_t> &&callback) final {
|
||||
auto async_callback = [callback](const char *topic, const char *payload,
|
||||
AsyncMqttClientMessageProperties async_properties, size_t len, size_t index,
|
||||
size_t total) { callback(topic, payload, len, index, total); };
|
||||
mqtt_client_.onMessage(std::move(async_callback));
|
||||
}
|
||||
void set_on_publish(std::function<on_publish_user_callback_t> &&callback) final {
|
||||
this->mqtt_client_.onPublish(std::move(callback));
|
||||
}
|
||||
|
||||
bool connected() const final { return mqtt_client_.connected(); }
|
||||
void connect() final { mqtt_client_.connect(); }
|
||||
void disconnect() final { mqtt_client_.disconnect(true); }
|
||||
bool subscribe(const char *topic, uint8_t qos) final { return mqtt_client_.subscribe(topic, qos) != 0; }
|
||||
bool unsubscribe(const char *topic) final { return mqtt_client_.unsubscribe(topic) != 0; }
|
||||
bool publish(const char *topic, const char *payload, size_t length, uint8_t qos, bool retain) final {
|
||||
return mqtt_client_.publish(topic, qos, retain, payload, length, false, 0) != 0;
|
||||
}
|
||||
using MQTTBackend::publish;
|
||||
|
||||
protected:
|
||||
AsyncMqttClient mqtt_client_;
|
||||
};
|
||||
|
||||
} // namespace mqtt
|
||||
} // namespace esphome
|
||||
|
||||
#endif // defined(USE_LIBRETINY)
|
|
@ -106,6 +106,9 @@ void MQTTClientComponent::send_device_info_() {
|
|||
#ifdef USE_ESP32
|
||||
root["platform"] = "ESP32";
|
||||
#endif
|
||||
#ifdef USE_LIBRETINY
|
||||
root["platform"] = lt_cpu_get_model_name();
|
||||
#endif
|
||||
|
||||
root["board"] = ESPHOME_BOARD;
|
||||
#if defined(USE_WIFI)
|
||||
|
@ -156,7 +159,7 @@ void MQTTClientComponent::start_dnslookup_() {
|
|||
this->dns_resolve_error_ = false;
|
||||
this->dns_resolved_ = false;
|
||||
ip_addr_t addr;
|
||||
#ifdef USE_ESP32
|
||||
#if defined(USE_ESP32) || defined(USE_LIBRETINY)
|
||||
err_t err = dns_gethostbyname_addrtype(this->credentials_.address.c_str(), &addr,
|
||||
MQTTClientComponent::dns_found_callback, this, LWIP_DNS_ADDRTYPE_IPV4);
|
||||
#endif
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "mqtt_backend_esp32.h"
|
||||
#elif defined(USE_ESP8266)
|
||||
#include "mqtt_backend_esp8266.h"
|
||||
#elif defined(USE_LIBRETINY)
|
||||
#include "mqtt_backend_libretiny.h"
|
||||
#endif
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
|
@ -300,6 +302,8 @@ class MQTTClientComponent : public Component {
|
|||
MQTTBackendESP32 mqtt_backend_;
|
||||
#elif defined(USE_ESP8266)
|
||||
MQTTBackendESP8266 mqtt_backend_;
|
||||
#elif defined(USE_LIBRETINY)
|
||||
MQTTBackendLibreTiny mqtt_backend_;
|
||||
#endif
|
||||
|
||||
MQTTClientState state_{MQTT_CLIENT_DISCONNECTED};
|
||||
|
|
|
@ -9,6 +9,7 @@ from esphome.const import (
|
|||
CONF_REBOOT_TIMEOUT,
|
||||
)
|
||||
from esphome.components import time
|
||||
from esphome.core import TimePeriod
|
||||
|
||||
CONF_NETMASK = "netmask"
|
||||
CONF_PRIVATE_KEY = "private_key"
|
||||
|
@ -59,9 +60,9 @@ CONFIG_SCHEMA = cv.Schema(
|
|||
cv.Optional(CONF_PEER_ALLOWED_IPS, default=["0.0.0.0/0"]): cv.ensure_list(
|
||||
_cidr_network
|
||||
),
|
||||
cv.Optional(CONF_PEER_PERSISTENT_KEEPALIVE, default=0): cv.Any(
|
||||
cv.Optional(CONF_PEER_PERSISTENT_KEEPALIVE, default="0s"): cv.All(
|
||||
cv.positive_time_period_seconds,
|
||||
cv.uint16_t,
|
||||
cv.Range(max=TimePeriod(seconds=65535)),
|
||||
),
|
||||
cv.Optional(
|
||||
CONF_REBOOT_TIMEOUT, default="15min"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2023.9.0b3"
|
||||
__version__ = "2023.9.0b4"
|
||||
|
||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||
|
|
|
@ -2972,6 +2972,7 @@ display:
|
|||
model: TFT 2.4
|
||||
cs_pin: GPIO5
|
||||
dc_pin: GPIO4
|
||||
color_palette: GRAYSCALE
|
||||
reset_pin: GPIO22
|
||||
lambda: |-
|
||||
it.rectangle(0, 0, it.get_width(), it.get_height());
|
||||
|
|
Loading…
Reference in a new issue