mirror of
https://github.com/liberatedsystems/RNode_Firmware_CE.git
synced 2024-10-01 03:15:40 -04:00
Added battery state reporting over USB/Serial/Bluetooth. Implements #39.
This commit is contained in:
parent
e4245c6177
commit
6d26997fa4
2
Config.h
2
Config.h
@ -19,7 +19,7 @@
|
||||
#define CONFIG_H
|
||||
|
||||
#define MAJ_VERS 0x01
|
||||
#define MIN_VERS 0x40
|
||||
#define MIN_VERS 0x41
|
||||
|
||||
#define PLATFORM_AVR 0x90
|
||||
#define PLATFORM_ESP32 0x80
|
||||
|
@ -44,6 +44,7 @@
|
||||
#define CMD_STAT_SNR 0x24
|
||||
#define CMD_STAT_CHTM 0x25
|
||||
#define CMD_STAT_PHYPRM 0x26
|
||||
#define CMD_STAT_BAT 0x27
|
||||
#define CMD_BLINK 0x30
|
||||
#define CMD_RANDOM 0x40
|
||||
|
||||
|
12
Power.h
12
Power.h
@ -32,6 +32,9 @@
|
||||
uint32_t last_pmu_update = 0;
|
||||
uint8_t pmu_target_pps = 1;
|
||||
int pmu_update_interval = 1000/pmu_target_pps;
|
||||
uint8_t pmu_rc = 0;
|
||||
#define PMU_R_INTERVAL 5
|
||||
void kiss_indicate_battery();
|
||||
|
||||
void measure_battery() {
|
||||
#if BOARD_MODEL == BOARD_RNODE_NG_21 || BOARD_MODEL == BOARD_LORA32_V2_1
|
||||
@ -82,6 +85,8 @@ void measure_battery() {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if (bt_state == BT_STATE_CONNECTED) {
|
||||
// SerialBT.printf("Bus voltage %.3fv. Unfiltered %.3fv.", battery_voltage, bat_v_samples[BAT_SAMPLES-1]);
|
||||
// if (bat_voltage_dropping) {
|
||||
@ -154,6 +159,13 @@ void measure_battery() {
|
||||
// SerialBT.println("");
|
||||
// }
|
||||
#endif
|
||||
|
||||
if (battery_ready) {
|
||||
pmu_rc++;
|
||||
if (pmu_rc%PMU_R_INTERVAL == 0) {
|
||||
kiss_indicate_battery();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void update_pmu() {
|
||||
|
10
Utilities.h
10
Utilities.h
@ -755,6 +755,16 @@ void kiss_indicate_phy_stats() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void kiss_indicate_battery() {
|
||||
#if MCU_VARIANT == MCU_ESP32
|
||||
serial_write(FEND);
|
||||
serial_write(CMD_STAT_BAT);
|
||||
escaped_serial_write(battery_state);
|
||||
escaped_serial_write((uint8_t)int(battery_percent));
|
||||
serial_write(FEND);
|
||||
#endif
|
||||
}
|
||||
|
||||
void kiss_indicate_btpin() {
|
||||
#if HAS_BLUETOOTH
|
||||
serial_write(FEND);
|
||||
|
Loading…
Reference in New Issue
Block a user