mirror of
https://github.com/esphome/esphome.git
synced 2026-11-18 11:06:02 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3474a1ed5 |
No files matched your search
@@ -20,6 +20,9 @@ flagging in a review; read the matching skill for the detail behind any item.
|
||||
Only raise findings that the diff actually introduces or changes. Do not ask for
|
||||
drive-by cleanup of pre-existing code the PR did not touch.
|
||||
|
||||
For error paths that fail without telling the user (early returns, swallowed
|
||||
errors, ignored results), the `silent-failure-review` skill has its own checklist.
|
||||
|
||||
## Scope: shared code does not ride a component PR
|
||||
|
||||
Check the file list first. A PR titled for one component (`[ld2450] ...`) must
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
name: silent-failure-review
|
||||
description: Find code paths in a branch's diff that fail without telling the user - early returns, swallowed errors, ignored return values, half-done cleanup, and checks that are only safe under an unstated assumption. Use when asked for a silent failure review or before pushing a PR for review.
|
||||
---
|
||||
|
||||
# Silent failure review
|
||||
|
||||
Report only. Do not edit files.
|
||||
|
||||
## Scope
|
||||
|
||||
The diff of the checked-out branch against its base. Fetch the base first (`git fetch upstream dev`, or
|
||||
`git fetch origin dev` when there is no `upstream` remote); a stale base pulls in commits the branch only merged.
|
||||
Then run `git merge-base upstream/dev HEAD` (or `origin/dev`) on its own. If it fails or prints nothing (often a
|
||||
shallow clone; `git fetch --unshallow` fixes that), say the review could not run and stop; never report "no
|
||||
findings" then. Diff against that commit with `git diff <base>`. The diff includes uncommitted changes but not
|
||||
untracked files, so also read in full every file `git status --porcelain --untracked-files=all` lists as `??`.
|
||||
Use another branch only if the user names one. If neither remote exists, say so and stop. Read each changed
|
||||
function in full, and its callers, not just the hunks. When a failure depends on how a library call behaves,
|
||||
read that library's code too.
|
||||
|
||||
## What to look for
|
||||
|
||||
1. **Early returns and skips:** a `return` or `continue` taken before a check or a fetch. Name the assumption
|
||||
it relies on and the case that breaks it (a later release, a lost file, an older install).
|
||||
2. **Swallowed errors:** `except` that logs, passes or returns a default; `OSError` tolerated where the next
|
||||
step needs the file. In C++: an error code mapped to a default, or a status flag that is never set.
|
||||
3. **Ignored results:** a `False`, `None`, exit code, `bool` or `ErrorCode` that the caller does not check.
|
||||
4. **Half-done state:** a failure between two writes that leaves a marker, stamp, lock or filter saying
|
||||
something is done when it is not; cleanup missing on an error path.
|
||||
5. **Stale stored state:** markers, stamps or saved preferences (NVS, flash) written by an older version that
|
||||
the new code trusts.
|
||||
6. **Unclear late failure:** an error that surfaces later (CMake, compile, boot) instead of where it starts,
|
||||
with a message that does not point back to the cause.
|
||||
7. **Defaults standing in for errors:** `x or default`, `.get(key, default)` or an empty object takes the
|
||||
place of a value that is missing or could not be read, and the code carries on as if it were real.
|
||||
8. **Unwatched work:** a thread, task or subprocess is started and nothing ever looks at how it ended.
|
||||
9. **Wrong value on an error branch:** the error is detected, but the branch returns success, `None` or the
|
||||
wrong code instead of passing it on.
|
||||
10. **State reset or skipped:** for each counter, flag, retry or timeout the diff adds or changes, find every
|
||||
place that writes it, and check that no path resets or skips it before it can do its job.
|
||||
11. **Boundaries:** length and buffer comparisons (`>=` against `>`, `len` against `len + 1`), the exact-fit
|
||||
case and the empty case.
|
||||
12. **Unjudged results:** a test or script that prints a result but never fails on it.
|
||||
|
||||
Moved code counts too: if the original had the same flaw, say so, but still report it. Report only flaws in
|
||||
changed or moved lines; unchanged callers are context. If the branch has an open PR (`gh pr view --json number`
|
||||
finds it), read its reviews (`gh pr view <n> --comments` and
|
||||
`gh api --paginate repos/esphome/esphome/pulls/<n>/comments`) and skip what they already raised.
|
||||
|
||||
Before reporting a candidate, follow it to the line that proves it and quote that line. If you cannot
|
||||
confirm it, drop it or mark it as likely.
|
||||
|
||||
## Skip
|
||||
|
||||
- Code that ignores a failure and has a comment explaining why.
|
||||
- Tests that provoke an error and check for it.
|
||||
- Optional tidy-up steps (removing a temp file, say) that may fail with only a log line.
|
||||
|
||||
## Report
|
||||
|
||||
One entry per finding, most severe first:
|
||||
|
||||
- **HIGH / MEDIUM / LOW** - one-line title, `file:line`. HIGH: wrong result or lost data. MEDIUM: a
|
||||
misleading or delayed failure. LOW: affects only logs or diagnostics.
|
||||
- **Confidence:** confirmed, or likely and why it could not be confirmed.
|
||||
- **Risk:** the concrete input or state, and what the user sees.
|
||||
- **Fix:** the smallest change.
|
||||
- **Test:** the test that fails before the fix, or for on-device code, the steps to reproduce it on a board.
|
||||
|
||||
No findings: say so in one line. Keep the report short; no summary of what the PR does.
|
||||
@@ -66,6 +66,8 @@ file does, and it is the authority when they disagree. The most useful starting
|
||||
* `breaking-changes`: what is public API, deprecation patterns and migration notes.
|
||||
* `pr-workflow`, `code-review`, `hardware-test`, `display-test`: creating PRs, reviewing them, and testing
|
||||
on real boards and panels.
|
||||
* `silent-failure-review`: code paths in a branch's diff that fail without telling the user, checked
|
||||
before a PR goes up for review.
|
||||
|
||||
* **Formatting:**
|
||||
* **Python:** Uses `ruff` for linting and formatting. Configuration is in `pyproject.toml`.
|
||||
|
||||
@@ -2,16 +2,11 @@ from collections.abc import Iterable
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
|
||||
import esphome.codegen as cg
|
||||
from esphome.core import CORE
|
||||
|
||||
CODEOWNERS = ["@esphome/core"]
|
||||
DOMAIN = "epaper_spi"
|
||||
|
||||
register_enable_pin = cg.slot_list(
|
||||
"EPAPER_SPI_ENABLE_PIN_COUNT", "register_enable_pin", DOMAIN
|
||||
)
|
||||
|
||||
# The source file that every model needs.
|
||||
BASE_SOURCE_FILE = "epaper_spi.cpp"
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ from esphome.const import (
|
||||
)
|
||||
from esphome.cpp_generator import RawExpression
|
||||
|
||||
from . import models, register_enable_pin, register_sources
|
||||
from . import models, register_sources
|
||||
|
||||
AUTO_LOAD = ["split_buffer"]
|
||||
DEPENDENCIES = ["spi"]
|
||||
@@ -249,8 +249,9 @@ async def to_code(config):
|
||||
await display.add_writer(var, config)
|
||||
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
|
||||
await cg.add_pin(var.set_busy_pin, config.get(CONF_BUSY_PIN))
|
||||
for pin in config.get(CONF_ENABLE_PIN, ()):
|
||||
cg.add(register_enable_pin(var, await cg.gpio_pin_expression(pin)))
|
||||
if enable_pin := config.get(CONF_ENABLE_PIN):
|
||||
enable = [await cg.gpio_pin_expression(pin) for pin in enable_pin]
|
||||
cg.add(var.set_enable_pins(enable))
|
||||
cg.add(var.set_full_update_every(config[CONF_FULL_UPDATE_EVERY]))
|
||||
cg.add_optional(var.set_reset_duration, config.get(CONF_RESET_DURATION))
|
||||
if transform := config.get(CONF_TRANSFORM):
|
||||
|
||||
@@ -57,7 +57,7 @@ class EPaperBase : public Display,
|
||||
float get_setup_priority() const override;
|
||||
void set_reset_pin(GPIOPin *reset) { this->reset_pin_ = reset; }
|
||||
void set_busy_pin(GPIOPin *busy) { this->busy_pin_ = busy; }
|
||||
SLOT_LIST(GPIOPin, enable_pins_, register_enable_pin, EPAPER_SPI_ENABLE_PIN_COUNT)
|
||||
void set_enable_pins(std::vector<GPIOPin *> enable_pins) { this->enable_pins_ = std::move(enable_pins); }
|
||||
void set_reset_duration(uint32_t reset_duration) { this->reset_duration_ = reset_duration; }
|
||||
void set_transform(uint8_t transform) {
|
||||
this->transform_ = transform;
|
||||
@@ -227,6 +227,7 @@ class EPaperBase : public Display,
|
||||
GPIOPin *dc_pin_{};
|
||||
GPIOPin *busy_pin_{};
|
||||
GPIOPin *reset_pin_{};
|
||||
std::vector<GPIOPin *> enable_pins_{};
|
||||
bool waiting_for_idle_{};
|
||||
HighFrequencyLoopRequester high_frequency_loop_;
|
||||
uint32_t delay_until_{}; // timestamp until which to delay processing
|
||||
|
||||
@@ -1,8 +1,2 @@
|
||||
import esphome.codegen as cg
|
||||
|
||||
CODEOWNERS = ["@Passific", "@koosoli", "@limengdu"]
|
||||
DOMAIN = "it8951"
|
||||
|
||||
register_enable_pin = cg.slot_list(
|
||||
"IT8951_ENABLE_PIN_COUNT", "register_enable_pin", DOMAIN
|
||||
)
|
||||
@@ -39,8 +39,6 @@ from esphome.const import (
|
||||
from esphome.cpp_generator import RawExpression
|
||||
from esphome.types import ConfigType
|
||||
|
||||
from . import register_enable_pin
|
||||
|
||||
AUTO_LOAD = ["split_buffer"]
|
||||
DEPENDENCIES = ["spi"]
|
||||
|
||||
@@ -369,8 +367,12 @@ async def to_code(config: ConfigType) -> None:
|
||||
await display.add_writer(var, config)
|
||||
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
|
||||
await cg.add_pin(var.set_busy_pin, config.get(CONF_BUSY_PIN))
|
||||
for pin in config.get(CONF_ENABLE_PIN, ()):
|
||||
cg.add(register_enable_pin(var, await cg.gpio_pin_expression(pin)))
|
||||
if enable_pins := config.get(CONF_ENABLE_PIN):
|
||||
cg.add(
|
||||
var.set_enable_pins(
|
||||
[await cg.gpio_pin_expression(pin) for pin in enable_pins]
|
||||
)
|
||||
)
|
||||
cg.add(var.set_full_update_every(config[CONF_FULL_UPDATE_EVERY]))
|
||||
cg.add_optional(var.set_reset_duration, config.get(CONF_RESET_DURATION))
|
||||
if config.get(CONF_INVERT_COLORS):
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/hal.h"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "esphome/components/display/display.h"
|
||||
#include "esphome/components/spi/spi.h"
|
||||
@@ -102,8 +104,7 @@ class IT8951Display : public Display,
|
||||
// --- Config setters (called from generated code) ---
|
||||
void set_reset_pin(GPIOPin *pin) { this->reset_pin_ = pin; }
|
||||
void set_busy_pin(GPIOPin *pin) { this->busy_pin_ = pin; }
|
||||
// GPIOs driven high during setup to power on the panel.
|
||||
SLOT_LIST(GPIOPin, enable_pins_, register_enable_pin, IT8951_ENABLE_PIN_COUNT)
|
||||
void set_enable_pins(std::vector<GPIOPin *> pins) { this->enable_pins_ = std::move(pins); }
|
||||
void set_reset_duration(uint32_t ms) { this->reset_duration_ = ms; }
|
||||
void set_full_update_every(uint8_t n) {
|
||||
this->full_update_every_ = n;
|
||||
@@ -280,6 +281,8 @@ class IT8951Display : public Display,
|
||||
UpdateMode default_update_mode_{UPDATE_MODE_NONE};
|
||||
GPIOPin *reset_pin_{nullptr};
|
||||
GPIOPin *busy_pin_{nullptr};
|
||||
// GPIOs driven high during setup to power on the panel (empty if unused).
|
||||
std::vector<GPIOPin *> enable_pins_;
|
||||
|
||||
// Dirty region (pixel coordinates of bounding box of changes since last update)
|
||||
uint16_t x_low_{0}, y_low_{0}, x_high_{0}, y_high_{0};
|
||||
|
||||
@@ -3,8 +3,4 @@ import esphome.codegen as cg
|
||||
CODEOWNERS = ["@clydebarrow"]
|
||||
DOMAIN = "mipi_dsi"
|
||||
|
||||
register_enable_pin = cg.slot_list(
|
||||
"MIPI_DSI_ENABLE_PIN_COUNT", "register_enable_pin", DOMAIN
|
||||
)
|
||||
|
||||
mipi_dsi_ns = cg.esphome_ns.namespace("mipi_dsi")
|
||||
@@ -63,7 +63,7 @@ from esphome.core import CORE
|
||||
from esphome.final_validate import full_config
|
||||
from esphome.types import ConfigType
|
||||
|
||||
from . import mipi_dsi_ns, models, register_enable_pin
|
||||
from . import mipi_dsi_ns, models
|
||||
from .models import DsiDriverChip
|
||||
|
||||
# Currently only ESP32-P4 is supported, so esp_ldo and psram are required
|
||||
@@ -227,8 +227,9 @@ async def to_code(config: ConfigType) -> None:
|
||||
cg.add(var.set_lanes(int(config[CONF_LANES])))
|
||||
cg.add(var.set_lane_bit_rate(config[CONF_LANE_BIT_RATE] / 1.0e6))
|
||||
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
|
||||
for pin in config.get(CONF_ENABLE_PIN, ()):
|
||||
cg.add(register_enable_pin(var, await cg.gpio_pin_expression(pin)))
|
||||
if enable_pin := config.get(CONF_ENABLE_PIN):
|
||||
enable = [await cg.gpio_pin_expression(pin) for pin in enable_pin]
|
||||
cg.add(var.set_enable_pins(enable))
|
||||
|
||||
if model.rotation_as_transform(config):
|
||||
config[CONF_ROTATION] = 0
|
||||
|
||||
@@ -48,7 +48,7 @@ class MipiDsi final : public display::Display {
|
||||
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; }
|
||||
|
||||
void set_reset_pin(GPIOPin *reset_pin) { this->reset_pin_ = reset_pin; }
|
||||
SLOT_LIST(GPIOPin, enable_pins_, register_enable_pin, MIPI_DSI_ENABLE_PIN_COUNT)
|
||||
void set_enable_pins(std::vector<GPIOPin *> enable_pins) { this->enable_pins_ = std::move(enable_pins); }
|
||||
void set_pclk_frequency(float pclk_frequency) { this->pclk_frequency_ = pclk_frequency; }
|
||||
int get_width_internal() override { return this->width_; }
|
||||
int get_height_internal() override { return this->height_; }
|
||||
@@ -114,6 +114,7 @@ class MipiDsi final : public display::Display {
|
||||
return this->big_endian_ ? convert_big_endian(rgb565) : rgb565;
|
||||
}
|
||||
GPIOPin *reset_pin_{nullptr};
|
||||
std::vector<GPIOPin *> enable_pins_{};
|
||||
size_t width_{};
|
||||
size_t height_{};
|
||||
uint16_t hsync_pulse_width_ = 10;
|
||||
|
||||
@@ -1,8 +1,2 @@
|
||||
import esphome.codegen as cg
|
||||
|
||||
CODEOWNERS = ["@clydebarrow"]
|
||||
DOMAIN = "mipi_rgb"
|
||||
|
||||
register_enable_pin = cg.slot_list(
|
||||
"MIPI_RGB_ENABLE_PIN_COUNT", "register_enable_pin", DOMAIN
|
||||
)
|
||||
@@ -79,7 +79,7 @@ from esphome.const import (
|
||||
from esphome.final_validate import full_config
|
||||
from esphome.types import ConfigType
|
||||
|
||||
from . import models, register_enable_pin
|
||||
from . import models
|
||||
from .models import RgbDriverChip
|
||||
|
||||
DEPENDENCIES = ["esp32"]
|
||||
@@ -276,8 +276,9 @@ async def to_code(config: ConfigType) -> None:
|
||||
)
|
||||
var = cg.new_Pvariable(config[CONF_ID], width, height)
|
||||
cg.add(var.set_model(model.name))
|
||||
for pin in config.get(CONF_ENABLE_PIN, ()):
|
||||
cg.add(register_enable_pin(var, await cg.gpio_pin_expression(pin)))
|
||||
if enable_pin := config.get(CONF_ENABLE_PIN):
|
||||
enable = [await cg.gpio_pin_expression(pin) for pin in enable_pin]
|
||||
cg.add(var.set_enable_pins(enable))
|
||||
|
||||
if CONF_SPI_ID in config:
|
||||
await spi.register_spi_device(var, config, write_only=True)
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
#if defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32P4) || defined(USE_ESP32_VARIANT_ESP32S31)
|
||||
#include "esphome/core/gpio.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/components/display/display.h"
|
||||
#include "esphome/components/display/display_color_utils.h"
|
||||
#include "mipi_rgb_blitter.h"
|
||||
#include <esp_lcd_panel_rgb.h>
|
||||
#include <utility>
|
||||
#ifdef USE_SPI
|
||||
#include "esphome/components/spi/spi.h"
|
||||
#endif
|
||||
@@ -61,7 +61,7 @@ class MipiRgb : public display::Display {
|
||||
void set_vsync_pulse_width(uint16_t vsync_pulse_width) { this->vsync_pulse_width_ = vsync_pulse_width; }
|
||||
void set_vsync_back_porch(uint16_t vsync_back_porch) { this->vsync_back_porch_ = vsync_back_porch; }
|
||||
void set_vsync_front_porch(uint16_t vsync_front_porch) { this->vsync_front_porch_ = vsync_front_porch; }
|
||||
SLOT_LIST(GPIOPin, enable_pins_, register_enable_pin, MIPI_RGB_ENABLE_PIN_COUNT)
|
||||
void set_enable_pins(std::vector<GPIOPin *> enable_pins) { this->enable_pins_ = std::move(enable_pins); }
|
||||
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; }
|
||||
int get_width_internal() override { return this->width_; }
|
||||
int get_height_internal() override { return this->height_; }
|
||||
@@ -111,6 +111,7 @@ class MipiRgb : public display::Display {
|
||||
size_t width_;
|
||||
size_t height_;
|
||||
uint16_t *buffer_{nullptr};
|
||||
std::vector<GPIOPin *> enable_pins_{};
|
||||
uint16_t x_low_{1};
|
||||
uint16_t y_low_{1};
|
||||
uint16_t x_high_{0};
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
import esphome.codegen as cg
|
||||
|
||||
CODEOWNERS = ["@clydebarrow"]
|
||||
|
||||
DOMAIN = "mipi_spi"
|
||||
|
||||
register_enable_pin = cg.slot_list(
|
||||
"MIPI_SPI_ENABLE_PIN_COUNT", "register_enable_pin", DOMAIN
|
||||
)
|
||||
|
||||
CONF_SPI_16 = "spi_16"
|
||||
CONF_BUS_MODE = "bus_mode"
|
||||
@@ -56,7 +56,7 @@ from esphome.cpp_generator import MockObjClass, TemplateArguments
|
||||
from esphome.final_validate import full_config
|
||||
from esphome.types import ConfigType
|
||||
|
||||
from . import CONF_BUS_MODE, CONF_SPI_16, DOMAIN, models, register_enable_pin
|
||||
from . import CONF_BUS_MODE, CONF_SPI_16, DOMAIN, models
|
||||
|
||||
DEPENDENCIES = ["spi"]
|
||||
|
||||
@@ -397,8 +397,9 @@ async def to_code(config: ConfigType) -> None:
|
||||
table = cg.shared_progmem_array("mipi_spi_init_sequence", cg.uint8, init_sequence)
|
||||
cg.add(var.set_init_sequence(table, len(init_sequence)))
|
||||
cg.add(var.set_model(config[CONF_MODEL]))
|
||||
for pin in config.get(CONF_ENABLE_PIN, ()):
|
||||
cg.add(register_enable_pin(var, await cg.gpio_pin_expression(pin)))
|
||||
if enable_pin := config.get(CONF_ENABLE_PIN):
|
||||
enable = [await cg.gpio_pin_expression(pin) for pin in enable_pin]
|
||||
cg.add(var.set_enable_pins(enable))
|
||||
|
||||
await cg.add_pin(var.set_reset_pin, config.get(CONF_RESET_PIN))
|
||||
await cg.add_pin(var.set_dc_pin, config.get(CONF_DC_PIN))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
#include "esphome/components/spi/spi.h"
|
||||
#include "esphome/components/display/display.h"
|
||||
@@ -106,7 +107,7 @@ class MipiSpi : public display::Display,
|
||||
void draw_pixel_at(int x, int y, Color color) override {}
|
||||
void set_model(const char *model) { this->model_ = model; }
|
||||
void set_reset_pin(GPIOPin *reset_pin) { this->reset_pin_ = reset_pin; }
|
||||
SLOT_LIST(GPIOPin, enable_pins_, register_enable_pin, MIPI_SPI_ENABLE_PIN_COUNT)
|
||||
void set_enable_pins(std::vector<GPIOPin *> enable_pins) { this->enable_pins_ = std::move(enable_pins); }
|
||||
void set_dc_pin(GPIOPin *dc_pin) { this->dc_pin_ = dc_pin; }
|
||||
void set_invert_colors(bool invert_colors) {
|
||||
this->invert_colors_ = invert_colors;
|
||||
@@ -485,6 +486,7 @@ class MipiSpi : public display::Display,
|
||||
|
||||
// GPIO pins
|
||||
GPIOPin *reset_pin_{nullptr};
|
||||
std::vector<GPIOPin *> enable_pins_{};
|
||||
GPIOPin *dc_pin_{nullptr};
|
||||
|
||||
// other properties set by configuration
|
||||
|
||||
@@ -198,17 +198,12 @@
|
||||
#define USE_MDNS_STORE_SERVICES
|
||||
#define USE_MOTION_TAP
|
||||
#define ETHERNET_INFO_IP_SENSOR_COUNT 5
|
||||
#define EPAPER_SPI_ENABLE_PIN_COUNT 2
|
||||
#define GPS_LISTENER_COUNT 1
|
||||
#define IT8951_ENABLE_PIN_COUNT 2
|
||||
#define HDMI_CEC_MESSAGE_CALLBACK_COUNT 2
|
||||
#define I2C_PORT_FREQUENCY_COUNT 1
|
||||
#define LD600X_AREA_KINDS 3
|
||||
#define LD600X_MAX_TARGETS 3
|
||||
#define MDNS_SERVICE_COUNT 3
|
||||
#define MIPI_DSI_ENABLE_PIN_COUNT 2
|
||||
#define MIPI_RGB_ENABLE_PIN_COUNT 2
|
||||
#define MIPI_SPI_ENABLE_PIN_COUNT 2
|
||||
#define USE_MDNS_DYNAMIC_TXT
|
||||
#define USE_MDNS_EXTRA_SERVICES
|
||||
#define MDNS_DYNAMIC_TXT_COUNT 2
|
||||
|
||||
@@ -6,11 +6,12 @@ import re
|
||||
|
||||
|
||||
def _enable_pin_numbers(main_cpp: str) -> list[int]:
|
||||
"""Get the GPIO numbers passed to register_enable_pin() in the generated code."""
|
||||
"""Get the GPIO numbers passed to set_enable_pins() in the generated code."""
|
||||
match = re.search(r"epaper_display->set_enable_pins\(\{(.*)\}\);", main_cpp)
|
||||
if match is None:
|
||||
return []
|
||||
numbers = []
|
||||
for pin_id in re.findall(
|
||||
r"epaper_display->register_enable_pin\((\w+)\);", main_cpp
|
||||
):
|
||||
for pin_id in match.group(1).split(", "):
|
||||
pin = re.search(rf"{pin_id}->set_pin\(::GPIO_NUM_(\d+)\);", main_cpp)
|
||||
assert pin is not None
|
||||
numbers.append(int(pin.group(1)))
|
||||
|
||||
@@ -986,8 +986,9 @@ def test_enable_pin_code_generation(
|
||||
pin_25 = pin_var_for(25)
|
||||
pin_26 = pin_var_for(26)
|
||||
|
||||
# Both pin objects must be registered with the display, in the configured order.
|
||||
assert re.findall(r"->register_enable_pin\((\w+)\);", main_cpp) == [pin_25, pin_26]
|
||||
# Both pin objects must be passed to the display via set_enable_pins() as a
|
||||
# std::vector initializer list, in the configured order.
|
||||
assert f"set_enable_pins({{{pin_25}, {pin_26}}});" in main_cpp
|
||||
|
||||
|
||||
def test_full_update_next_action_code_generation(
|
||||
|
||||
@@ -37,7 +37,9 @@ def test_reterminal_e1003_enable_pin_used_elsewhere(
|
||||
"""A default enable pin used by a switch is left out, and the other is still applied."""
|
||||
main_cpp = generate_main(component_fixture_path("enable_pins.yaml"))
|
||||
|
||||
pin_ids = re.findall(r"epaper_display->register_enable_pin\((\w+)\);", main_cpp)
|
||||
match = re.search(r"epaper_display->set_enable_pins\(\{(.*)\}\);", main_cpp)
|
||||
assert match is not None
|
||||
pin_ids = match.group(1).split(", ")
|
||||
assert len(pin_ids) == 1
|
||||
assert f"{pin_ids[0]}->set_pin(::GPIO_NUM_11);" in main_cpp
|
||||
assert "logic_supply->set_pin(" in main_cpp
|
||||
@@ -32,7 +32,9 @@ def test_default_enable_pins_by_address(
|
||||
|
||||
main_cpp = generate_main(component_fixture_path("enable_pins_address.yaml"))
|
||||
|
||||
pin_ids = re.findall(r"default_pins->register_enable_pin\((\w+)\);", main_cpp)
|
||||
match = re.search(r"default_pins->set_enable_pins\(\{(.*)\}\);", main_cpp)
|
||||
assert match is not None
|
||||
pin_ids = match.group(1).split(", ")
|
||||
assert len(pin_ids) == 1
|
||||
assert f"{pin_ids[0]}->set_parent(pi4ioe1);" in main_cpp
|
||||
assert f"{pin_ids[0]}->set_pin(1);" in main_cpp
|
||||
@@ -6,9 +6,11 @@ import re
|
||||
|
||||
|
||||
def _enable_pin_numbers(main_cpp: str) -> list[int]:
|
||||
"""Get the expander pin numbers passed to register_enable_pin() in the generated code."""
|
||||
"""Get the expander pin numbers passed to set_enable_pins() in the generated code."""
|
||||
match = re.search(r"default_pins->set_enable_pins\(\{(.*)\}\);", main_cpp)
|
||||
assert match is not None
|
||||
numbers = []
|
||||
for pin_id in re.findall(r"default_pins->register_enable_pin\((\w+)\);", main_cpp):
|
||||
for pin_id in match.group(1).split(", "):
|
||||
pin = re.search(rf"{pin_id}->set_pin\((\d+)\);", main_cpp)
|
||||
assert pin is not None
|
||||
numbers.append(int(pin.group(1)))
|
||||
|
||||
Reference in new issue
Block a user