ESP32 I2S Call used. Seconds jumps sometimes. Not glitches or wrong color

This commit is contained in:
coelner 2020-12-27 14:35:16 +01:00
parent d21301a1e8
commit 1f27ce7fa0

View File

@ -44,7 +44,8 @@ RgbwColor temp;
#define MINIMAL_BRIGHTNESS 20
#define LDR_SCALE 16
#define colorSaturation 192
NeoPixelBrightnessBus<NeoGrbFeature, Neo800KbpsMethod> strip(NUM_LEDS, DATA_PIN);
//NeoPixelBrightnessBus<NeoGrbFeature, Neo800KbpsMethod> strip(NUM_LEDS, DATA_PIN);
NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp32I2s1800KbpsMethod> strip(NUM_LEDS, DATA_PIN);
RgbColor red(colorSaturation, 0, 0);
RgbColor green(0, colorSaturation, 0);
RgbColor blue(0, 0, colorSaturation);
@ -239,7 +240,7 @@ void syncNTP() {
}
void setup() {
//interrupt for one second@80Mhz!
//interrupt for one second
timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &onTimer, true);
timerAlarmWrite(timer, 1000000, true);
@ -250,9 +251,9 @@ void setup() {
Serial.begin(SERIAL_BAUD);
Serial.flush();
Serial.print("CPU Frequency is: ");
Serial.print("\nCPU Frequency is: ");
Serial.print(getCpuFrequencyMhz()); //Get CPU clock
Serial.print(" Mhz");
Serial.println(" Mhz");
strip.Begin();
strip.SetBrightness( MINIMAL_BRIGHTNESS );
@ -276,8 +277,10 @@ void loop()
{
// -- doLoop should be called as frequently as possible.
iotWebConf.doLoop();
while (Serial.available())
/*
while (Serial.available())
Serial.read();
*/
if (!setupDone && interruptCounter > 0) {
if (currentSec < 0) {
currentSec = 59;
@ -293,9 +296,7 @@ void loop()
currentSec--;
portEXIT_CRITICAL(&timerMux);
}
while (setupDone && interruptCounter > 0) {
if (setupDone && interruptCounter > 0) {
//brigthness measurement
ldrValue = (ldrValue + analogRead(LDR_PIN));
//Serial.println(ldrValue);