Merge pull request #351 from cyberman54/development
Fix battery function & new option WIFI off
This commit is contained in:
commit
92007a84e3
@ -139,7 +139,7 @@ extern time_t userUTCTime;
|
||||
#include "button.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAS_BATTERY_PROBE
|
||||
#ifdef BAT_MEASURE_ADC
|
||||
#include "battery.h"
|
||||
#endif
|
||||
|
||||
|
@ -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++) {
|
||||
|
@ -9,7 +9,9 @@ static const char TAG[] = __FILE__;
|
||||
|
||||
Ticker housekeeper;
|
||||
|
||||
void housekeeping() { xTaskNotifyFromISR(irqHandlerTask, CYCLIC_IRQ, eSetBits, NULL); }
|
||||
void housekeeping() {
|
||||
xTaskNotifyFromISR(irqHandlerTask, CYCLIC_IRQ, eSetBits, NULL);
|
||||
}
|
||||
|
||||
// do all housekeeping
|
||||
void doHousekeeping() {
|
||||
@ -24,7 +26,7 @@ void doHousekeeping() {
|
||||
#ifdef HAS_SPI
|
||||
spi_housekeeping();
|
||||
#endif
|
||||
#if(HAS_LORA)
|
||||
#if (HAS_LORA)
|
||||
lora_housekeeping();
|
||||
#endif
|
||||
|
||||
@ -32,7 +34,7 @@ void doHousekeeping() {
|
||||
ESP_LOGD(TAG, "IRQhandler %d bytes left | Taskstate = %d",
|
||||
uxTaskGetStackHighWaterMark(irqHandlerTask),
|
||||
eTaskGetState(irqHandlerTask));
|
||||
#if(HAS_GPS)
|
||||
#if (HAS_GPS)
|
||||
ESP_LOGD(TAG, "Gpsloop %d bytes left | Taskstate = %d",
|
||||
uxTaskGetStackHighWaterMark(GpsTask), eTaskGetState(GpsTask));
|
||||
#endif
|
||||
@ -52,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
|
||||
@ -115,8 +117,10 @@ uint32_t getFreeRAM() {
|
||||
}
|
||||
|
||||
void reset_counters() {
|
||||
#if ((WIFICOUNTER) || (BLECOUNTER))
|
||||
macs.clear(); // clear all macs container
|
||||
macs_total = 0; // reset all counters
|
||||
macs_wifi = 0;
|
||||
macs_ble = 0;
|
||||
#endif
|
||||
}
|
@ -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
|
||||
|
16
src/main.cpp
16
src/main.cpp
@ -346,9 +346,8 @@ void setup() {
|
||||
strcat_P(features, " IF482");
|
||||
#endif
|
||||
|
||||
// show compiled features
|
||||
ESP_LOGI(TAG, "Features:%s", features);
|
||||
|
||||
#if (WIFICOUNTER)
|
||||
strcat_P(features, " WIFI");
|
||||
// start wifi in monitor mode and start channel rotation timer
|
||||
ESP_LOGI(TAG, "Starting Wifi...");
|
||||
wifi_sniffer_init();
|
||||
@ -356,6 +355,15 @@ void setup() {
|
||||
// arduino-esp32 core. Note: do this *after* wifi has started, since
|
||||
// function gets it's seed from RF noise
|
||||
get_salt(); // get new 16bit for salting hashes
|
||||
#else
|
||||
// switch off wifi
|
||||
WiFi.mode(WIFI_OFF);
|
||||
esp_wifi_stop();
|
||||
esp_wifi_deinit();
|
||||
#endif
|
||||
|
||||
// show compiled features
|
||||
ESP_LOGI(TAG, "Features:%s", features);
|
||||
|
||||
// start state machine
|
||||
ESP_LOGI(TAG, "Starting Interrupt Handler...");
|
||||
@ -400,7 +408,7 @@ void setup() {
|
||||
timerAlarmEnable(displayIRQ);
|
||||
#endif
|
||||
|
||||
// cyclic function interrupts
|
||||
// cyclic function interrupts
|
||||
sendcycler.attach(SENDCYCLE * 2, sendcycle);
|
||||
housekeeper.attach(HOMECYCLE, housekeeping);
|
||||
|
||||
|
@ -13,9 +13,10 @@
|
||||
#define SENDCYCLE 30 // payload send cycle [seconds/2], 0 .. 255
|
||||
#define PAYLOAD_ENCODER 2 // payload encoder: 1=Plain, 2=Packed, 3=Cayenne LPP dynamic, 4=Cayenne LPP packed
|
||||
|
||||
// Set this to include BLE counting and vendor filter functions
|
||||
// Set this to include BLE counting and vendor filter functions, or to switch off WIFI counting
|
||||
#define VENDORFILTER 1 // set to 0 if you want to count things, not people
|
||||
#define BLECOUNTER 0 // set it to 1 if you want to use BLE count, at expense of memory
|
||||
#define BLECOUNTER 0 // set it to 1 if you want to use BLE count, at expense of power & memory
|
||||
#define WIFICOUNTER 1 // set it to 0 if you want to switch off WIFI count
|
||||
|
||||
// BLE scan parameters
|
||||
#define BLESCANTIME 0 // [seconds] scan duration, 0 means infinite [default], see note below
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -3,7 +3,9 @@
|
||||
|
||||
Ticker sendcycler;
|
||||
|
||||
void sendcycle() { xTaskNotifyFromISR(irqHandlerTask, SENDCYCLE_IRQ, eSetBits, NULL); }
|
||||
void sendcycle() {
|
||||
xTaskNotifyFromISR(irqHandlerTask, SENDCYCLE_IRQ, eSetBits, NULL);
|
||||
}
|
||||
|
||||
// put data to send in RTos Queues used for transmit over channels Lora and SPI
|
||||
void SendPayload(uint8_t port, sendprio_t prio) {
|
||||
@ -57,6 +59,7 @@ void sendCounter() {
|
||||
while (bitmask) {
|
||||
switch (bitmask & mask) {
|
||||
|
||||
#if ((WIFICOUNTER) || (BLECOUNTER))
|
||||
case COUNT_DATA:
|
||||
payload.reset();
|
||||
payload.addCount(macs_wifi, MAC_SNIFF_WIFI);
|
||||
@ -70,6 +73,7 @@ void sendCounter() {
|
||||
ESP_LOGI(TAG, "Counter cleared");
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if (HAS_BME)
|
||||
case MEMS_DATA:
|
||||
@ -110,7 +114,7 @@ void sendCounter() {
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_BATTERY_PROBE
|
||||
#ifdef BAT_MEASURE_ADC
|
||||
case BATT_DATA:
|
||||
payload.reset();
|
||||
payload.addVoltage(read_voltage());
|
||||
|
Loading…
Reference in New Issue
Block a user