1
0
Fork 0
qmk_firmware/keyboards/handwired/promethium/promethium.c

39 lines
711 B
C
Raw Normal View History

2016-11-26 06:11:40 +00:00
#include "promethium.h"
2017-02-10 14:28:46 +00:00
#include "analog.h"
#include "timer.h"
#include "matrix.h"
2016-11-26 06:11:40 +00:00
2017-02-10 14:28:46 +00:00
float battery_percentage(void) {
float voltage = analogRead(BATTERY_PIN) * 2 * 3.3 / 1024;
float percentage = (voltage - 3.5) * 143;
if (percentage > 100) {
return 100;
} else if (percentage < 0) {
return 0;
} else {
return percentage;
}
}
__attribute__ ((weak))
void battery_poll(float percentage) {
}
2016-11-26 06:11:40 +00:00
2017-02-10 14:28:46 +00:00
void matrix_init_kb(void) {
2016-11-26 06:11:40 +00:00
matrix_init_user();
2017-02-10 14:28:46 +00:00
}
void matrix_scan_kb(void) {
static uint16_t counter = BATTERY_POLL;
counter++;
if (counter > BATTERY_POLL) {
counter = 0;
battery_poll(battery_percentage());
}
2017-02-10 17:07:10 +00:00
matrix_scan_user();
2017-02-10 14:28:46 +00:00
}