Arduino
Arduino copied to clipboard
Full consolidation of "phase locking" and "PWM locking" waveform generators
This now needs review and testing. At time of publishing, the following MCVE works for eyes and ears, not tested with an oscilloscope by myself yet:
#include <PolledTimeout.h>
#ifndef D5
#define D5 (14)
#endif
uint8_t brightness = 255;
uint8_t brightnessAdj = 1;
void setup()
{
tone(D5, 440, 3 * 2560);
analogWrite(LED_BUILTIN, brightness);
}
esp8266::polledTimeout::periodicMs changeBrightness(10);
void loop()
{
if (changeBrightness)
{
if (!brightness || !static_cast<uint8_t>(~brightness))
{
brightnessAdj = ~brightnessAdj;
++brightnessAdj;
}
brightness += brightnessAdj;
analogWrite(LED_BUILTIN, brightness);
}
}
Fixes #8081.