From 07dbe088330d7f94eefc346f129cccb708e99aa0 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 21 Jul 2018 23:13:28 +0200 Subject: [PATCH 1/3] =?UTF-8?q?battery=20voltage=20d=C3=ADsplay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformio.ini | 4 ++-- src/battery.cpp | 6 +++--- src/display.cpp | 2 +- src/globals.h | 4 ++-- src/main.cpp | 8 ++++++-- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/platformio.ini b/platformio.ini index a79d78c6..30e427f6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,11 +11,11 @@ ; ---> SELECT TARGET PLATFORM HERE! <--- [platformio] -env_default = generic +;env_default = generic ;env_default = heltec ;env_default = ttgov1 ;env_default = ttgov2 -;env_default = ttgov21 +env_default = ttgov21 ;env_default = ttgobeam ;env_default = lopy ;env_default = lopy4 diff --git a/src/battery.cpp b/src/battery.cpp index ce9b0924..1c4dc144 100644 --- a/src/battery.cpp +++ b/src/battery.cpp @@ -7,13 +7,13 @@ static const char TAG[] = "main"; static void print_char_val_type(esp_adc_cal_value_t val_type) { if (val_type == ESP_ADC_CAL_VAL_EFUSE_TP) { - ESP_LOGI(TAG, + ESP_LOGD(TAG, "ADC characterization based on Two Point values stored in eFuse"); } else if (val_type == ESP_ADC_CAL_VAL_EFUSE_VREF) { - ESP_LOGI(TAG, + ESP_LOGD(TAG, "ADC characterization based on reference voltage stored in eFuse"); } else { - ESP_LOGI(TAG, "ADC characterization based on default reference voltage"); + ESP_LOGD(TAG, "ADC characterization based on default reference voltage"); } } diff --git a/src/display.cpp b/src/display.cpp index 8671585a..697dc34e 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -112,7 +112,7 @@ void refreshDisplay() { // update Battery status (line 2) #ifdef HAS_BATTERY_PROBE u8x8.setCursor(0, 2); - u8x8.printf("B:%.1fV", read_voltage() / 1000.0); + u8x8.printf("B:%.1fV", batt_volt / 1000.0); #endif // update GPS status (line 2) diff --git a/src/globals.h b/src/globals.h index 2c1408fd..91d26f19 100644 --- a/src/globals.h +++ b/src/globals.h @@ -40,8 +40,8 @@ typedef struct { extern configData_t cfg; // current device configuration extern char display_line6[], display_line7[]; // screen buffers extern uint8_t channel; // wifi channel rotation counter -extern uint16_t macs_total, macs_wifi, macs_ble; // MAC counters -extern std::set macs; // temp storage for MACs +extern uint16_t macs_total, macs_wifi, macs_ble, batt_volt; // display values +extern std::set macs; // temp storage for MACs extern hw_timer_t *channelSwitch, *sendCycle; extern portMUX_TYPE timerMux; diff --git a/src/main.cpp b/src/main.cpp index 40b890bf..4621efe5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,8 +30,8 @@ licenses. Refer to LICENSE.txt file in repository for more details. configData_t cfg; // struct holds current device configuration char display_line6[16], display_line7[16]; // display buffers uint8_t channel = 0; // channel rotation counter -uint16_t macs_total = 0, macs_wifi = 0, - macs_ble = 0; // MAC counters globals for display +uint16_t macs_total = 0, macs_wifi = 0, macs_ble = 0, + batt_volt = 0; // globals for display hw_timer_t *channelSwitch = NULL, *displaytimer = NULL, *sendCycle = NULL; // configure hardware timer for cyclic tasks @@ -185,6 +185,10 @@ void sendPayload() { SendCycleTimerIRQ = 0; portEXIT_CRITICAL(&timerMux); +#ifdef HAS_BATTERY_PROBE + batt_volt = read_voltage(); +#endif + // append counter data to payload payload.reset(); payload.addCount(macs_wifi, cfg.blescan ? macs_ble : 0); From 12be54301051449e4682686050985bfce7f19d81 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 21 Jul 2018 23:40:42 +0200 Subject: [PATCH 2/3] battery voltage display --- src/battery.cpp | 2 +- src/main.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/battery.cpp b/src/battery.cpp index 1c4dc144..147e5d0b 100644 --- a/src/battery.cpp +++ b/src/battery.cpp @@ -48,7 +48,7 @@ uint16_t read_voltage(void) { #ifdef BATT_FACTOR voltage *= BATT_FACTOR; #endif - ESP_LOGI(TAG, "Raw: %d / Voltage: %dmV", adc_reading, voltage); + ESP_LOGD(TAG, "Raw: %d / Voltage: %dmV", adc_reading, voltage); return voltage; } #endif // HAS_BATTERY_PROBE \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 4621efe5..b4f82d22 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -185,10 +185,6 @@ void sendPayload() { SendCycleTimerIRQ = 0; portEXIT_CRITICAL(&timerMux); -#ifdef HAS_BATTERY_PROBE - batt_volt = read_voltage(); -#endif - // append counter data to payload payload.reset(); payload.addCount(macs_wifi, cfg.blescan ? macs_ble : 0); @@ -436,6 +432,10 @@ void loop() { readButton(); #endif +#ifdef HAS_BATTERY_PROBE + batt_volt = read_voltage(); +#endif + #ifdef HAS_DISPLAY updateDisplay(); #endif From ffa6c2cb1be518fd6c6c94c5ec45e96b439ea501 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 22 Jul 2018 00:01:43 +0200 Subject: [PATCH 3/3] battery display disabled (RAM issue) --- src/display.cpp | 10 ++++++---- src/globals.h | 4 ++-- src/main.cpp | 7 +------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index 697dc34e..a5116041 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -109,22 +109,24 @@ void refreshDisplay() { u8x8.draw2x2String(0, 0, buff); // display number on unique macs total Wifi + BLE +/* // update Battery status (line 2) #ifdef HAS_BATTERY_PROBE u8x8.setCursor(0, 2); - u8x8.printf("B:%.1fV", batt_volt / 1000.0); + u8x8.printf("B:%.1fV", read_voltage() / 1000.0); #endif +*/ // update GPS status (line 2) #ifdef HAS_GPS - u8x8.setCursor(8, 2); + u8x8.setCursor(9, 2); if (!gps.location.isValid()) // if no fix then display Sats value inverse { u8x8.setInverseFont(1); - u8x8.printf("Sat:%.3d", gps.satellites.value()); + u8x8.printf("Sats:%.2d", gps.satellites.value()); u8x8.setInverseFont(0); } else - u8x8.printf("Sat:%.3d", gps.satellites.value()); + u8x8.printf("Sats:%.d", gps.satellites.value()); #endif // update bluetooth counter + LoRa SF (line 3) diff --git a/src/globals.h b/src/globals.h index 91d26f19..b02bc37a 100644 --- a/src/globals.h +++ b/src/globals.h @@ -40,8 +40,8 @@ typedef struct { extern configData_t cfg; // current device configuration extern char display_line6[], display_line7[]; // screen buffers extern uint8_t channel; // wifi channel rotation counter -extern uint16_t macs_total, macs_wifi, macs_ble, batt_volt; // display values -extern std::set macs; // temp storage for MACs +extern uint16_t macs_total, macs_wifi, macs_ble; // display values +extern std::set macs; // temp storage for MACs extern hw_timer_t *channelSwitch, *sendCycle; extern portMUX_TYPE timerMux; diff --git a/src/main.cpp b/src/main.cpp index b4f82d22..55ba10d2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,8 +30,7 @@ licenses. Refer to LICENSE.txt file in repository for more details. configData_t cfg; // struct holds current device configuration char display_line6[16], display_line7[16]; // display buffers uint8_t channel = 0; // channel rotation counter -uint16_t macs_total = 0, macs_wifi = 0, macs_ble = 0, - batt_volt = 0; // globals for display +uint16_t macs_total = 0, macs_wifi = 0, macs_ble = 0; // globals for display hw_timer_t *channelSwitch = NULL, *displaytimer = NULL, *sendCycle = NULL; // configure hardware timer for cyclic tasks @@ -432,10 +431,6 @@ void loop() { readButton(); #endif -#ifdef HAS_BATTERY_PROBE - batt_volt = read_voltage(); -#endif - #ifdef HAS_DISPLAY updateDisplay(); #endif