aboutsummaryrefslogtreecommitdiff
path: root/keyboards/handwired/promethium/promethium.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/handwired/promethium/promethium.c')
-rw-r--r--keyboards/handwired/promethium/promethium.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/keyboards/handwired/promethium/promethium.c b/keyboards/handwired/promethium/promethium.c
index 63139ac09d..c94a27a4de 100644
--- a/keyboards/handwired/promethium/promethium.c
+++ b/keyboards/handwired/promethium/promethium.c
@@ -1,16 +1,15 @@
-#include "promethium.h"
-#include "analog.h"
+#include "keyboard.h"
#include "timer.h"
-#include "matrix.h"
-#include "bluefruit_le.h"
+#include "battery.h"
-// 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}
+#ifndef BATTERY_POLL
+# define BATTERY_POLL 30000
+#endif
uint8_t battery_level(void) {
- float voltage = bluefruit_le_read_battery_voltage() * 2 * 3.3 / 1024;
- if (voltage < MIN_VOLTAGE) return 0;
- if (voltage > MAX_VOLTAGE) return 255;
- return (voltage - MIN_VOLTAGE) / (MAX_VOLTAGE - MIN_VOLTAGE) * 255;
+ // maintain legacy behaviour and scale 0-100 percent to 0-255
+ uint16_t percent = battery_get_percent();
+ return (percent * 255) / 100;
}
__attribute__ ((weak))