experimental: display screen saver (auto-off)
This commit is contained in:
parent
3808b0892f
commit
a68cd577e2
|
|
@ -613,6 +613,7 @@ struct st_configitems config_list[] = {
|
|||
{"rxalt", -7, &sonde.config.rxalt},
|
||||
{"screenfile", 0, &sonde.config.screenfile},
|
||||
{"display", -6, sonde.config.display},
|
||||
{"dispsaver", 0, &sonde.config.dispsaver},
|
||||
/* Spectrum display settings */
|
||||
{"spectrum", 0, &sonde.config.spectrum},
|
||||
{"startfreq", 0, &sonde.config.startfreq},
|
||||
|
|
@ -2503,6 +2504,7 @@ void loopDecoder() {
|
|||
//Serial.println("Writing rdzclient OK");
|
||||
}
|
||||
Serial.print("MAIN: updateDisplay started\n");
|
||||
sonde.dispsavectlOFF( (res & 0xff) == 0 ); // handle screen saver (disp auto off)
|
||||
if (forceReloadScreenConfig) {
|
||||
disp.initFromFile(sonde.config.screenfile);
|
||||
sonde.clearDisplay();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ var cfgs = [
|
|||
[ "", "OLED/TFT display configuration", "https://github.com/dl9rdz/rdz_ttgo_sonde/wiki/Display-configuration" ],
|
||||
[ "screenfile", "Screen config (0=automatic; 1-5=predefined; other=custom)" ],
|
||||
[ "display", "Display screens (scan, default, ...)" ],
|
||||
[ "dispsaver", "Display saver (0=never/1=always/2=ifnorx [+10*n: after n sec.])" ],
|
||||
[ "norx_timeout", "No-RX-timeout in seconds (-1=disabled)"],
|
||||
[ "tft_orient", "TFT orientation (0/1/2/3), OLED flip: 3"],
|
||||
[ "", "Spectrum display configuration", "https://github.com/dl9rdz/rdz_ttgo_sonde/wiki/Spectrum-configuration" ],
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ kisstnc.active = 1
|
|||
# second entry: default "Receiver" display
|
||||
# additional entries: alternative receiver display, activated by button
|
||||
display=0,1,2,3,4
|
||||
# turn off display: 0=never, 1=always, 2=if no RX; (+n*10: after n seconds)
|
||||
dispsaver=0
|
||||
# set to -1 to disable (used for "N" values in timers in screens.txt). Value in seconds
|
||||
norx_timeout=20
|
||||
#-------------------------------#
|
||||
|
|
|
|||
|
|
@ -779,6 +779,7 @@ void Display::init() {
|
|||
delay(100);
|
||||
Serial.println("Display initialized");
|
||||
rdis->clear();
|
||||
dispstate = 1; // display active by default
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1773,10 +1774,30 @@ void Display::updateDisplayIP() {
|
|||
}
|
||||
|
||||
void Display::updateDisplay() {
|
||||
if( dispstate == 0 ) return; // do not display anything
|
||||
calcGPS();
|
||||
for(DispEntry *di=layout->de; di->func != NULL; di++) {
|
||||
di->func(di);
|
||||
}
|
||||
}
|
||||
|
||||
// Called when key is pressed or new RX starts
|
||||
void Display::dispsavectlON() {
|
||||
// nothing to do to turn display on, may add power on code here later
|
||||
dispstate = 1;
|
||||
}
|
||||
|
||||
// Should be called 1x / sec to update display
|
||||
// parameter: rxactive (1=currently receiving something, 0=no rx)
|
||||
void Display::dispsavectlOFF(int rxactive) {
|
||||
if( sonde.config.dispsaver == 0 ) return; // screensaver disabled
|
||||
if( dispstate == 0 ) return; // already OFF
|
||||
if( rxactive && ((sonde.config.dispsaver%10)==2) ) return; // OFF only if no RX, but rxactive is 0
|
||||
dispstate++;
|
||||
if( dispstate > (sonde.config.dispsaver/10) ) {
|
||||
rdis->clear();
|
||||
dispstate = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Display disp = Display();
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ public:
|
|||
DispInfo *layouts;
|
||||
int nLayouts;
|
||||
static RawDisplay *rdis;
|
||||
char dispstate;
|
||||
|
||||
Display();
|
||||
void init();
|
||||
|
|
@ -193,7 +194,8 @@ public:
|
|||
void updateDisplayRXConfig();
|
||||
void updateDisplayIP();
|
||||
void updateDisplay();
|
||||
|
||||
void dispsavectlON();
|
||||
void dispsavectlOFF(int rxactive);
|
||||
void setLayout(int layout);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -490,6 +490,7 @@ void Sonde::receive() {
|
|||
if(si->lastState != 1) {
|
||||
si->rxStart = millis();
|
||||
si->lastState = 1;
|
||||
sonde.dispsavectlON();
|
||||
}
|
||||
} else { // RX Timeout
|
||||
//Serial.printf("Sonde::receive(): result %d (%s), laststate was %d\n", res, (res<=3)?RXstr[res]:"?", si->lastState);
|
||||
|
|
@ -507,6 +508,7 @@ void Sonde::receive() {
|
|||
|
||||
int event = getKeyPressEvent();
|
||||
if (!event) event = timeoutEvent(si);
|
||||
else sonde.dispsavectlON();
|
||||
int action = (event==EVT_NONE) ? ACT_NONE : disp.layout->actions[event];
|
||||
//if(action!=ACT_NONE) { Serial.printf("event %x: action is %x\n", event, action); }
|
||||
// If action is to move to a different sonde index, we do update things here, set activate
|
||||
|
|
@ -716,6 +718,15 @@ void Sonde::clearDisplay() {
|
|||
disp.rdis->clear();
|
||||
}
|
||||
|
||||
void Sonde::dispsavectlON() {
|
||||
disp.dispsavectlON();
|
||||
}
|
||||
|
||||
void Sonde::dispsavectlOFF(int rxactive) {
|
||||
disp.dispsavectlOFF(rxactive);
|
||||
}
|
||||
|
||||
|
||||
SondeType Sonde::realType(SondeInfo *si) {
|
||||
if(TYPE_IS_METEO(si->type) && si->d.subtype>0 ) { return si->d.subtype==1 ? STYPE_M10:STYPE_M20; }
|
||||
else return si->type;
|
||||
|
|
|
|||
|
|
@ -263,6 +263,8 @@ typedef struct st_rdzconfig {
|
|||
int wifi; // connect to known WLAN 0=skip
|
||||
int screenfile;
|
||||
int8_t display[30]; // list of display mode (0:scanner, 1:default, 2,... additional modes)
|
||||
int dispsaver; // Turn display on/off (0=always on, 10*n+1: off after n seconds,
|
||||
// 10*n+2: scanner off after n seconds, RX always shown)
|
||||
int startfreq; // spectrum display start freq (400, 401, ...)
|
||||
int channelbw; // spectrum channel bandwidth (valid: 5, 10, 20, 25, 50, 100 kHz)
|
||||
int spectrum; // show freq spectrum for n seconds -1=disable; 0=forever
|
||||
|
|
@ -360,6 +362,8 @@ public:
|
|||
void updateDisplayIP();
|
||||
void updateDisplay();
|
||||
void clearDisplay();
|
||||
void dispsavectlON();
|
||||
void dispsavectlOFF(int rxactive);
|
||||
|
||||
void setIP(String ip, bool isAP);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ const char *getType(SondeInfo *si) {
|
|||
return sondeTypeStrSH[sonde.realType(si)];
|
||||
}
|
||||
|
||||
int float2json(char **buf, int *maxlen, char *fmt, float value) {
|
||||
int float2json(char **buf, int *maxlen, const char *fmt, float value) {
|
||||
if(isnan(value)) return 0;
|
||||
int n = snprintf(*buf, *maxlen, fmt, value);
|
||||
if(n>*maxlen) return -1;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const char *version_name = "rdzTTGOsonde";
|
||||
const char *version_id = "devel20220414";
|
||||
const char *version_id = "devel20220418";
|
||||
const int SPIFFS_MAJOR=2;
|
||||
const int SPIFFS_MINOR=16;
|
||||
|
|
|
|||
Loading…
Reference in New Issue