From fa71c4c91e8b822e2d78d420d7d6fe2ca32245af Mon Sep 17 00:00:00 2001 From: bwhelm Date: Tue, 3 Sep 2019 14:29:23 -0400 Subject: Fix battery level code in adafruit_ble.cpp (#6648) * Fix battery level code in adafruit_ble.cpp The code in tsk_core/protocol/lufa/adafluit_ble.cpp that polls the battery level for the Adafruit feather BLE controller reads the regulated voltage, not the raw voltage coming from the battery. To do that, the Adafruit Feather docs say you should read from pin A9: https://learn.adafruit.com/adafruit-feather-32u4-basic-proto/power-management#measuring-battery-4-9. (See also https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le/pinouts#logic-pins-2-9.) I'm not sure why, but analogRead(9); doesn't read the correct pin. Checking all available analog pins experimentally, it turns out that analogRead(7); returns the correct value. So the code above should read: state.vbat = analogRead(7); * Update tmk_core/protocol/lufa/adafruit_ble.cpp Co-Authored-By: Drashna Jaelre * Remove old comment * Fix linking error * Remove `#ifdef` around `#include analog.h`. * Really fix linking error --- drivers/avr/analog.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers') diff --git a/drivers/avr/analog.h b/drivers/avr/analog.h index 32452a1ec2..1b773d82ce 100644 --- a/drivers/avr/analog.h +++ b/drivers/avr/analog.h @@ -19,9 +19,15 @@ #include +#ifdef __cplusplus +extern "C" { +#endif void analogReference(uint8_t mode); int16_t analogRead(uint8_t pin); int16_t adc_read(uint8_t mux); +#ifdef __cplusplus +} +#endif #define ADC_REF_POWER (1 << REFS0) #define ADC_REF_INTERNAL ((1 << REFS1) | (1 << REFS0)) -- cgit v1.2.3