Commit | Line | Data |
---|---|---|
8ee389c9 | 1 | #include "promethium.h" |
5944ab24 PIN |
2 | #include "analog.h" |
3 | #include "timer.h" | |
4 | #include "matrix.h" | |
8ee389c9 | 5 | |
5944ab24 PIN |
6 | float battery_percentage(void) { |
7 | float voltage = analogRead(BATTERY_PIN) * 2 * 3.3 / 1024; | |
8 | float percentage = (voltage - 3.5) * 143; | |
9 | if (percentage > 100) { | |
10 | return 100; | |
11 | } else if (percentage < 0) { | |
12 | return 0; | |
13 | } else { | |
14 | return percentage; | |
15 | } | |
16 | } | |
17 | ||
18 | __attribute__ ((weak)) | |
19 | void battery_poll(float percentage) { | |
20 | } | |
8ee389c9 | 21 | |
5944ab24 | 22 | void matrix_init_kb(void) { |
8ee389c9 | 23 | matrix_init_user(); |
5944ab24 PIN |
24 | } |
25 | ||
26 | void matrix_scan_kb(void) { | |
27 | static uint16_t counter = BATTERY_POLL; | |
28 | counter++; | |
29 | ||
30 | if (counter > BATTERY_POLL) { | |
31 | counter = 0; | |
32 | battery_poll(battery_percentage()); | |
33 | } | |
909fd4ae PIN |
34 | |
35 | matrix_scan_user(); | |
5944ab24 PIN |
36 | } |
37 | ||
38 |