diff --git a/MultiMatrix.ino b/MultiMatrix.ino index 1db97f1..3995a7d 100644 --- a/MultiMatrix.ino +++ b/MultiMatrix.ino @@ -42,6 +42,7 @@ float lux = 1.00f; const int potPin = GPIO_NUM_6; int adcResult = 0; uint8_t targetBrightness = 255; +uint8_t currentBrightness = 255; #define NUM_SAMPLES 64 // Gang i don't know JPEGDEC jpeg; @@ -392,6 +393,12 @@ void refreshToken() { http.end(); } +void adjustBrightness(){ + if(targetBrightness != currentBrightness){ + dma_display->setPanelBrightness(targetBrightness); + currentBrightness = targetBrightness; + } +} String getTrack() { HTTPClient http; @@ -460,7 +467,6 @@ void spotifyTask(void *parameter) { } void panelTask(void *parameter) { const TickType_t framePeriod = pdMS_TO_TICKS(33); - ; String time = ntp.formattedTime("%m%e"); if (time == String("11 1")) { Serial.println("HAPPY BIRTHDAY"); @@ -468,7 +474,6 @@ void panelTask(void *parameter) { int start = millis(); Serial.printf("Successfully opened GIF; Canvas size = %d x %d\n", gif.getCanvasWidth(), gif.getCanvasHeight()); while (millis() - start < 5000) { - dma_display->setBrightness(targetBrightness); while (gif.playFrame(true, NULL)) { dma_display->clearScreen(); for (int y = 0; y < 64; y++) { @@ -489,7 +494,7 @@ void panelTask(void *parameter) { float deltaTime = (now - previousFrame) * portTICK_PERIOD_MS / 1000.0f; previousFrame = now; if (lux > 0.00 || switchState) { - dma_display->setBrightness(targetBrightness); + adjustBrightness(); if (!playing) { Serial.println("Entering Idle."); if (gif.open((uint8_t *)idle_gif, sizeof(idle_gif), GIFDraw)) { @@ -498,7 +503,7 @@ void panelTask(void *parameter) { if (lux == 0.00 && !switchState) { break; } - dma_display->setBrightness(targetBrightness); + adjustBrightness(); while (gif.playFrame(true, NULL)) { dma_display->clearScreen(); for (int y = 0; y < 64; y++) { @@ -588,7 +593,7 @@ void setup() { xTaskCreatePinnedToCore( panelTask, "panelTask", - 2048, + 2560, NULL, 1, &taskPanelHandle,