diff --git a/TEF6686_ESP32.ino b/TEF6686_ESP32.ino index 2e1fcd1..3d9983d 100644 --- a/TEF6686_ESP32.ino +++ b/TEF6686_ESP32.ino @@ -227,6 +227,7 @@ int BWAutoColorSmooth; int BWOld; int bwupdatetimer; int DeEmphasis; +int DisplayedSegments; int ForceMono; int FrameColor; int FreqColor; @@ -374,6 +375,8 @@ unsigned long eonticker; unsigned long eontickerhold; unsigned long flashingtimer; unsigned long lowsignaltimer; +unsigned long ModulationpreviousMillis; +unsigned long ModulationpeakPreviousMillis; unsigned long peakholdmillis; unsigned long pslongticker; unsigned long pslongtickerhold; @@ -1112,7 +1115,7 @@ void loop() { WakeToSleep(REVERSE); while (digitalRead(BWBUTTON) == LOW); } else { - if (!screenmute && !afscreen) BWButtonPress(); + if (!screenmute && !afscreen) BWButtonPress(); } } @@ -3246,24 +3249,38 @@ void ShowModLevel() { MStatus = 0; MStatusold = 1; } + segments = map(MStatus, 0, 120, 0, 94); - if (segments > peakholdold) { - peakholdold = segments; + if (segments < DisplayedSegments && (millis() - ModulationpreviousMillis >= 20)) { + DisplayedSegments = max(DisplayedSegments - 3, segments); + ModulationpreviousMillis = millis(); + } else if (segments > DisplayedSegments) { + DisplayedSegments = segments; + } + + if (DisplayedSegments > peakholdold) { + peakholdold = DisplayedSegments; peakholdmillis = millis(); } - tft.fillRect(16, 133, 2 * constrain(segments, 0, 54), 6, ModBarInsignificantColor); - tft.fillRect(16 + 2 * 54, 133, 2 * (constrain(segments, 54, 94) - 54), 6, ModBarSignificantColor); - tft.fillRect(16 + 2 * constrain(segments, 0, 94), 133, 2 * (94 - constrain(segments, 0, 94)), 6, GreyoutColor); + if (millis() - peakholdmillis >= 1000) { + if (millis() - ModulationpeakPreviousMillis >= 20) { + peakholdold = max(peakholdold - 3, DisplayedSegments); + ModulationpeakPreviousMillis = millis(); + } + } + + tft.fillRect(16, 133, 2 * 94, 6, GreyoutColor); + tft.fillRect(16, 133, 2 * constrain(DisplayedSegments, 0, 54), 6, ModBarInsignificantColor); + tft.fillRect(16 + 2 * 54, 133, 2 * (constrain(DisplayedSegments, 54, 94) - 54), 6, ModBarSignificantColor); + tft.fillRect(16 + 2 * constrain(DisplayedSegments, 0, 94), 133, 2 * (94 - constrain(DisplayedSegments, 0, 94)), 6, GreyoutColor); int peakHoldPosition = 16 + 2 * constrain(peakholdold, 0, 94); tft.fillRect(peakHoldPosition, 133, 2, 6, (MStatus > 80) ? ModBarSignificantColor : PrimaryColor); - if (millis() - peakholdmillis >= 1000) { + if (millis() - peakholdmillis >= 1000 && peakholdold == DisplayedSegments) { tft.fillRect(peakHoldPosition, 133, 2, 6, GreyoutColor); - peakholdold = segments; - peakholdmillis = millis(); } } }