summaryrefslogtreecommitdiffstats
path: root/keyboards/handwired/promethium/promethium.c
diff options
context:
space:
mode:
authorluc wastiaux <luc.wastiaux@airpost.net>2017-02-13 00:44:28 +0100
committerluc wastiaux <luc.wastiaux@airpost.net>2017-02-13 00:44:28 +0100
commit352d79e1fbbd7eea65793abb261dd544fec7bb1c (patch)
treee006ee8098826054d93939b2a59521f6c032e10d /keyboards/handwired/promethium/promethium.c
parent5f8535b356e66975e20f1a573ab104db75f8b33c (diff)
parent4505db5d0e0c2423645cc9117f29b942d4841c5b (diff)
downloadqmk_firmware-352d79e1fbbd7eea65793abb261dd544fec7bb1c.tar.gz
qmk_firmware-352d79e1fbbd7eea65793abb261dd544fec7bb1c.tar.xz
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'keyboards/handwired/promethium/promethium.c')
-rw-r--r--keyboards/handwired/promethium/promethium.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/keyboards/handwired/promethium/promethium.c b/keyboards/handwired/promethium/promethium.c
index a0035cce1..62e2281fa 100644
--- a/keyboards/handwired/promethium/promethium.c
+++ b/keyboards/handwired/promethium/promethium.c
@@ -1,6 +1,38 @@
#include "promethium.h"
+#include "analog.h"
+#include "timer.h"
+#include "matrix.h"
-void matrix_init_kb(void) {
+// cubic fit {3.3, 0}, {3.5, 2.9}, {3.6, 5}, {3.7, 8.6}, {3.8, 36}, {3.9, 62}, {4.0, 73}, {4.05, 83}, {4.1, 89}, {4.15, 94}, {4.2, 100}
+
+uint8_t battery_level(void) {
+ float voltage = analogRead(BATTERY_PIN) * 2 * 3.3 / 1024;
+ if (voltage < MIN_VOLTAGE) return 0;
+ if (voltage > MAX_VOLTAGE) return 255;
+ return (voltage - MIN_VOLTAGE) / (MAX_VOLTAGE - MIN_VOLTAGE) * 255;
+}
+
+__attribute__ ((weak))
+void battery_poll(uint8_t level) {
+}
+void matrix_init_kb(void) {
matrix_init_user();
-} \ No newline at end of file
+}
+
+void matrix_scan_kb(void) {
+ static uint16_t counter = BATTERY_POLL;
+ counter++;
+
+ if (counter > BATTERY_POLL) {
+ counter = 0;
+ battery_poll(battery_level());
+ }
+
+ matrix_scan_user();
+}
+
+void led_set_kb(uint8_t usb_led) {
+ led_set_user(usb_led);
+}
+