]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/handwired/promethium/promethium.c
Merge remote-tracking branch 'bigtunaio/layouts/adam-lee' into dev
[qmk_firmware.git] / keyboards / handwired / promethium / promethium.c
1 #include "promethium.h"
2 #include "analog.h"
3 #include "timer.h"
4 #include "matrix.h"
5 #include "musical_notes.h"
6
7 float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_A4, 0.0625);
8 float fauxclicky_released_note[2] = MUSICAL_NOTE(_A4, 0.0625);
9 float fauxclicky_beep_note[2] = MUSICAL_NOTE(_C6, 0.25);
10
11 // 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}
12
13 uint8_t battery_level(void) {
14     float voltage = analogRead(BATTERY_PIN) * 2 * 3.3 / 1024;
15     if (voltage < MIN_VOLTAGE) return 0;
16     if (voltage > MAX_VOLTAGE) return 255;
17     return (voltage - MIN_VOLTAGE) / (MAX_VOLTAGE - MIN_VOLTAGE) * 255;
18 }
19
20 __attribute__ ((weak))
21 void battery_poll(uint8_t level) {
22 }
23
24 void matrix_init_kb(void) {
25         matrix_init_user();
26 }
27
28 void matrix_scan_kb(void) {
29     static uint16_t counter = BATTERY_POLL;
30     counter++;
31
32     if (counter > BATTERY_POLL) {
33         counter = 0;
34         battery_poll(battery_level());
35     }
36
37     matrix_scan_user();
38 }
39
40 void led_set_kb(uint8_t usb_led) {
41     led_set_user(usb_led);
42 }
43
44 __attribute__ ((weak))
45 void led_set_user(uint8_t usb_led) {
46 }
47