Adjusted adc_multiplier for heltec2.1 and added adc_mulitplier_override (#1183)

pull/1191/head
Ben Meadors 2022-02-09 13:37:48 -06:00 zatwierdzone przez GitHub
rodzic 856f2f9589
commit c867af8522
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 7 dodań i 4 usunięć

Wyświetl plik

@ -100,6 +100,10 @@ class AnalogBatteryLevel : public HasBatteryLevel
#ifndef ADC_MULTIPLIER
#define ADC_MULTIPLIER 2.0
#endif
// Override variant or default ADC_MULTIPLIER if we have the override pref
float operativeAdcMultiplier = radioConfig.preferences.adc_multiplier_override > 0 ?
radioConfig.preferences.adc_multiplier_override :
ADC_MULTIPLIER;
#ifdef BATTERY_PIN
// Do not call analogRead() often.
@ -109,7 +113,7 @@ class AnalogBatteryLevel : public HasBatteryLevel
uint32_t raw = analogRead(BATTERY_PIN);
float scaled;
#ifndef VBAT_RAW_TO_SCALED
scaled = 1000.0 * ADC_MULTIPLIER * (AREF_VOLTAGE / 1024.0) * raw;
scaled = 1000.0 * operativeAdcMultiplier * (AREF_VOLTAGE / 1024.0) * raw;
#else
scaled = VBAT_RAW_TO_SCALED(raw); //defined in variant.h
#endif

Wyświetl plik

@ -24,8 +24,7 @@
#define LORA_DIO1 35 // Not really used
#define LORA_DIO2 34 // Not really used
// ratio of voltage divider = 3.20 (schematic R12=100k, R10=220k)
// device to device variations, the actual ratio can be between 3.2 and 4
#define ADC_MULTIPLIER 3.6 // best fit
#define ADC_MULTIPLIER 3.8
#define BATTERY_PIN 37 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Plugin.