aboutsummaryrefslogtreecommitdiffstats
path: root/keyboards
diff options
context:
space:
mode:
authorJoel Challis2025-04-19 23:52:25 +0200
committerGitHub2025-04-19 23:52:25 +0200
commitce8b8414d96e9d9ecb2e001fc5844a8fa9b7addc (patch)
treeae6216a06adebe37cb44e887ef33a43d02496d67 /keyboards
parent7e68cfc6fa4adf4b17e06cd5138cc9c2ad40f3e3 (diff)
Remove `bluefruit_le_read_battery_voltage` function (#25129)
Diffstat (limited to 'keyboards')
-rw-r--r--keyboards/handwired/promethium/config.h5
-rw-r--r--keyboards/handwired/promethium/promethium.c17
-rw-r--r--keyboards/handwired/promethium/rules.mk2
-rw-r--r--keyboards/matrix/falcon/config.h1
-rw-r--r--keyboards/tokyokeyboard/alix40/config.h18
5 files changed, 11 insertions, 32 deletions
diff --git a/keyboards/handwired/promethium/config.h b/keyboards/handwired/promethium/config.h
index 806726b5eb..974a4f951f 100644
--- a/keyboards/handwired/promethium/config.h
+++ b/keyboards/handwired/promethium/config.h
@@ -63,9 +63,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define NO_ACTION_ONESHOT
#define PS2_MOUSE_INIT_DELAY 2000
-#define BATTERY_POLL 30000
-#define MAX_VOLTAGE 4.2
-#define MIN_VOLTAGE 3.2
+
+#define BATTERY_PIN B5
#ifndef __ASSEMBLER__ // assembler doesn't like enum in .h file
enum led_sequence {
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))
diff --git a/keyboards/handwired/promethium/rules.mk b/keyboards/handwired/promethium/rules.mk
index 7f20880066..4012f8ca29 100644
--- a/keyboards/handwired/promethium/rules.mk
+++ b/keyboards/handwired/promethium/rules.mk
@@ -5,7 +5,7 @@ PS2_DRIVER = interrupt
CUSTOM_MATRIX = yes
WS2812_DRIVER_REQUIRED = yes
-ANALOG_DRIVER_REQUIRED = yes
+BATTERY_DRIVER_REQUIRED = yes
SRC += rgbsps.c
SRC += matrix.c
diff --git a/keyboards/matrix/falcon/config.h b/keyboards/matrix/falcon/config.h
index 9065dd0770..66787658fd 100644
--- a/keyboards/matrix/falcon/config.h
+++ b/keyboards/matrix/falcon/config.h
@@ -29,4 +29,3 @@
//pin setting
#define LED_POWER_PIN D5
#define CHG_EN_PIN E6
-#define BATTERY_LEVEL_PIN F0
diff --git a/keyboards/tokyokeyboard/alix40/config.h b/keyboards/tokyokeyboard/alix40/config.h
deleted file mode 100644
index 51d446c6d2..0000000000
--- a/keyboards/tokyokeyboard/alix40/config.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
-Copyright 2021 quadcube <james@quadcube.xyz>
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#pragma once
-
-/* Bluetooth */
-#define BATTERY_LEVEL_PIN B6