Fix battery level code in adafruit_ble.cpp (#6648)
authorbwhelm <bwhelm@users.noreply.github.com>
Tue, 3 Sep 2019 18:29:23 +0000 (14:29 -0400)
committerfauxpark <fauxpark@gmail.com>
Tue, 3 Sep 2019 18:29:23 +0000 (04:29 +1000)
commitfa71c4c91e8b822e2d78d420d7d6fe2ca32245af
treeda88278bb1da73b00288db9a1feb7b8f97c41b0e
parente6a6b1f122e72d58fbb14f5752929fe489d0e828
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 <drashna@live.com>
* Remove old comment

* Fix linking error

* Remove `#ifdef` around `#include analog.h`.

* Really fix linking error
drivers/avr/analog.h
tmk_core/protocol/lufa.mk
tmk_core/protocol/lufa/adafruit_ble.cpp