summaryrefslogtreecommitdiff
path: root/tmk_core/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol')
-rw-r--r--tmk_core/protocol/lufa.mk2
-rw-r--r--tmk_core/protocol/lufa/adafruit_ble.cpp14
2 files changed, 10 insertions, 6 deletions
diff --git a/tmk_core/protocol/lufa.mk b/tmk_core/protocol/lufa.mk
index bb82a31e17..d7d1d9ffcc 100644
--- a/tmk_core/protocol/lufa.mk
+++ b/tmk_core/protocol/lufa.mk
@@ -29,6 +29,7 @@ ifeq ($(strip $(BLUETOOTH_ENABLE)), yes)
endif
ifeq ($(strip $(BLUETOOTH)), AdafruitBLE)
+ LUFA_SRC += analog.c
LUFA_SRC += $(LUFA_DIR)/adafruit_ble.cpp
endif
@@ -51,6 +52,7 @@ SRC += $(LUFA_SRC)
# Search Path
VPATH += $(TMK_PATH)/$(LUFA_DIR)
VPATH += $(LUFA_PATH)
+VPATH += $(DRIVER_PATH)/avr
# Option modules
#ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE)
diff --git a/tmk_core/protocol/lufa/adafruit_ble.cpp b/tmk_core/protocol/lufa/adafruit_ble.cpp
index 71d0936f8f..1d8ae1038b 100644
--- a/tmk_core/protocol/lufa/adafruit_ble.cpp
+++ b/tmk_core/protocol/lufa/adafruit_ble.cpp
@@ -10,6 +10,7 @@
#include "action_util.h"
#include "ringbuffer.hpp"
#include <string.h>
+#include "analog.h"
// These are the pin assignments for the 32u4 boards.
// You may define them to something else in your config.h
@@ -29,6 +30,12 @@
#define SAMPLE_BATTERY
#define ConnectionUpdateInterval 1000 /* milliseconds */
+#ifdef SAMPLE_BATTERY
+#ifndef BATTERY_LEVEL_PIN
+# define BATTERY_LEVEL_PIN 7
+#endif
+#endif
+
static struct {
bool is_connected;
bool initialized;
@@ -631,15 +638,10 @@ void adafruit_ble_task(void) {
}
#ifdef SAMPLE_BATTERY
- // I don't know if this really does anything useful yet; the reported
- // voltage level always seems to be around 3200mV. We may want to just rip
- // this code out.
if (timer_elapsed(state.last_battery_update) > BatteryUpdateInterval && resp_buf.empty()) {
state.last_battery_update = timer_read();
- if (at_command_P(PSTR("AT+HWVBAT"), resbuf, sizeof(resbuf))) {
- state.vbat = atoi(resbuf);
- }
+ state.vbat = analogRead(BATTERY_LEVEL_PIN);
}
#endif
}