define fixups
This commit is contained in:
parent
18ca823d92
commit
b91ef3ec7e
@ -8,7 +8,7 @@ esp_adc_cal_characteristics_t *adc_characs =
|
|||||||
(esp_adc_cal_characteristics_t *)calloc(
|
(esp_adc_cal_characteristics_t *)calloc(
|
||||||
1, sizeof(esp_adc_cal_characteristics_t));
|
1, sizeof(esp_adc_cal_characteristics_t));
|
||||||
|
|
||||||
static const adc1_channel_t adc_channel = HAS_BATTERY_PROBE;
|
static const adc1_channel_t adc_channel = BAT_MEASURE_ADC;
|
||||||
static const adc_atten_t atten = ADC_ATTEN_DB_11;
|
static const adc_atten_t atten = ADC_ATTEN_DB_11;
|
||||||
static const adc_unit_t unit = ADC_UNIT_1;
|
static const adc_unit_t unit = ADC_UNIT_1;
|
||||||
#endif
|
#endif
|
||||||
@ -43,19 +43,23 @@ uint16_t read_voltage() {
|
|||||||
}
|
}
|
||||||
adc_reading /= NO_OF_SAMPLES;
|
adc_reading /= NO_OF_SAMPLES;
|
||||||
// Convert ADC reading to voltage in mV
|
// Convert ADC reading to voltage in mV
|
||||||
uint16_t voltage =
|
uint32_t voltage = esp_adc_cal_raw_to_voltage(adc_reading, adc_characs);
|
||||||
(uint16_t)esp_adc_cal_raw_to_voltage(adc_reading, adc_characs);
|
#ifdef BAT_VOLTAGE_DIVIDER
|
||||||
#ifdef BATT_FACTOR
|
voltage *= BAT_VOLTAGE_DIVIDER;
|
||||||
voltage *= BATT_FACTOR;
|
|
||||||
#endif
|
#endif
|
||||||
return voltage;
|
|
||||||
|
#ifdef BAT_MEASURE_EN // turn ext. power off
|
||||||
|
digitalWrite(EXT_POWER_SW, EXT_POWER_OFF);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (uint16_t)voltage;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool batt_sufficient() {
|
bool batt_sufficient() {
|
||||||
#ifdef HAS_BATTERY_PROBE
|
#ifdef BAT_MEASURE_ADC
|
||||||
uint16_t volts = read_voltage();
|
uint16_t volts = read_voltage();
|
||||||
return ((volts < 1000) ||
|
return ((volts < 1000) ||
|
||||||
(volts > OTA_MIN_BATT)); // no battery or battery sufficient
|
(volts > OTA_MIN_BATT)); // no battery or battery sufficient
|
||||||
|
17
src/main.cpp
17
src/main.cpp
@ -180,16 +180,15 @@ void setup() {
|
|||||||
strcat_P(features, " PSRAM");
|
strcat_P(features, " PSRAM");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// set low power mode to off
|
// set external power mode to off
|
||||||
#ifdef HAS_LOWPOWER_SWITCH
|
#ifdef EXT_POWER_SW
|
||||||
pinMode(HAS_LOWPOWER_SWITCH, OUTPUT);
|
pinMode(EXT_POWER_SW, OUTPUT);
|
||||||
#if (LOW_POWER_ACTIVE_LOW)
|
digitalWrite(EXT_POWER_SW, EXT_POWER_ON);
|
||||||
digitalWrite(HAS_LOWPOWER_SWITCH, HIGH);
|
strcat_P(features, " VEXT");
|
||||||
#else
|
|
||||||
digitalWrite(HAS_LOWPOWER_SWITCH, LOW);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
strcat_P(features, " LPWR");
|
#ifdef BAT_MEASURE_EN
|
||||||
|
pinMode(BAT_MEASURE_EN, OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// initialize leds
|
// initialize leds
|
||||||
@ -224,7 +223,7 @@ void setup() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// initialize battery status
|
// initialize battery status
|
||||||
#ifdef HAS_BATTERY_PROBE
|
#ifdef BAT_MEASURE_ADC
|
||||||
strcat_P(features, " BATT");
|
strcat_P(features, " BATT");
|
||||||
calibrate_voltage();
|
calibrate_voltage();
|
||||||
batt_voltage = read_voltage();
|
batt_voltage = read_voltage();
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include "mbedtls/aes.h"
|
#include "mbedtls/aes.h"
|
||||||
#include "lmic/oslmic.h"
|
#include "lmic/oslmic.h"
|
||||||
|
|
||||||
#if defined(USE_MBEDTLS_AES)
|
#if defined USE_MBEDTLS_AES
|
||||||
|
|
||||||
void lmic_aes_encrypt(u1_t *data, u1_t *key)
|
void lmic_aes_encrypt(u1_t *data, u1_t *key)
|
||||||
{
|
{
|
||||||
|
@ -373,7 +373,7 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float celsius,
|
|||||||
buffer[cursor++] = LPP_ANALOG_INPUT;
|
buffer[cursor++] = LPP_ANALOG_INPUT;
|
||||||
buffer[cursor++] = highByte(volt);
|
buffer[cursor++] = highByte(volt);
|
||||||
buffer[cursor++] = lowByte(volt);
|
buffer[cursor++] = lowByte(volt);
|
||||||
#endif // HAS_BATTERY_PROBE
|
#endif // BAT_MEASURE_ADC
|
||||||
|
|
||||||
#if (PAYLOAD_ENCODER == 3)
|
#if (PAYLOAD_ENCODER == 3)
|
||||||
buffer[cursor++] = LPP_TEMPERATURE_CHANNEL;
|
buffer[cursor++] = LPP_TEMPERATURE_CHANNEL;
|
||||||
|
Loading…
Reference in New Issue
Block a user