Implement battery level indicator
parent
07879bf66b
commit
5944ab246a
@ -1,6 +1,36 @@
|
||||
#include "promethium.h"
|
||||
#include "analog.h"
|
||||
#include "timer.h"
|
||||
#include "matrix.h"
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
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) {
|
||||
}
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
matrix_init_user();
|
||||
}
|
||||
}
|
||||
|
||||
void matrix_scan_kb(void) {
|
||||
static uint16_t counter = BATTERY_POLL;
|
||||
counter++;
|
||||
|
||||
if (counter > BATTERY_POLL) {
|
||||
counter = 0;
|
||||
battery_poll(battery_percentage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
void rgbsps_set(uint8_t index, uint8_t r, uint8_t g, uint8_t b);
|
||||
void rgbsps_setall(uint8_t r, uint8_t g, uint8_t b);
|
||||
void rgbsps_turnoff(void);
|
||||
void rgbsps_send(void);
|
||||
void rgbsps_send(void);
|
||||
void rgbsps_sethsv(uint8_t index, uint16_t hue, uint8_t sat, uint8_t val);
|
Loading…
Reference in New Issue