Merge branch 'dev' into my_display_support

This commit is contained in:
Jakub Čermák 2023-08-31 20:10:33 +02:00 committed by GitHub
commit f403212ef5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 15 deletions

View file

@ -1,9 +1,11 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components.esp32 import add_idf_sdkconfig_option
from esphome.components.esp32 import add_idf_sdkconfig_option, get_esp32_variant
from esphome.core import CORE
from esphome.const import (
CONF_ID,
CONF_MODE,
CONF_SPEED,
)
CODEOWNERS = ["@esphome/core"]
@ -11,8 +13,26 @@ CODEOWNERS = ["@esphome/core"]
psram_ns = cg.esphome_ns.namespace("psram")
PsramComponent = psram_ns.class_("PsramComponent", cg.Component)
SPIRAM_MODES = {
"quad": "CONFIG_SPIRAM_MODE_QUAD",
"octal": "CONFIG_SPIRAM_MODE_OCT",
}
SPIRAM_SPEEDS = {
40e6: "CONFIG_SPIRAM_SPEED_40M",
80e6: "CONFIG_SPIRAM_SPEED_80M",
120e6: "CONFIG_SPIRAM_SPEED_120M",
}
CONFIG_SCHEMA = cv.All(
cv.Schema({cv.GenerateID(): cv.declare_id(PsramComponent)}), cv.only_on_esp32
cv.Schema(
{
cv.GenerateID(): cv.declare_id(PsramComponent),
cv.Optional(CONF_MODE): cv.enum(SPIRAM_MODES, lower=True),
cv.Optional(CONF_SPEED): cv.All(cv.frequency, cv.one_of(*SPIRAM_SPEEDS)),
}
),
cv.only_on_esp32,
)
@ -21,9 +41,18 @@ async def to_code(config):
cg.add_build_flag("-DBOARD_HAS_PSRAM")
if CORE.using_esp_idf:
add_idf_sdkconfig_option("CONFIG_ESP32_SPIRAM_SUPPORT", True)
add_idf_sdkconfig_option(
f"CONFIG_{get_esp32_variant().upper()}_SPIRAM_SUPPORT", True
)
add_idf_sdkconfig_option("CONFIG_SPIRAM", True)
add_idf_sdkconfig_option("CONFIG_SPIRAM_USE", True)
add_idf_sdkconfig_option("CONFIG_SPIRAM_USE_CAPS_ALLOC", True)
add_idf_sdkconfig_option("CONFIG_SPIRAM_IGNORE_NOTFOUND", True)
if CONF_MODE in config:
add_idf_sdkconfig_option(f"{SPIRAM_MODES[config[CONF_MODE]]}", True)
if CONF_SPEED in config:
add_idf_sdkconfig_option(f"{SPIRAM_SPEEDS[config[CONF_SPEED]]}", True)
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)

View file

@ -19,6 +19,7 @@ void ST7789V::setup() {
this->write_command_(ST7789_SLPOUT); // Sleep out
delay(120); // NOLINT
this->write_command_(ST7789_SLPOUT); //
this->write_command_(ST7789_NORON); // Normal display mode on

View file

@ -1,19 +1,19 @@
import logging
import socket
import threading
import time
from typing import Optional
import logging
from dataclasses import dataclass
from typing import Optional
from zeroconf import (
DNSAddress,
DNSOutgoing,
DNSRecord,
DNSQuestion,
RecordUpdate,
RecordUpdateListener,
Zeroconf,
ServiceBrowser,
ServiceStateChange,
Zeroconf,
current_time_millis,
)
@ -24,17 +24,28 @@ _LOGGER = logging.getLogger(__name__)
class HostResolver(RecordUpdateListener):
"""Resolve a host name to an IP address."""
def __init__(self, name: str):
self.name = name
self.address: Optional[bytes] = None
def update_record(self, zc: Zeroconf, now: float, record: DNSRecord) -> None:
if record is None:
return
if record.type == _TYPE_A:
assert isinstance(record, DNSAddress)
if record.name == self.name:
self.address = record.address
def async_update_records(
self, zc: Zeroconf, now: float, records: list[RecordUpdate]
) -> None:
"""Update multiple records in one shot.
This will run in zeroconf's event loop thread so it
must be thread-safe.
"""
for record_update in records:
record, _ = record_update
if record is None:
continue
if record.type == _TYPE_A:
assert isinstance(record, DNSAddress)
if record.name == self.name:
self.address = record.address
def request(self, zc: Zeroconf, timeout: float) -> bool:
now = time.time()

View file

@ -11,7 +11,7 @@ esptool==4.6.2
click==8.1.7
esphome-dashboard==20230711.0
aioesphomeapi==15.0.0
zeroconf==0.80.0
zeroconf==0.86.0
# esp-idf requires this, but doesn't bundle it by default
# https://github.com/espressif/esp-idf/blob/220590d599e134d7a5e7f1e683cc4550349ffbf8/requirements.txt#L24