1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 08:41:59 +00:00
This commit is contained in:
J. Nick Koston
2025-12-27 21:56:02 -10:00
parent ebe43228e3
commit 05f19ea644
3 changed files with 9 additions and 12 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,16 +3,15 @@
// 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 {
extern "C" {
// Called by Arduino GPIO code to stop any waveform on a pin
@@ -29,6 +28,4 @@ bool _stopPWM(uint8_t pin) {
} // extern "C"
} // namespace esphome::esp8266
#endif // USE_ESP8266_WAVEFORM_STUBS