1 #include "promethium.h"
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}
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;
15 __attribute__ ((weak))
16 void battery_poll(uint8_t level) {
19 void matrix_init_kb(void) {
23 void matrix_scan_kb(void) {
24 static uint16_t counter = BATTERY_POLL;
27 if (counter > BATTERY_POLL) {
29 battery_poll(battery_level());
35 void led_set_kb(uint8_t usb_led) {
36 led_set_user(usb_led);
39 __attribute__ ((weak))
40 void led_set_user(uint8_t usb_led) {