1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 00:31:58 +00:00

Merge branch 'esp8266_waveform' into integration

This commit is contained in:
J. Nick Koston
2025-12-27 22:02:28 -10:00
4 changed files with 13 additions and 11 deletions

View File

@@ -20,12 +20,12 @@ def require_waveform() -> None:
(startWaveform, stopWaveform, analogWrite, Tone, Servo).
If no component calls this, the waveform code is excluded from the build
to save ~580 bytes of RAM (wvfState 512B + pwmState 68B).
to save ~596 bytes of RAM and 464 bytes of flash.
Example:
from .const import require_waveform
from esphome.components.esp8266.const import require_waveform
async def to_code(config):
require_waveform()
"""
CORE.data[KEY_ESP8266][KEY_WAVEFORM_REQUIRED] = True
CORE.data.setdefault(KEY_ESP8266, {})[KEY_WAVEFORM_REQUIRED] = True

View File

@@ -4,8 +4,8 @@ Import("env") # noqa
import os
# Filter out waveform/PWM code from the Arduino core build
# This saves ~580 bytes of RAM (wvfState 512B + pwmState 68B) by not
# instantiating the waveform generator state structures.
# This saves ~596 bytes of RAM and 464 bytes of flash by not
# instantiating the waveform generator state structures (wvfState + pwmState).
#
# The waveform code is used by: analogWrite, Tone, Servo, and direct
# startWaveform/stopWaveform calls. ESPHome's esp8266_pwm component

View File

@@ -3,15 +3,17 @@
// Stub implementations for Arduino waveform/PWM functions.
//
// When the waveform generator is not needed (no esp8266_pwm component),
// we exclude core_esp8266_waveform_pwm.cpp from the build to save ~580 bytes
// of RAM (wvfState 512B + pwmState 68B).
// we exclude core_esp8266_waveform_pwm.cpp from the build to save ~596 bytes
// of RAM and 464 bytes of flash.
//
// These stubs satisfy calls from the Arduino GPIO code when the real
// waveform implementation is excluded.
// waveform implementation is excluded. They must be in the global namespace
// with C linkage to match the Arduino core function declarations.
#include <cstdint>
namespace esphome::esp8266 {
// Empty namespace to satisfy linter - actual stubs must be at global scope
namespace esphome::esp8266 {} // namespace esphome::esp8266
extern "C" {
@@ -29,6 +31,4 @@ bool _stopPWM(uint8_t pin) {
} // extern "C"
} // namespace esphome::esp8266
#endif // USE_ESP8266_WAVEFORM_STUBS

View File

@@ -552,6 +552,8 @@ def convert_path_to_relative(abspath, current):
exclude=[
"esphome/components/libretiny/generate_components.py",
"esphome/components/web_server/__init__.py",
# const.py has absolute import in docstring example for external components
"esphome/components/esp8266/const.py",
],
)
def lint_relative_py_import(fname: Path, line, col, content):