diff options
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 a0035cce1..62e2281fa 100644 --- a/keyboards/handwired/promethium/promethium.c +++ b/keyboards/handwired/promethium/promethium.c | |||
| @@ -1,6 +1,38 @@ | |||
| 1 | #include "promethium.h" | 1 | #include "promethium.h" |
| 2 | #include "analog.h" | ||
| 3 | #include "timer.h" | ||
| 4 | #include "matrix.h" | ||
| 2 | 5 | ||
| 3 | void matrix_init_kb(void) { | 6 | // 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} |
| 7 | |||
| 8 | uint8_t battery_level(void) { | ||
| 9 | float voltage = analogRead(BATTERY_PIN) * 2 * 3.3 / 1024; | ||
| 10 | if (voltage < MIN_VOLTAGE) return 0; | ||
| 11 | if (voltage > MAX_VOLTAGE) return 255; | ||
| 12 | return (voltage - MIN_VOLTAGE) / (MAX_VOLTAGE - MIN_VOLTAGE) * 255; | ||
| 13 | } | ||
| 14 | |||
| 15 | __attribute__ ((weak)) | ||
| 16 | void battery_poll(uint8_t level) { | ||
| 17 | } | ||
| 4 | 18 | ||
| 19 | void matrix_init_kb(void) { | ||
| 5 | matrix_init_user(); | 20 | matrix_init_user(); |
| 6 | } \ No newline at end of file | 21 | } |
| 22 | |||
| 23 | void matrix_scan_kb(void) { | ||
| 24 | static uint16_t counter = BATTERY_POLL; | ||
| 25 | counter++; | ||
| 26 | |||
| 27 | if (counter > BATTERY_POLL) { | ||
| 28 | counter = 0; | ||
| 29 | battery_poll(battery_level()); | ||
| 30 | } | ||
| 31 | |||
| 32 | matrix_scan_user(); | ||
| 33 | } | ||
| 34 | |||
| 35 | void led_set_kb(uint8_t usb_led) { | ||
| 36 | led_set_user(usb_led); | ||
| 37 | } | ||
| 38 | |||
