adding low battery beep

This commit is contained in:
richonguzman 2023-09-23 10:10:02 -03:00
parent 246d083a8c
commit 6f2c8ca1b6
8 changed files with 51 additions and 24 deletions

View File

@ -1,7 +1,7 @@
{
"beacons": [
{
"callsign": "NOCALL-7",
"callsign": "CD2RXU-7",
"symbol": "[",
"overlay": "/",
"comment": "",
@ -18,7 +18,7 @@
}
},
{
"callsign": "NOCALL-7",
"callsign": "CD2RXU-7",
"symbol": ">",
"overlay": "/",
"comment": "",
@ -35,7 +35,7 @@
}
},
{
"callsign": "NOCALL-7",
"callsign": "CD2RXU-7",
"symbol": "j",
"overlay": "/",
"comment": "",
@ -86,16 +86,17 @@
"active": false
},
"notification": {
"ledTx": false,
"ledTx": true,
"ledTxPin": 13,
"ledMessage": false,
"ledMessage": true,
"ledMessagePin": 2,
"buzzerActive": false,
"buzzerActive": true,
"buzzerPinTone": 33,
"buzzerPinVcc": 25,
"bootUpBeep": false,
"txBeep": false,
"messageRxBeep": false,
"stationBeep": false
"bootUpBeep": true,
"txBeep": true,
"messageRxBeep": true,
"stationBeep": true,
"lowBatteryBeep": true
}
}

View File

@ -30,7 +30,7 @@ TinyGPSPlus gps;
BluetoothSerial SerialBT;
OneButton userButton = OneButton(BUTTON_PIN, true, true);
String versionDate = "2023.09.18";
String versionDate = "2023.09.23";
int myBeaconsIndex = 0;
int myBeaconsSize = Config.beacons.size();
@ -55,6 +55,7 @@ bool bluetoothConnected = false;
bool messageLed = false;
uint32_t messageLedTime = millis();
int batteryPercent = 81;
uint32_t lastTx = 0.0;
uint32_t txInterval = 60000L;

View File

@ -70,6 +70,7 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) {
notification.txBeep = data["notification"]["txBeep"].as<bool>();
notification.messageRxBeep = data["notification"]["messageRxBeep"].as<bool>();
notification.stationBeep = data["notification"]["stationBeep"].as<bool>();
notification.lowBatteryBeep = data["notification"]["lowBatteryBeep"].as<bool>();
simplifiedTrackerMode = data["other"]["simplifiedTrackerMode"].as<bool>();
showSymbolOnScreen = data["other"]["showSymbolOnScreen"].as<bool>();

View File

@ -58,6 +58,7 @@ public:
bool txBeep;
bool messageRxBeep;
bool stationBeep;
bool lowBatteryBeep;
};

View File

@ -7,7 +7,7 @@
#include "display.h"
#include "TimeLib.h"
//#define ssd1306 //uncomment this line when using SH1106 screen instead of SSD1306
#define ssd1306 //uncomment this line when using SH1106 screen instead of SSD1306
#ifdef ssd1306
#include <Adafruit_SSD1306.h>

View File

@ -1,5 +1,6 @@
#include <TinyGPS++.h>
#include <vector>
#include "notification_utils.h"
#include "custom_characters.h"
#include "station_utils.h"
#include "configuration.h"
@ -20,6 +21,7 @@ extern std::vector<String> loadedAPRSMessages;
extern int messagesIterator;
extern uint32_t menuTime;
extern bool symbolAvailable;
extern int batteryPercent;
namespace MENU_Utils {
@ -132,27 +134,40 @@ namespace MENU_Utils {
if (powerManagement.getBatteryInfoIsConnected()) {
String batteryVoltage = powerManagement.getBatteryInfoVoltage();
String batteryChargeCurrent = powerManagement.getBatteryInfoCurrent();
String batteryCharge = powerManagement.getBatteryInfoCurrent();
#ifdef TTGO_T_Beam_V0_7
sixthRowMainMenu = "Bat: " + batteryVoltage + "V";
#endif
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
if (batteryChargeCurrent.toInt() == 0) {
if (batteryCharge.toInt() == 0) {
sixthRowMainMenu = "Battery Charged " + batteryVoltage + "V";
} else if (batteryChargeCurrent.toInt() > 0) {
} else if (batteryCharge.toInt() > 0) {
sixthRowMainMenu = "Bat: " + batteryVoltage + "V (charging)";
} else {
sixthRowMainMenu = "Battery " + batteryVoltage + "V " + batteryChargeCurrent + "mA";
sixthRowMainMenu = "Battery " + batteryVoltage + "V " + batteryCharge + "mA";
}
#endif
#ifdef TTGO_T_Beam_V1_2
if (Config.notification.lowBatteryBeep && !powerManagement.isChargeing() && batteryCharge.toInt() < batteryPercent) {
Serial.println(batteryPercent);
Serial.println(batteryCharge.toInt());
Serial.println("--");
batteryPercent = batteryCharge.toInt();
NOTIFICATION_Utils::lowBatteryBeep();
if (batteryCharge.toInt() < 76) {
NOTIFICATION_Utils::lowBatteryBeep();
}
}
if (powerManagement.isChargeing()) {
batteryPercent = 81;
}
batteryVoltage = batteryVoltage.toFloat()/1000;
if (powerManagement.isChargeing() && batteryChargeCurrent!="100") {
if (powerManagement.isChargeing() && batteryCharge!="100") {
sixthRowMainMenu = "Bat: " + String(batteryVoltage) + "V (charging)";
} else if (!powerManagement.isChargeing() && batteryChargeCurrent=="100") {
} else if (!powerManagement.isChargeing() && batteryCharge=="100") {
sixthRowMainMenu = "Battery Charged " + String(batteryVoltage) + "V";
} else {
sixthRowMainMenu = "Battery " + String(batteryVoltage) + "V " + batteryChargeCurrent + "%";
sixthRowMainMenu = "Battery " + String(batteryVoltage) + "V " + batteryCharge + "%";
}
#endif
} else {

View File

@ -8,9 +8,8 @@ int pauseDuration = 20;
int startUpSound[] = {440, 880, 440, 1760};
int startUpSoundDuration[] = {100, 100, 100, 200};
int shutDownSound[] = {1720, 880, 400};
int shutDownSoundDuration[] = {60, 60, 200};
//int shutDownSound[] = {1720, 880, 400};
//int shutDownSoundDuration[] = {60, 60, 200};
extern Configuration Config;
@ -45,12 +44,20 @@ namespace NOTIFICATION_Utils {
digitalWrite(Config.notification.buzzerPinVcc, LOW);
}
void shutDownBeep() {
/*void shutDownBeep() {
digitalWrite(Config.notification.buzzerPinVcc, HIGH);
for (int i = 0; i < sizeof(shutDownSound) / sizeof(shutDownSound[0]); i++) {
playTone(shutDownSound[i], shutDownSoundDuration[i]);
}
digitalWrite(Config.notification.buzzerPinVcc, LOW);
}*/
void lowBatteryBeep() {
digitalWrite(Config.notification.buzzerPinVcc, HIGH);
playTone(1600,100);
playTone(1600,100);
playTone(800,100);
digitalWrite(Config.notification.buzzerPinVcc, LOW);
}
void start() {

View File

@ -9,7 +9,8 @@ void playTone(int frequency, int duration);
void beaconTxBeep();
void messageBeep();
void stationHeardBeep();
void shutDownBeep();
//void shutDownBeep();
void lowBatteryBeep();
void start();
}