Merge branch 'dev' into dev

This commit is contained in:
CptSkippy 2024-06-18 15:27:03 -07:00 committed by GitHub
commit 3cebf6a85b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 108 additions and 26 deletions

View file

@ -46,7 +46,7 @@ runs:
- name: Build and push to ghcr by digest - name: Build and push to ghcr by digest
id: build-ghcr id: build-ghcr
uses: docker/build-push-action@v5.4.0 uses: docker/build-push-action@v6.0.1
with: with:
context: . context: .
file: ./docker/Dockerfile file: ./docker/Dockerfile
@ -69,7 +69,7 @@ runs:
- name: Build and push to dockerhub by digest - name: Build and push to dockerhub by digest
id: build-dockerhub id: build-dockerhub
uses: docker/build-push-action@v5.4.0 uses: docker/build-push-action@v6.0.1
with: with:
context: . context: .
file: ./docker/Dockerfile file: ./docker/Dockerfile

View file

@ -65,7 +65,7 @@ jobs:
pip3 install build pip3 install build
python3 -m build python3 -m build
- name: Publish - name: Publish
uses: pypa/gh-action-pypi-publish@v1.8.14 uses: pypa/gh-action-pypi-publish@v1.9.0
deploy-docker: deploy-docker:
name: Build ESPHome ${{ matrix.platform }} name: Build ESPHome ${{ matrix.platform }}

View file

@ -36,7 +36,7 @@ jobs:
python ./script/sync-device_class.py python ./script/sync-device_class.py
- name: Commit changes - name: Commit changes
uses: peter-evans/create-pull-request@v6.0.5 uses: peter-evans/create-pull-request@v6.1.0
with: with:
commit-message: "Synchronise Device Classes from Home Assistant" commit-message: "Synchronise Device Classes from Home Assistant"
committer: esphomebot <esphome@nabucasa.com> committer: esphomebot <esphome@nabucasa.com>

View file

@ -96,16 +96,16 @@ def get_board(core_obj=None):
def get_download_types(storage_json): def get_download_types(storage_json):
return [ return [
{ {
"title": "Modern format", "title": "Factory format (Previously Modern)",
"description": "For use with ESPHome Web and other tools.", "description": "For use with ESPHome Web and other tools.",
"file": "firmware-factory.bin", "file": "firmware.factory.bin",
"download": f"{storage_json.name}-factory.bin", "download": f"{storage_json.name}.factory.bin",
}, },
{ {
"title": "Legacy format", "title": "OTA format (Previously Legacy)",
"description": "For use with ESPHome Flasher.", "description": "For OTA updating a device.",
"file": "firmware.bin", "file": "firmware.ota.bin",
"download": f"{storage_json.name}.bin", "download": f"{storage_json.name}.ota.bin",
}, },
] ]

View file

@ -17,17 +17,19 @@ from SCons.Script import ARGUMENTS
# Copy over the default sdkconfig. # Copy over the default sdkconfig.
from os import path from os import path
if path.exists("./sdkconfig.defaults"): if path.exists("./sdkconfig.defaults"):
os.makedirs(".temp", exist_ok=True) os.makedirs(".temp", exist_ok=True)
shutil.copy("./sdkconfig.defaults", "./.temp/sdkconfig-esp32-idf") shutil.copy("./sdkconfig.defaults", "./.temp/sdkconfig-esp32-idf")
def esp32_create_combined_bin(source, target, env): def esp32_create_combined_bin(source, target, env):
verbose = bool(int(ARGUMENTS.get("PIOVERBOSE", "0"))) verbose = bool(int(ARGUMENTS.get("PIOVERBOSE", "0")))
if verbose: if verbose:
print("Generating combined binary for serial flashing") print("Generating combined binary for serial flashing")
app_offset = 0x10000 app_offset = 0x10000
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}-factory.bin") new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.bin")
sections = env.subst(env.get("FLASH_EXTRA_IMAGES")) sections = env.subst(env.get("FLASH_EXTRA_IMAGES"))
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin") firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
chip = env.get("BOARD_MCU") chip = env.get("BOARD_MCU")
@ -62,5 +64,14 @@ def esp32_create_combined_bin(source, target, env):
else: else:
subprocess.run(["esptool.py", *cmd]) subprocess.run(["esptool.py", *cmd])
def esp32_copy_ota_bin(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
shutil.copyfile(firmware_name, new_file_name)
# pylint: disable=E0602 # pylint: disable=E0602
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) # noqa env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) # noqa
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_copy_ota_bin) # noqa

View file

@ -6,10 +6,18 @@ Import("env") # noqa
def esp8266_copy_factory_bin(source, target, env): def esp8266_copy_factory_bin(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin") firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}-factory.bin") new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.bin")
shutil.copyfile(firmware_name, new_file_name)
def esp8266_copy_ota_bin(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
shutil.copyfile(firmware_name, new_file_name) shutil.copyfile(firmware_name, new_file_name)
# pylint: disable=E0602 # pylint: disable=E0602
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp8266_copy_factory_bin) # noqa env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp8266_copy_factory_bin) # noqa
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp8266_copy_ota_bin) # noqa

View file

@ -42,6 +42,14 @@ COLOR_ORDERS = {
} }
DATA_PIN_SCHEMA = pins.internal_gpio_output_pin_schema DATA_PIN_SCHEMA = pins.internal_gpio_output_pin_schema
def validate_dimension(value):
value = cv.positive_int(value)
if value % 2 != 0:
raise cv.Invalid("Width/height/offset must be divisible by 2")
return value
CONFIG_SCHEMA = cv.All( CONFIG_SCHEMA = cv.All(
display.FULL_DISPLAY_SCHEMA.extend( display.FULL_DISPLAY_SCHEMA.extend(
cv.Schema( cv.Schema(
@ -52,10 +60,14 @@ CONFIG_SCHEMA = cv.All(
cv.dimensions, cv.dimensions,
cv.Schema( cv.Schema(
{ {
cv.Required(CONF_WIDTH): cv.int_, cv.Required(CONF_WIDTH): validate_dimension,
cv.Required(CONF_HEIGHT): cv.int_, cv.Required(CONF_HEIGHT): validate_dimension,
cv.Optional(CONF_OFFSET_HEIGHT, default=0): cv.int_, cv.Optional(
cv.Optional(CONF_OFFSET_WIDTH, default=0): cv.int_, CONF_OFFSET_HEIGHT, default=0
): validate_dimension,
cv.Optional(
CONF_OFFSET_WIDTH, default=0
): validate_dimension,
} }
), ),
), ),

View file

@ -26,6 +26,19 @@ void QspiAmoLed::setup() {
void QspiAmoLed::update() { void QspiAmoLed::update() {
this->do_update_(); this->do_update_();
// Start addresses and widths/heights must be divisible by 2 (CASET/RASET restriction in datasheet)
if (this->x_low_ % 2 == 1) {
this->x_low_--;
}
if (this->x_high_ % 2 == 0) {
this->x_high_++;
}
if (this->y_low_ % 2 == 1) {
this->y_low_--;
}
if (this->y_high_ % 2 == 0) {
this->y_high_++;
}
int w = this->x_high_ - this->x_low_ + 1; int w = this->x_high_ - this->x_low_ + 1;
int h = this->y_high_ - this->y_low_ + 1; int h = this->y_high_ - this->y_low_ + 1;
this->draw_pixels_at(this->x_low_, this->y_low_, w, h, this->buffer_, this->color_mode_, display::COLOR_BITNESS_565, this->draw_pixels_at(this->x_low_, this->y_low_, w, h, this->buffer_, this->color_mode_, display::COLOR_BITNESS_565,

View file

@ -47,10 +47,16 @@ def set_core_data(config):
def get_download_types(storage_json): def get_download_types(storage_json):
return [ return [
{ {
"title": "UF2 format", "title": "UF2 factory format",
"description": "For copying to RP2040 over USB.", "description": "For copying to RP2040 over USB.",
"file": "firmware.uf2", "file": "firmware.uf2",
"download": f"{storage_json.name}.uf2", "download": f"{storage_json.name}.factory.uf2",
},
{
"title": "OTA format",
"description": "For OTA updating a device.",
"file": "firmware.ota.bin",
"download": f"{storage_json.name}.ota.bin",
}, },
] ]
@ -160,6 +166,8 @@ async def to_code(config):
cg.add_define("ESPHOME_BOARD", config[CONF_BOARD]) cg.add_define("ESPHOME_BOARD", config[CONF_BOARD])
cg.add_define("ESPHOME_VARIANT", "RP2040") cg.add_define("ESPHOME_VARIANT", "RP2040")
cg.add_platformio_option("extra_scripts", ["post:post_build.py"])
conf = config[CONF_FRAMEWORK] conf = config[CONF_FRAMEWORK]
cg.add_platformio_option("framework", "arduino") cg.add_platformio_option("framework", "arduino")
cg.add_build_flag("-DUSE_ARDUINO") cg.add_build_flag("-DUSE_ARDUINO")
@ -225,4 +233,10 @@ def generate_pio_files() -> bool:
# Called by writer.py # Called by writer.py
def copy_files() -> bool: def copy_files() -> bool:
dir = os.path.dirname(__file__)
post_build_file = os.path.join(dir, "post_build.py.script")
copy_file_if_changed(
post_build_file,
CORE.relative_build_path("post_build.py"),
)
return generate_pio_files() return generate_pio_files()

View file

@ -0,0 +1,23 @@
import shutil
# pylint: disable=E0602
Import("env") # noqa
def rp2040_copy_factory_uf2(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.uf2")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.uf2")
shutil.copyfile(firmware_name, new_file_name)
def rp2040_copy_ota_bin(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
shutil.copyfile(firmware_name, new_file_name)
# pylint: disable=E0602
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", rp2040_copy_factory_uf2) # noqa
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", rp2040_copy_ota_bin) # noqa

View file

@ -258,6 +258,7 @@ KEY_UART_DEVICES = "uart_devices"
def final_validate_device_schema( def final_validate_device_schema(
name: str, name: str,
*, *,
uart_bus: str = CONF_UART_ID,
baud_rate: Optional[int] = None, baud_rate: Optional[int] = None,
require_tx: bool = False, require_tx: bool = False,
require_rx: bool = False, require_rx: bool = False,
@ -268,7 +269,7 @@ def final_validate_device_schema(
def validate_baud_rate(value): def validate_baud_rate(value):
if value != baud_rate: if value != baud_rate:
raise cv.Invalid( raise cv.Invalid(
f"Component {name} requires baud rate {baud_rate} for the uart bus" f"Component {name} requires baud rate {baud_rate} for the uart referenced by {uart_bus}"
) )
return value return value
@ -287,21 +288,21 @@ def final_validate_device_schema(
def validate_data_bits(value): def validate_data_bits(value):
if value != data_bits: if value != data_bits:
raise cv.Invalid( raise cv.Invalid(
f"Component {name} requires {data_bits} data bits for the uart bus" f"Component {name} requires {data_bits} data bits for the uart referenced by {uart_bus}"
) )
return value return value
def validate_parity(value): def validate_parity(value):
if value != parity: if value != parity:
raise cv.Invalid( raise cv.Invalid(
f"Component {name} requires parity {parity} for the uart bus" f"Component {name} requires parity {parity} for the uart referenced by {uart_bus}"
) )
return value return value
def validate_stop_bits(value): def validate_stop_bits(value):
if value != stop_bits: if value != stop_bits:
raise cv.Invalid( raise cv.Invalid(
f"Component {name} requires {stop_bits} stop bits for the uart bus" f"Component {name} requires {stop_bits} stop bits for the uart referenced by {uart_bus}"
) )
return value return value
@ -316,14 +317,14 @@ def final_validate_device_schema(
hub_schema[ hub_schema[
cv.Required( cv.Required(
CONF_TX_PIN, CONF_TX_PIN,
msg=f"Component {name} requires this uart bus to declare a tx_pin", msg=f"Component {name} requires uart referenced by {uart_bus} to declare a tx_pin",
) )
] = validate_pin(CONF_TX_PIN, device) ] = validate_pin(CONF_TX_PIN, device)
if require_rx and uart_id_type_str in NATIVE_UART_CLASSES: if require_rx and uart_id_type_str in NATIVE_UART_CLASSES:
hub_schema[ hub_schema[
cv.Required( cv.Required(
CONF_RX_PIN, CONF_RX_PIN,
msg=f"Component {name} requires this uart bus to declare a rx_pin", msg=f"Component {name} requires uart referenced by {uart_bus} to declare a rx_pin",
) )
] = validate_pin(CONF_RX_PIN, device) ] = validate_pin(CONF_RX_PIN, device)
if baud_rate is not None: if baud_rate is not None:
@ -337,7 +338,7 @@ def final_validate_device_schema(
return cv.Schema(hub_schema, extra=cv.ALLOW_EXTRA)(hub_config) return cv.Schema(hub_schema, extra=cv.ALLOW_EXTRA)(hub_config)
return cv.Schema( return cv.Schema(
{cv.Required(CONF_UART_ID): fv.id_declaration_match_schema(validate_hub)}, {cv.Required(uart_bus): fv.id_declaration_match_schema(validate_hub)},
extra=cv.ALLOW_EXTRA, extra=cv.ALLOW_EXTRA,
) )