diff options
author | milestogo <milestogo@users.noreply.github.com> | 2017-02-11 22:11:06 -0800 |
---|---|---|
committer | milestogo <milestogo@users.noreply.github.com> | 2017-02-11 22:11:06 -0800 |
commit | 2d655b18303620efc8eeb8529274a106cd438fd8 (patch) | |
tree | d96cfcc56e80ae278c3806608e4689116939e9a5 /keyboards/handwired/promethium/promethium.c | |
parent | 41c93575a838e9b201ca113165085f47198e109d (diff) | |
parent | a0c2305bd1153d9d578d73effd33896c2dbc26c8 (diff) |
Merge branch 'master' of https://github.com/jackhumbert/qmk_firmware
Diffstat (limited to 'keyboards/handwired/promethium/promethium.c')
-rw-r--r-- | keyboards/handwired/promethium/promethium.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/keyboards/handwired/promethium/promethium.c b/keyboards/handwired/promethium/promethium.c index a0035cce1a..62e2281fac 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); +} + |