This commit is contained in:
J. Nick Koston
2025-12-27 21:27:34 -10:00
parent ca3b9a0e55
commit 53fa89d0e3
2 changed files with 9 additions and 6 deletions

View File

@@ -23,7 +23,7 @@ def require_waveform() -> None:
to save ~580 bytes of RAM (wvfState 512B + pwmState 68B).
Example:
from esphome.components.esp8266.const import require_waveform
from .const import require_waveform
async def to_code(config):
require_waveform()

View File

@@ -6,21 +6,22 @@
// we exclude core_esp8266_waveform_pwm.cpp from the build to save ~580 bytes
// of RAM (wvfState 512B + pwmState 68B).
//
// However, digitalWrite() unconditionally calls stopWaveform() and _stopPWM()
// to ensure any active waveform is stopped before changing pin state.
// These stubs satisfy those calls when the real waveform code is excluded.
// These stubs satisfy calls from the Arduino GPIO code when the real
// waveform implementation is excluded.
#include <cstdint>
namespace esphome::esp8266 {
extern "C" {
// Called by digitalWrite() to stop any waveform on a pin
// Called by Arduino GPIO code to stop any waveform on a pin
int stopWaveform(uint8_t pin) {
(void) pin;
return 1; // Success (no waveform to stop)
}
// Called by digitalWrite() to stop any PWM on a pin
// Called by Arduino GPIO code to stop any PWM on a pin
bool _stopPWM(uint8_t pin) {
(void) pin;
return false; // No PWM was running
@@ -28,4 +29,6 @@ bool _stopPWM(uint8_t pin) {
} // extern "C"
} // namespace esphome::esp8266
#endif // USE_ESP8266_WAVEFORM_STUBS