adding battery info

This commit is contained in:
richonguzman 2023-07-12 01:26:53 -04:00
parent 8db5066752
commit ed1b44b6e9
5 changed files with 24 additions and 8 deletions

View File

@ -1,7 +1,7 @@
{ {
"beacons": [ "beacons": [
{ {
"callsign": "NOCALL-7", "callsign": "CD2RXU-7",
"symbol": "[", "symbol": "[",
"comment": "", "comment": "",
"smart_beacon": { "smart_beacon": {
@ -17,7 +17,7 @@
} }
}, },
{ {
"callsign": "NOCALL-7", "callsign": "CD2RXU-7",
"symbol": ">", "symbol": ">",
"comment": "", "comment": "",
"smart_beacon": { "smart_beacon": {
@ -33,8 +33,8 @@
} }
}, },
{ {
"callsign": "NOCALL-7", "callsign": "CD2RXU-7",
"symbol": "b", "symbol": "j",
"comment": "", "comment": "",
"smart_beacon": { "smart_beacon": {
"active": true, "active": true,
@ -67,6 +67,7 @@
"rememberStationTime": 30, "rememberStationTime": 30,
"maxDistanceToTracker": 30, "maxDistanceToTracker": 30,
"standingUpdateTime": 15, "standingUpdateTime": 15,
"sendAltitude": true "sendAltitude": true,
"sendBatteryInfo": false
} }
} }

View File

@ -82,12 +82,12 @@ void setup() {
GPS_Utils::setup(); GPS_Utils::setup();
LoRa_Utils::setup(); LoRa_Utils::setup();
/*WiFi.mode(WIFI_OFF); WiFi.mode(WIFI_OFF);
btStop(); btStop();
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "WiFi and BT controller stopped"); logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "WiFi and BT controller stopped");
esp_bt_controller_disable(); esp_bt_controller_disable();
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "BT controller disabled");*/ logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "BT controller disabled");
BLE_Utils::setup(); //BLE_Utils::setup();
userButton.attachClick(BUTTON_Utils::singlePress); userButton.attachClick(BUTTON_Utils::singlePress);
userButton.attachLongPressStart(BUTTON_Utils::longPress); userButton.attachLongPressStart(BUTTON_Utils::longPress);

View File

@ -61,6 +61,7 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) {
maxDistanceToTracker = data["other"]["maxDistanceToTracker"].as<int>(); maxDistanceToTracker = data["other"]["maxDistanceToTracker"].as<int>();
standingUpdateTime = data["other"]["standingUpdateTime"].as<int>(); standingUpdateTime = data["other"]["standingUpdateTime"].as<int>();
sendAltitude = data["other"]["sendAltitude"].as<bool>(); sendAltitude = data["other"]["sendAltitude"].as<bool>();
sendBatteryInfo = data["other"]["sendBatteryInfo"].as<bool>();
configFile.close(); configFile.close();
} }

View File

@ -47,6 +47,7 @@ public:
int maxDistanceToTracker; int maxDistanceToTracker;
int standingUpdateTime; int standingUpdateTime;
bool sendAltitude; bool sendAltitude;
bool sendBatteryInfo;
Configuration(); Configuration();
void validateConfigFile(String currentBeaconCallsign); void validateConfigFile(String currentBeaconCallsign);

View File

@ -2,6 +2,7 @@
#include <vector> #include <vector>
#include "station_utils.h" #include "station_utils.h"
#include "configuration.h" #include "configuration.h"
#include "power_utils.h"
#include "lora_utils.h" #include "lora_utils.h"
#include "msg_utils.h" #include "msg_utils.h"
#include "gps_utils.h" #include "gps_utils.h"
@ -13,6 +14,7 @@ extern Configuration Config;
extern Beacon *currentBeacon; extern Beacon *currentBeacon;
extern logging::Logger logger; extern logging::Logger logger;
extern TinyGPSPlus gps; extern TinyGPSPlus gps;
extern PowerManagement powerManagement;
extern std::vector<String> lastHeardStation; extern std::vector<String> lastHeardStation;
extern std::vector<String> lastHeardStation_temp; extern std::vector<String> lastHeardStation_temp;
extern String fourthLine; extern String fourthLine;
@ -395,6 +397,17 @@ void sendBeacon() {
} }
} }
if (Config.sendBatteryInfo) {
String batteryVoltage = powerManagement.getBatteryInfoVoltage();
String batteryChargeCurrent = powerManagement.getBatteryInfoCurrent();
#ifdef TTGO_T_Beam_V1_0
packet += " Bat=" + batteryVoltage + "V (" + batteryChargeCurrent + "mA)";
#endif
#ifdef TTGO_T_Beam_V1_2
packet += " Bat=" + String(batteryVoltage.toFloat()/1000,2) + "V (" + batteryChargeCurrent + "%)";
#endif
}
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, "Loop", "%s", packet.c_str()); logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, "Loop", "%s", packet.c_str());
show_display("<<< TX >>>", "", packet,100); show_display("<<< TX >>>", "", packet,100);
LoRa_Utils::sendNewPacket(packet); LoRa_Utils::sendNewPacket(packet);