display: set OLED contrast (config option); oled screen saver: also hide RSSI/stat
This commit is contained in:
parent
6dad96d44f
commit
8b59a0d1c9
|
|
@ -614,6 +614,7 @@ struct st_configitems config_list[] = {
|
||||||
{"screenfile", 0, &sonde.config.screenfile},
|
{"screenfile", 0, &sonde.config.screenfile},
|
||||||
{"display", -6, sonde.config.display},
|
{"display", -6, sonde.config.display},
|
||||||
{"dispsaver", 0, &sonde.config.dispsaver},
|
{"dispsaver", 0, &sonde.config.dispsaver},
|
||||||
|
{"dispcontrast", 0, &sonde.config.dispcontrast},
|
||||||
/* Spectrum display settings */
|
/* Spectrum display settings */
|
||||||
{"spectrum", 0, &sonde.config.spectrum},
|
{"spectrum", 0, &sonde.config.spectrum},
|
||||||
{"startfreq", 0, &sonde.config.startfreq},
|
{"startfreq", 0, &sonde.config.startfreq},
|
||||||
|
|
@ -811,6 +812,9 @@ const char *handleConfigPost(AsyncWebServerRequest * request) {
|
||||||
f.close();
|
f.close();
|
||||||
Serial.printf("Re-reading file file\n");
|
Serial.printf("Re-reading file file\n");
|
||||||
setupConfigData();
|
setupConfigData();
|
||||||
|
// TODO: Check if this is better done elsewhere?
|
||||||
|
// Use new config (whereever this is feasible without a reboot)
|
||||||
|
disp.setContrast();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ var cfgs = [
|
||||||
[ "screenfile", "Screen config (0=automatic; 1-5=predefined; other=custom)" ],
|
[ "screenfile", "Screen config (0=automatic; 1-5=predefined; other=custom)" ],
|
||||||
[ "display", "Display screens (scan, default, ...)" ],
|
[ "display", "Display screens (scan, default, ...)" ],
|
||||||
[ "dispsaver", "Display saver (0=never/1=always/2=ifnorx [+10*n: after n sec.])" ],
|
[ "dispsaver", "Display saver (0=never/1=always/2=ifnorx [+10*n: after n sec.])" ],
|
||||||
|
[ "dispcontrast", "OLED contrast (-1=use default; 0..255=set contrast)" ],
|
||||||
[ "norx_timeout", "No-RX-timeout in seconds (-1=disabled)"],
|
[ "norx_timeout", "No-RX-timeout in seconds (-1=disabled)"],
|
||||||
[ "tft_orient", "TFT orientation (0/1/2/3), OLED flip: 3"],
|
[ "tft_orient", "TFT orientation (0/1/2/3), OLED flip: 3"],
|
||||||
[ "", "Spectrum display configuration", "https://github.com/dl9rdz/rdz_ttgo_sonde/wiki/Spectrum-configuration" ],
|
[ "", "Spectrum display configuration", "https://github.com/dl9rdz/rdz_ttgo_sonde/wiki/Spectrum-configuration" ],
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,8 @@ kisstnc.active = 1
|
||||||
display=0,1,2,3,4
|
display=0,1,2,3,4
|
||||||
# turn off display: 0=never, 1=always, 2=if no RX; (+n*10: after n seconds)
|
# turn off display: 0=never, 1=always, 2=if no RX; (+n*10: after n seconds)
|
||||||
dispsaver=0
|
dispsaver=0
|
||||||
|
# set OLED contrast (0..255) or leave at factory default (-1)
|
||||||
|
dispcontrast=-1
|
||||||
# set to -1 to disable (used for "N" values in timers in screens.txt). Value in seconds
|
# set to -1 to disable (used for "N" values in timers in screens.txt). Value in seconds
|
||||||
norx_timeout=20
|
norx_timeout=20
|
||||||
#-------------------------------#
|
#-------------------------------#
|
||||||
|
|
|
||||||
|
|
@ -277,6 +277,7 @@ void U8x8Display::begin() {
|
||||||
}
|
}
|
||||||
u8x8->begin();
|
u8x8->begin();
|
||||||
if(sonde.config.tft_orient==3) u8x8->setFlipMode(true);
|
if(sonde.config.tft_orient==3) u8x8->setFlipMode(true);
|
||||||
|
if(sonde.config.dispcontrast>=0) u8x8->setContrast(sonde.config.dispcontrast);
|
||||||
|
|
||||||
fontlist = fl;
|
fontlist = fl;
|
||||||
nfonts = sizeof(fl)/sizeof(uint8_t *);
|
nfonts = sizeof(fl)/sizeof(uint8_t *);
|
||||||
|
|
@ -287,6 +288,10 @@ void U8x8Display::clear() {
|
||||||
u8x8->clear();
|
u8x8->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void U8x8Display::setContrast(uint8_t contrast) {
|
||||||
|
u8x8->setContrast(contrast);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// For u8x8 oled display: 0=small font, 1=large font 7x14
|
// For u8x8 oled display: 0=small font, 1=large font 7x14
|
||||||
void U8x8Display::setFont(uint8_t fontindex) {
|
void U8x8Display::setFont(uint8_t fontindex) {
|
||||||
|
|
@ -526,6 +531,9 @@ void ILI9225Display::clear() {
|
||||||
SPI_MUTEX_UNLOCK();
|
SPI_MUTEX_UNLOCK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ILI9225Display::setContrast(uint8_t /*contrast*/) {
|
||||||
|
}
|
||||||
|
|
||||||
// for now, 0=small=FreeSans9pt7b, 1=large=FreeSans18pt7b
|
// for now, 0=small=FreeSans9pt7b, 1=large=FreeSans18pt7b
|
||||||
void ILI9225Display::setFont(uint8_t fontindex) {
|
void ILI9225Display::setFont(uint8_t fontindex) {
|
||||||
//if(fontindex==1 || fontindex==2) { fontindex=3; }
|
//if(fontindex==1 || fontindex==2) { fontindex=3; }
|
||||||
|
|
@ -1728,30 +1736,35 @@ void Display::drawText(DispEntry *de) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::updateDisplayPos() {
|
void Display::updateDisplayPos() {
|
||||||
|
if( dispstate == 0 ) return; // do not display anything
|
||||||
for(DispEntry *di=layout->de; di->func != NULL; di++) {
|
for(DispEntry *di=layout->de; di->func != NULL; di++) {
|
||||||
if(di->func != disp.drawLat && di->func != disp.drawLon) continue;
|
if(di->func != disp.drawLat && di->func != disp.drawLon) continue;
|
||||||
di->func(di);
|
di->func(di);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Display::updateDisplayPos2() {
|
void Display::updateDisplayPos2() {
|
||||||
|
if( dispstate == 0 ) return; // do not display anything
|
||||||
for(DispEntry *di=layout->de; di->func != NULL; di++) {
|
for(DispEntry *di=layout->de; di->func != NULL; di++) {
|
||||||
if(di->func != disp.drawAlt && di->func != disp.drawHS && di->func != disp.drawVS) continue;
|
if(di->func != disp.drawAlt && di->func != disp.drawHS && di->func != disp.drawVS) continue;
|
||||||
di->func(di);
|
di->func(di);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Display::updateDisplayID() {
|
void Display::updateDisplayID() {
|
||||||
|
if( dispstate == 0 ) return; // do not display anything
|
||||||
for(DispEntry *di=layout->de; di->func != NULL; di++) {
|
for(DispEntry *di=layout->de; di->func != NULL; di++) {
|
||||||
if(di->func != disp.drawID) continue;
|
if(di->func != disp.drawID) continue;
|
||||||
di->func(di);
|
di->func(di);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Display::updateDisplayRSSI() {
|
void Display::updateDisplayRSSI() {
|
||||||
|
if( dispstate == 0 ) return; // do not display anything
|
||||||
for(DispEntry *di=layout->de; di->func != NULL; di++) {
|
for(DispEntry *di=layout->de; di->func != NULL; di++) {
|
||||||
if(di->func != disp.drawRSSI) continue;
|
if(di->func != disp.drawRSSI) continue;
|
||||||
di->func(di);
|
di->func(di);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Display::updateStat() {
|
void Display::updateStat() {
|
||||||
|
if( dispstate == 0 ) return; // do not display anything
|
||||||
for(DispEntry *di=layout->de; di->func != NULL; di++) {
|
for(DispEntry *di=layout->de; di->func != NULL; di++) {
|
||||||
if(di->func != disp.drawQS) continue;
|
if(di->func != disp.drawQS) continue;
|
||||||
di->func(di);
|
di->func(di);
|
||||||
|
|
@ -1759,6 +1772,7 @@ void Display::updateStat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::updateDisplayRXConfig() {
|
void Display::updateDisplayRXConfig() {
|
||||||
|
if( dispstate == 0 ) return; // do not display anything
|
||||||
for(DispEntry *di=layout->de; di->func != NULL; di++) {
|
for(DispEntry *di=layout->de; di->func != NULL; di++) {
|
||||||
if(di->func != disp.drawQS && di->func != disp.drawAFC) continue;
|
if(di->func != disp.drawQS && di->func != disp.drawAFC) continue;
|
||||||
di->func(di);
|
di->func(di);
|
||||||
|
|
@ -1800,4 +1814,9 @@ void Display::dispsavectlOFF(int rxactive) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Display::setContrast() {
|
||||||
|
if(sonde.config.dispcontrast<0) return;
|
||||||
|
rdis->setContrast(sonde.config.dispcontrast);
|
||||||
|
}
|
||||||
|
|
||||||
Display disp = Display();
|
Display disp = Display();
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ class RawDisplay {
|
||||||
public:
|
public:
|
||||||
virtual void begin() = 0;
|
virtual void begin() = 0;
|
||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
|
virtual void setContrast(uint8_t contrast) = 0;
|
||||||
virtual void setFont(uint8_t fontindex) = 0;
|
virtual void setFont(uint8_t fontindex) = 0;
|
||||||
virtual void getDispSize(uint8_t *height, uint8_t *width, uint8_t *lineskip, uint8_t *colskip) = 0;
|
virtual void getDispSize(uint8_t *height, uint8_t *width, uint8_t *lineskip, uint8_t *colskip) = 0;
|
||||||
virtual void drawString(uint16_t x, uint16_t y, const char *s, int16_t width=WIDTH_AUTO, uint16_t fg=0xffff, uint16_t bg=0 ) = 0;
|
virtual void drawString(uint16_t x, uint16_t y, const char *s, int16_t width=WIDTH_AUTO, uint16_t fg=0xffff, uint16_t bg=0 ) = 0;
|
||||||
|
|
@ -86,6 +87,7 @@ public:
|
||||||
U8x8Display(uint8_t type = 0) { _type = type; }
|
U8x8Display(uint8_t type = 0) { _type = type; }
|
||||||
void begin();
|
void begin();
|
||||||
void clear();
|
void clear();
|
||||||
|
void setContrast(uint8_t contrast);
|
||||||
void setFont(uint8_t fontindex);
|
void setFont(uint8_t fontindex);
|
||||||
void getDispSize(uint8_t *height, uint8_t *width, uint8_t *lineskip, uint8_t *colskip);
|
void getDispSize(uint8_t *height, uint8_t *width, uint8_t *lineskip, uint8_t *colskip);
|
||||||
void drawString(uint16_t x, uint16_t y, const char *s, int16_t width=WIDTH_AUTO, uint16_t fg=0xffff, uint16_t bg=0);
|
void drawString(uint16_t x, uint16_t y, const char *s, int16_t width=WIDTH_AUTO, uint16_t fg=0xffff, uint16_t bg=0);
|
||||||
|
|
@ -110,6 +112,7 @@ public:
|
||||||
ILI9225Display(int type = 1) { _type = type; }
|
ILI9225Display(int type = 1) { _type = type; }
|
||||||
void begin();
|
void begin();
|
||||||
void clear();
|
void clear();
|
||||||
|
void setContrast(uint8_t contrast);
|
||||||
void setFont(uint8_t fontindex);
|
void setFont(uint8_t fontindex);
|
||||||
void getDispSize(uint8_t *height, uint8_t *width, uint8_t *lineskip, uint8_t *colskip);
|
void getDispSize(uint8_t *height, uint8_t *width, uint8_t *lineskip, uint8_t *colskip);
|
||||||
void drawString(uint16_t x, uint16_t y, const char *s, int16_t width=WIDTH_AUTO, uint16_t fg=0xffff, uint16_t bg=0);
|
void drawString(uint16_t x, uint16_t y, const char *s, int16_t width=WIDTH_AUTO, uint16_t fg=0xffff, uint16_t bg=0);
|
||||||
|
|
@ -197,6 +200,7 @@ public:
|
||||||
void dispsavectlON();
|
void dispsavectlON();
|
||||||
void dispsavectlOFF(int rxactive);
|
void dispsavectlOFF(int rxactive);
|
||||||
void setLayout(int layout);
|
void setLayout(int layout);
|
||||||
|
void setContrast();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Display disp;
|
extern Display disp;
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@ void Sonde::defaultConfig() {
|
||||||
config.sx1278_sck = SCK;
|
config.sx1278_sck = SCK;
|
||||||
config.oled_rst = 16;
|
config.oled_rst = 16;
|
||||||
config.disptype = 0;
|
config.disptype = 0;
|
||||||
|
config.dispcontrast = -1;
|
||||||
config.tft_orient = 1;
|
config.tft_orient = 1;
|
||||||
config.button2_axp = 0;
|
config.button2_axp = 0;
|
||||||
config.norx_timeout = 20;
|
config.norx_timeout = 20;
|
||||||
|
|
@ -332,14 +333,6 @@ void Sonde::setConfig(const char *cfg) {
|
||||||
if(i==N_CONFIG) {
|
if(i==N_CONFIG) {
|
||||||
Serial.printf("Invalid config option '%s'=%s \n", cfg, val);
|
Serial.printf("Invalid config option '%s'=%s \n", cfg, val);
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
// currently not in config_list. Maybe add later.
|
|
||||||
} else if(strcmp(cfg,"axudp.symbol")==0) {
|
|
||||||
strncpy(config.udpfeed.symbol, val, 3);
|
|
||||||
} else if(strcmp(cfg,"tcp.symbol")==0) {
|
|
||||||
strncpy(config.tcpfeed.symbol, val, 3);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sonde::setIP(String ip, bool AP) {
|
void Sonde::setIP(String ip, bool AP) {
|
||||||
|
|
|
||||||
|
|
@ -265,6 +265,7 @@ typedef struct st_rdzconfig {
|
||||||
int8_t display[30]; // list of display mode (0:scanner, 1:default, 2,... additional modes)
|
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,
|
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)
|
// 10*n+2: scanner off after n seconds, RX always shown)
|
||||||
|
int dispcontrast; // For OLED: set contrast to 0..255 (-1: don't set/leave at factory default)
|
||||||
int startfreq; // spectrum display start freq (400, 401, ...)
|
int startfreq; // spectrum display start freq (400, 401, ...)
|
||||||
int channelbw; // spectrum channel bandwidth (valid: 5, 10, 20, 25, 50, 100 kHz)
|
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
|
int spectrum; // show freq spectrum for n seconds -1=disable; 0=forever
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@
|
||||||
|
|
||||||
TimerHandle_t mqttReconnectTimer;
|
TimerHandle_t mqttReconnectTimer;
|
||||||
|
|
||||||
|
extern const char *version_name;
|
||||||
|
extern const char *version_id;
|
||||||
|
|
||||||
void mqttCallback(char* topic, byte* payload, unsigned int length) {
|
void mqttCallback(char* topic, byte* payload, unsigned int length) {
|
||||||
Serial.print("Message arrived [");
|
Serial.print("Message arrived [");
|
||||||
Serial.print(topic);
|
Serial.print(topic);
|
||||||
|
|
@ -52,7 +55,8 @@ void MQTT::publishUptime()
|
||||||
//snprintf(payload, 12, "%lu", millis());
|
//snprintf(payload, 12, "%lu", millis());
|
||||||
//snprintf(payload, 124, "{\"uptime\": %lu," "\"user\": \"%s\"", millis(), username );
|
//snprintf(payload, 124, "{\"uptime\": %lu," "\"user\": \"%s\"", millis(), username );
|
||||||
char payload[128];
|
char payload[128];
|
||||||
snprintf(payload, 128, "{\"uptime\": %d, \"user\": \"%s\", \"rxlat\": %.5f, \"rxlon\": %.5f}", millis(), username, sonde.config.rxlat, sonde.config.rxlon );
|
snprintf(payload, 128, "{\"uptime\": %ld, \"user\": \"%s\", \"rxlat\": %.5f, \"rxlon\": %.5f, \"ver\": \"%s\", \"sub\": \"%s\"}",
|
||||||
|
millis(), username, sonde.config.rxlat, sonde.config.rxlon, version_name, version_id);
|
||||||
Serial.println(payload);
|
Serial.println(payload);
|
||||||
char topic[128];
|
char topic[128];
|
||||||
snprintf(topic, 128, "%s%s", this->prefix, "uptime");
|
snprintf(topic, 128, "%s%s", this->prefix, "uptime");
|
||||||
|
|
@ -152,7 +156,7 @@ void MQTT::publishPacket(SondeInfo *si)
|
||||||
strcat(payload, "}"); // terminate payload string
|
strcat(payload, "}"); // terminate payload string
|
||||||
|
|
||||||
char topic[128];
|
char topic[128];
|
||||||
snprintf(topic, 128, "%s%s", this->prefix, "data");
|
snprintf(topic, 128, "%s%s", this->prefix, "packet");
|
||||||
Serial.print(payload);
|
Serial.print(payload);
|
||||||
mqttClient.publish(topic, 1, 1, payload);
|
mqttClient.publish(topic, 1, 1, payload);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const char *version_name = "rdzTTGOsonde";
|
const char *version_name = "rdzTTGOsonde";
|
||||||
const char *version_id = "devel20220418";
|
const char *version_id = "devel20220422";
|
||||||
const int SPIFFS_MAJOR=2;
|
const int SPIFFS_MAJOR=2;
|
||||||
const int SPIFFS_MINOR=16;
|
const int SPIFFS_MINOR=16;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue