mirror of
https://github.com/markqvist/RNode_Firmware.git
synced 2024-10-01 03:15:39 -04:00
Added battery status and console support to Heltec V3
This commit is contained in:
parent
ac819ecb20
commit
d2133ba5e0
3
Boards.h
3
Boards.h
@ -258,7 +258,8 @@
|
|||||||
#define HAS_DISPLAY true
|
#define HAS_DISPLAY true
|
||||||
#define HAS_BLUETOOTH false
|
#define HAS_BLUETOOTH false
|
||||||
#define HAS_BLE true
|
#define HAS_BLE true
|
||||||
#define HAS_CONSOLE false
|
#define HAS_PMU true
|
||||||
|
#define HAS_CONSOLE true
|
||||||
#define HAS_EEPROM true
|
#define HAS_EEPROM true
|
||||||
#define HAS_INPUT true
|
#define HAS_INPUT true
|
||||||
#define HAS_SLEEP true
|
#define HAS_SLEEP true
|
||||||
|
6
Makefile
6
Makefile
@ -158,11 +158,11 @@ upload-heltec32_v2:
|
|||||||
python ./Release/esptool/esptool.py --chip esp32 --port /dev/ttyUSB1 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
|
python ./Release/esptool/esptool.py --chip esp32 --port /dev/ttyUSB1 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
|
||||||
|
|
||||||
upload-heltec32_v3:
|
upload-heltec32_v3:
|
||||||
arduino-cli upload -p /dev/ttyUSB1 --fqbn esp32:esp32:heltec_wifi_lora_32_V3
|
arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:heltec_wifi_lora_32_V3
|
||||||
@sleep 1
|
@sleep 1
|
||||||
rnodeconf /dev/ttyUSB1 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.heltec_wifi_lora_32_V3/RNode_Firmware.ino.bin)
|
rnodeconf /dev/ttyUSB0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.heltec_wifi_lora_32_V3/RNode_Firmware.ino.bin)
|
||||||
@sleep 3
|
@sleep 3
|
||||||
python ./Release/esptool/esptool.py --chip esp32-s3 --port /dev/ttyUSB1 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
|
python ./Release/esptool/esptool.py --chip esp32-s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
|
||||||
|
|
||||||
upload-rnode_ng_20:
|
upload-rnode_ng_20:
|
||||||
arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:ttgo-lora32
|
arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:ttgo-lora32
|
||||||
|
37
Power.h
37
Power.h
@ -44,6 +44,24 @@
|
|||||||
int bat_charged_samples = 0;
|
int bat_charged_samples = 0;
|
||||||
bool bat_voltage_dropping = false;
|
bool bat_voltage_dropping = false;
|
||||||
float bat_delay_v = 0;
|
float bat_delay_v = 0;
|
||||||
|
#elif BOARD_MODEL == BOARD_HELTEC32_V3
|
||||||
|
#define BAT_C_SAMPLES 7
|
||||||
|
#define BAT_D_SAMPLES 2
|
||||||
|
#define BAT_V_MIN 3.15
|
||||||
|
#define BAT_V_MAX 4.3
|
||||||
|
#define BAT_V_CHG 4.48
|
||||||
|
#define BAT_V_FLOAT 4.33
|
||||||
|
#define BAT_SAMPLES 5
|
||||||
|
const uint8_t pin_vbat = 1;
|
||||||
|
const uint8_t pin_ctrl = 37;
|
||||||
|
float bat_p_samples[BAT_SAMPLES];
|
||||||
|
float bat_v_samples[BAT_SAMPLES];
|
||||||
|
uint8_t bat_samples_count = 0;
|
||||||
|
int bat_discharging_samples = 0;
|
||||||
|
int bat_charging_samples = 0;
|
||||||
|
int bat_charged_samples = 0;
|
||||||
|
bool bat_voltage_dropping = false;
|
||||||
|
float bat_delay_v = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t last_pmu_update = 0;
|
uint32_t last_pmu_update = 0;
|
||||||
@ -54,10 +72,17 @@ uint8_t pmu_rc = 0;
|
|||||||
void kiss_indicate_battery();
|
void kiss_indicate_battery();
|
||||||
|
|
||||||
void measure_battery() {
|
void measure_battery() {
|
||||||
#if BOARD_MODEL == BOARD_RNODE_NG_21 || BOARD_MODEL == BOARD_LORA32_V2_1
|
#if BOARD_MODEL == BOARD_RNODE_NG_21 || BOARD_MODEL == BOARD_LORA32_V2_1 || BOARD_MODEL == BOARD_HELTEC32_V3
|
||||||
battery_installed = true;
|
battery_installed = true;
|
||||||
battery_indeterminate = true;
|
battery_indeterminate = true;
|
||||||
bat_v_samples[bat_samples_count%BAT_SAMPLES] = (float)(analogRead(pin_vbat)) / 4095*2*3.3*1.1;
|
|
||||||
|
#if BOARD_MODEL == BOARD_HELTEC32_V3
|
||||||
|
float battery_measurement = (float)(analogRead(pin_vbat)) * 0.0041;
|
||||||
|
#else
|
||||||
|
float battery_measurement = (float)(analogRead(pin_vbat)) / 4095.0*2.0*3.3*1.1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bat_v_samples[bat_samples_count%BAT_SAMPLES] = battery_measurement;
|
||||||
bat_p_samples[bat_samples_count%BAT_SAMPLES] = ((battery_voltage-BAT_V_MIN) / (BAT_V_MAX-BAT_V_MIN))*100.0;
|
bat_p_samples[bat_samples_count%BAT_SAMPLES] = ((battery_voltage-BAT_V_MIN) / (BAT_V_MAX-BAT_V_MIN))*100.0;
|
||||||
|
|
||||||
bat_samples_count++;
|
bat_samples_count++;
|
||||||
@ -95,11 +120,7 @@ void measure_battery() {
|
|||||||
if (bat_voltage_dropping && battery_voltage < BAT_V_FLOAT) {
|
if (bat_voltage_dropping && battery_voltage < BAT_V_FLOAT) {
|
||||||
battery_state = BATTERY_STATE_DISCHARGING;
|
battery_state = BATTERY_STATE_DISCHARGING;
|
||||||
} else {
|
} else {
|
||||||
#if BOARD_MODEL == BOARD_RNODE_NG_21
|
|
||||||
battery_state = BATTERY_STATE_CHARGING;
|
battery_state = BATTERY_STATE_CHARGING;
|
||||||
#else
|
|
||||||
battery_state = BATTERY_STATE_DISCHARGING;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -214,6 +235,10 @@ bool init_pmu() {
|
|||||||
#if BOARD_MODEL == BOARD_RNODE_NG_21 || BOARD_MODEL == BOARD_LORA32_V2_1
|
#if BOARD_MODEL == BOARD_RNODE_NG_21 || BOARD_MODEL == BOARD_LORA32_V2_1
|
||||||
pinMode(pin_vbat, INPUT);
|
pinMode(pin_vbat, INPUT);
|
||||||
return true;
|
return true;
|
||||||
|
#elif BOARD_MODEL == BOARD_HELTEC32_V3
|
||||||
|
pinMode(pin_ctrl,OUTPUT);
|
||||||
|
digitalWrite(pin_ctrl, LOW);
|
||||||
|
return true;
|
||||||
#elif BOARD_MODEL == BOARD_TBEAM
|
#elif BOARD_MODEL == BOARD_TBEAM
|
||||||
Wire.begin(I2C_SDA, I2C_SCL);
|
Wire.begin(I2C_SDA, I2C_SCL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user