From c62d406d87be204348011aac13db026e75956b7a Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 18 Jun 2023 21:07:45 +0800 Subject: [PATCH] Slow down display of BW and SNR Add a timer for display. --- TEF6686_ESP32.ino | 56 ++++++++++++++++++++++++++++------------------- src/TEF6686.h | 4 ++++ 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/TEF6686_ESP32.ino b/TEF6686_ESP32.ino index 35bcc6e..4f91ede 100644 --- a/TEF6686_ESP32.ino +++ b/TEF6686_ESP32.ino @@ -141,6 +141,8 @@ uint16_t SWMIBandPosold; // Fix Me: Should store this parameter into flash, for String SWMIBandstring = String(); String SWMIBandstringold = String(); int lowsignaltimer; +int bwupdatetimer; +int snrupdatetimer; int menuoption = 30; int MStatusold; int OStatusold; @@ -2809,17 +2811,21 @@ void ShowSignalLevel() { if (screenmute == false) { if (band == BAND_FM) SNR = int(0.46222375 * (float)(SStatus / 10) - 0.082495118 * (float)(USN / 10)) + 10; else SNR = -((int8_t)(USN / 10)); - if (SNR > (SNRold + 1) || SNR < (SNRold - 1)) { - tft.setFreeFont(FONT7); - tft.setTextColor(TFT_BLACK); - if (SNRold == 99) tft.drawRightString("--", 294, 166, GFXFF); else tft.drawRightString(String(SNRold), 294, 166, GFXFF); - tft.setTextColor(TFT_YELLOW, TFT_BLACK); - if (tuned == true) { - tft.drawRightString(String(SNR), 294, 166, GFXFF); - SNRold = SNR; - } else { - tft.drawRightString("--", 294, 166, GFXFF); - SNRold = 99; + if (millis() >= snrupdatetimer + TIMER_500_TICK) { + snrupdatetimer = millis(); + + if (SNR > (SNRold + 1) || SNR < (SNRold - 1)) { + tft.setFreeFont(FONT7); + tft.setTextColor(TFT_BLACK); + if (SNRold == 99) tft.drawRightString("--", 294, 166, GFXFF); else tft.drawRightString(String(SNRold), 294, 166, GFXFF); + tft.setTextColor(TFT_YELLOW, TFT_BLACK); + if (tuned == true) { + tft.drawRightString(String(SNR), 294, 166, GFXFF); + SNRold = SNR; + } else { + tft.drawRightString("--", 294, 166, GFXFF); + SNRold = 99; + } } } @@ -3134,20 +3140,24 @@ void doSquelch() { } void updateBW() { - tft.setFreeFont(FONT7); - if (BWset == 0) { - if (screenmute == false) { - tft.drawRoundRect(249, 35, 68, 20, 5, TFT_WHITE); - tft.setTextColor(TFT_WHITE); - } - radio.setFMABandw(); - } else { - if (screenmute == false) { - tft.drawRoundRect(249, 35, 68, 20, 5, TFT_GREYOUT); - tft.setTextColor(TFT_GREYOUT); + if (millis() >= bwupdatetimer + TIMER_500_TICK) { + bwupdatetimer = millis(); + + tft.setFreeFont(FONT7); + if (BWset == 0) { + if (screenmute == false) { + tft.drawRoundRect(249, 35, 68, 20, 5, TFT_WHITE); + tft.setTextColor(TFT_WHITE); + } + radio.setFMABandw(); + } else { + if (screenmute == false) { + tft.drawRoundRect(249, 35, 68, 20, 5, TFT_GREYOUT); + tft.setTextColor(TFT_GREYOUT); + } } + tft.drawCentreString("AUTO BW", 282, 33, GFXFF); } - tft.drawCentreString("AUTO BW", 282, 33, GFXFF); } void updateiMS() { diff --git a/src/TEF6686.h b/src/TEF6686.h index 8a3a6bb..6f61666 100644 --- a/src/TEF6686.h +++ b/src/TEF6686.h @@ -19,6 +19,10 @@ enum RADIO_TUNE_MODE { TUNE_MAN, TUNE_AUTO, TUNE_MEM, TUNE_MI_BAND }; +#define TIMER_BW_TIMER (TIMER_500_TICK) +#define TIMER_SNR_TIMER (TIMER_500_TICK) +#define TIMER_500_TICK 500 + #define BAT_LEVEL_EMPTY 1600 #define BAT_LEVEL_WARN 1700 #define BAT_LEVEL_FULL 2270