From 22286a9a13df29683d3e3fec3d763f8fcb8fe72f Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sat, 13 Apr 2019 19:22:48 +0200 Subject: [PATCH] repair broken battery measure function --- include/globals.h | 2 +- src/battery.cpp | 6 +++--- src/cyclic.cpp | 2 +- src/display.cpp | 2 +- src/payload.cpp | 2 +- src/rcommand.cpp | 2 +- src/senddata.cpp | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/globals.h b/include/globals.h index 871b4c3b..5ca2286d 100644 --- a/include/globals.h +++ b/include/globals.h @@ -139,7 +139,7 @@ extern time_t userUTCTime; #include "button.h" #endif -#ifdef HAS_BATTERY_PROBE +#ifdef BAT_MEASURE_ADC #include "battery.h" #endif diff --git a/src/battery.cpp b/src/battery.cpp index 4f412c77..3af874d9 100644 --- a/src/battery.cpp +++ b/src/battery.cpp @@ -3,7 +3,7 @@ // Local logging tag static const char TAG[] = __FILE__; -#ifdef HAS_BATTERY_PROBE +#ifdef BAT_MEASURE_ADC esp_adc_cal_characteristics_t *adc_characs = (esp_adc_cal_characteristics_t *)calloc( 1, sizeof(esp_adc_cal_characteristics_t)); @@ -14,7 +14,7 @@ static const adc_unit_t unit = ADC_UNIT_1; #endif void calibrate_voltage(void) { -#ifdef HAS_BATTERY_PROBE +#ifdef BAT_MEASURE_ADC // configure ADC ESP_ERROR_CHECK(adc1_config_width(ADC_WIDTH_BIT_12)); ESP_ERROR_CHECK(adc1_config_channel_atten(adc_channel, atten)); @@ -35,7 +35,7 @@ void calibrate_voltage(void) { } uint16_t read_voltage() { -#ifdef HAS_BATTERY_PROBE +#ifdef BAT_MEASURE_ADC // multisample ADC uint32_t adc_reading = 0; for (int i = 0; i < NO_OF_SAMPLES; i++) { diff --git a/src/cyclic.cpp b/src/cyclic.cpp index 9d108747..53b16956 100644 --- a/src/cyclic.cpp +++ b/src/cyclic.cpp @@ -54,7 +54,7 @@ void doHousekeeping() { #endif // read battery voltage into global variable -#ifdef HAS_BATTERY_PROBE +#ifdef BAT_MEASURE_ADC batt_voltage = read_voltage(); ESP_LOGI(TAG, "Voltage: %dmV", batt_voltage); #endif diff --git a/src/display.cpp b/src/display.cpp index 1e517a78..3d6b5a20 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -185,7 +185,7 @@ void draw_page(time_t t, uint8_t page) { case 0: // update Battery status (line 2) -#ifdef HAS_BATTERY_PROBE +#ifdef BAT_MEASURE_ADC u8x8.setCursor(0, 2); u8x8.printf("B:%.2fV", batt_voltage / 1000.0); #endif diff --git a/src/payload.cpp b/src/payload.cpp index c70edc20..a53cf7a1 100644 --- a/src/payload.cpp +++ b/src/payload.cpp @@ -366,7 +366,7 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float celsius, uint32_t mem, uint8_t reset1, uint8_t reset2) { uint16_t temp = celsius * 10; uint16_t volt = voltage / 10; -#ifdef HAS_BATTERY_PROBE +#ifdef BAT_MEASURE_ADC #if (PAYLOAD_ENCODER == 3) buffer[cursor++] = LPP_BATT_CHANNEL; #endif diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 2ab24ce2..fbc76ab7 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -239,7 +239,7 @@ void get_config(uint8_t val[]) { void get_status(uint8_t val[]) { ESP_LOGI(TAG, "Remote command: get device status"); -#ifdef HAS_BATTERY_PROBE +#ifdef BAT_MEASURE_ADC uint16_t voltage = read_voltage(); #else uint16_t voltage = 0; diff --git a/src/senddata.cpp b/src/senddata.cpp index ebfd84e1..1f8a9e7a 100644 --- a/src/senddata.cpp +++ b/src/senddata.cpp @@ -114,7 +114,7 @@ void sendCounter() { break; #endif -#ifdef HAS_BATTERY_PROBE +#ifdef BAT_MEASURE_ADC case BATT_DATA: payload.reset(); payload.addVoltage(read_voltage());