Closed iu2frl closed 2 years ago
i got it with very few lines:
declare:
ulong oled_timeout = 20000;
bool tempOled = true;
ulong oled_timer = millis();
then create:
void enableOled() {
tempOled = true;
oled_timer = millis() + oled_timeout;
}
change first button detect (lines 850) to:
if(digitalRead(BUTTON)==LOW && key_up == true){
key_up = false;
delay(50);
if(digitalRead(BUTTON)==LOW){
delay(300);
time_delay = millis() + 1500;
if(digitalRead(BUTTON)==HIGH){
// ------- begin modification ----------
// if OLED is off turn it on, if it is ON then send beacon manually
if (!tempOled) {
// turn ON OLED temporary
enableOled();
//----------- end -------------
} else {
if(gps_state == true && gps.location.isValid()){
writedisplaytext("((MAN TX))","","","","","");
sendpacket();
}else{
writedisplaytext("((FIX TX))","","","","","");
sendpacket();
}
}
key_up = true;
}
}
}
and add a function to turn off the oled right in the main loop, right after the first button detect:
// Only wake up OLED when necessary
display.dim(!tempOled);
if (tempOled && millis()>= oled_timer) {
tempOled = false;
}
//------------------------------------
whenever need in the code to show anything on the OLED just run:
enableOled()
and that's it, more power save!
Luca can you do a pull request from this?
I'm still working on this, i'd like to make it a little better
Done, pull request has been sent
I have already accepted your pull request. I have released the compilation on github,added you to the list of developers....
After the first startup, the parameter "Display show RX time (s)" is ignored OLED is blanked right after the startup. I wonder if this function should not have an off switch on the web page
I'll get this
Done, will merge it soon
i'm currently adding the HTML function
I'm working on getting the parameters stored but i can't sort it out, i've added the textbox in the html page, data is being sent and saved but at next reboot it restores old value
Done, added in pull request #73. Fixed first awake timer and added in html page
To better save power it would be useful to enable OLED just when necessary (such as when receiving packets or pressing a button). For example with OLED in power save mode one short press of user button can wake up the display and with OLED ON a short press can send manual position