Added OLED timeout
rodzic
9232352c3c
commit
055d3a054e
|
@ -181,6 +181,12 @@ boolean shutdown_active =true;
|
||||||
boolean shutdown_countdown_timer_enable = false;
|
boolean shutdown_countdown_timer_enable = false;
|
||||||
boolean shutdown_usb_status_bef = false;
|
boolean shutdown_usb_status_bef = false;
|
||||||
|
|
||||||
|
// Variables added by LucaFRL
|
||||||
|
ulong oled_timeout = 20000;
|
||||||
|
bool tempOled = true;
|
||||||
|
ulong oled_timer = millis();
|
||||||
|
//-------------------------------
|
||||||
|
|
||||||
#define ANGLE_AVGS 3 // angle averaging - x times
|
#define ANGLE_AVGS 3 // angle averaging - x times
|
||||||
float average_course[ANGLE_AVGS];
|
float average_course[ANGLE_AVGS];
|
||||||
float avg_c_y, avg_c_x;
|
float avg_c_y, avg_c_x;
|
||||||
|
@ -356,7 +362,7 @@ void batt_read(){
|
||||||
BattVolts = axp.getBattVoltage()/1000;
|
BattVolts = axp.getBattVoltage()/1000;
|
||||||
InpVolts = axp.getVbusVoltage()/1000;
|
InpVolts = axp.getVbusVoltage()/1000;
|
||||||
#else
|
#else
|
||||||
BattVolts = analogRead(35)*7.221/4096;
|
BattVolts = analogRead(35)*7.221/8192;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,10 +393,10 @@ void writedisplaytext(String HeaderTxt, String Line1, String Line2, String Line3
|
||||||
display.println(Line5);
|
display.println(Line5);
|
||||||
if (enabled_oled){
|
if (enabled_oled){
|
||||||
//axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); // enable oled
|
//axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); // enable oled
|
||||||
display.dim(true);
|
//display.dim(true);
|
||||||
}else{
|
}else{
|
||||||
//axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF); // disable oled
|
//axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF); // disable oled
|
||||||
display.dim(false);
|
//display.dim(false);
|
||||||
}
|
}
|
||||||
display.display();
|
display.display();
|
||||||
time_to_refresh = millis() + showRXTime;
|
time_to_refresh = millis() + showRXTime;
|
||||||
|
@ -821,6 +827,11 @@ void setup(){
|
||||||
digitalWrite(TXLED, HIGH);
|
digitalWrite(TXLED, HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enableOled() {
|
||||||
|
tempOled = true;
|
||||||
|
oled_timer = millis() + oled_timeout;
|
||||||
|
}
|
||||||
|
|
||||||
// +---------------------------------------------------------------------+//
|
// +---------------------------------------------------------------------+//
|
||||||
// + MAINLOOP -----------------------------------------------------------+//
|
// + MAINLOOP -----------------------------------------------------------+//
|
||||||
// +---------------------------------------------------------------------+//
|
// +---------------------------------------------------------------------+//
|
||||||
|
@ -832,19 +843,36 @@ void loop() {
|
||||||
delay(300);
|
delay(300);
|
||||||
time_delay = millis() + 1500;
|
time_delay = millis() + 1500;
|
||||||
if(digitalRead(BUTTON)==HIGH){
|
if(digitalRead(BUTTON)==HIGH){
|
||||||
if(gps_state == true && gps.location.isValid()){
|
if (!tempOled) {
|
||||||
writedisplaytext("((MAN TX))","","","","","");
|
// turn ON OLED temporary
|
||||||
sendpacket();
|
enableOled();
|
||||||
}else{
|
//----------------------------
|
||||||
writedisplaytext("((FIX TX))","","","","","");
|
} else {
|
||||||
sendpacket();
|
if(gps_state == true && gps.location.isValid()){
|
||||||
|
writedisplaytext("((MAN TX))","","","","","");
|
||||||
|
sendpacket();
|
||||||
|
}else{
|
||||||
|
writedisplaytext("((FIX TX))","","","","","");
|
||||||
|
sendpacket();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
key_up = true;
|
key_up = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only wake up OLED when necessary
|
||||||
|
display.dim(!tempOled);
|
||||||
|
|
||||||
|
if (tempOled && millis()>= oled_timer) {
|
||||||
|
tempOled = false;
|
||||||
|
}
|
||||||
|
//------------------------------------
|
||||||
|
|
||||||
if(digitalRead(BUTTON)==LOW && key_up == false && millis() >= time_delay && t_lock == false){
|
if(digitalRead(BUTTON)==LOW && key_up == false && millis() >= time_delay && t_lock == false){
|
||||||
|
// enable OLED
|
||||||
|
enableOled();
|
||||||
|
//---------------
|
||||||
t_lock = true;
|
t_lock = true;
|
||||||
if(gps_state){
|
if(gps_state){
|
||||||
gps_state = false;
|
gps_state = false;
|
||||||
|
@ -877,6 +905,9 @@ void loop() {
|
||||||
|
|
||||||
if (fixed_beacon_enabled) {
|
if (fixed_beacon_enabled) {
|
||||||
if (millis() >= next_fixed_beacon && !gps_state) {
|
if (millis() >= next_fixed_beacon && !gps_state) {
|
||||||
|
// enable OLED
|
||||||
|
enableOled();
|
||||||
|
//---------------
|
||||||
next_fixed_beacon = millis() + fix_beacon_interval;
|
next_fixed_beacon = millis() + fix_beacon_interval;
|
||||||
writedisplaytext("((AUT TX))", "", "", "", "", "");
|
writedisplaytext("((AUT TX))", "", "", "", "", "");
|
||||||
sendpacket();
|
sendpacket();
|
||||||
|
@ -932,6 +963,9 @@ void loop() {
|
||||||
loraReceivedFrameString = "";
|
loraReceivedFrameString = "";
|
||||||
//int rssi = rf95.lastSNR();
|
//int rssi = rf95.lastSNR();
|
||||||
//Serial.println(rssi);
|
//Serial.println(rssi);
|
||||||
|
// enable OLED
|
||||||
|
enableOled();
|
||||||
|
//---------------
|
||||||
for (int i=0 ; i < loraReceivedLength ; i++) {
|
for (int i=0 ; i < loraReceivedLength ; i++) {
|
||||||
loraReceivedFrameString += (char) lora_RXBUFF[i];
|
loraReceivedFrameString += (char) lora_RXBUFF[i];
|
||||||
}
|
}
|
||||||
|
@ -999,6 +1033,9 @@ void loop() {
|
||||||
}
|
}
|
||||||
if ( (lastTX+nextTX) <= millis() ) {
|
if ( (lastTX+nextTX) <= millis() ) {
|
||||||
if (gps.location.age() < 2000) {
|
if (gps.location.age() < 2000) {
|
||||||
|
// enable OLED
|
||||||
|
enableOled();
|
||||||
|
//---------------
|
||||||
writedisplaytext(" ((TX))","","LAT: "+LatShown,"LON: "+LongShown,"SPD: "+String(gps.speed.kmph(),1)+" CRS: "+String(gps.course.deg(),1),getSatAndBatInfo());
|
writedisplaytext(" ((TX))","","LAT: "+LatShown,"LON: "+LongShown,"SPD: "+String(gps.speed.kmph(),1)+" CRS: "+String(gps.course.deg(),1),getSatAndBatInfo());
|
||||||
sendpacket();
|
sendpacket();
|
||||||
} else {
|
} else {
|
||||||
|
|
Ładowanie…
Reference in New Issue