diff options
| author | Joel Challis <git@zvecr.com> | 2025-04-19 22:52:25 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-19 22:52:25 +0100 |
| commit | ce8b8414d96e9d9ecb2e001fc5844a8fa9b7addc (patch) | |
| tree | ae6216a06adebe37cb44e887ef33a43d02496d67 /keyboards/handwired | |
| parent | 7e68cfc6fa4adf4b17e06cd5138cc9c2ad40f3e3 (diff) | |
Remove `bluefruit_le_read_battery_voltage` function (#25129)
Diffstat (limited to 'keyboards/handwired')
| -rw-r--r-- | keyboards/handwired/promethium/config.h | 5 | ||||
| -rw-r--r-- | keyboards/handwired/promethium/promethium.c | 17 | ||||
| -rw-r--r-- | keyboards/handwired/promethium/rules.mk | 2 |
3 files changed, 11 insertions, 13 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/>. | |||
| 63 | //#define NO_ACTION_ONESHOT | 63 | //#define NO_ACTION_ONESHOT |
| 64 | 64 | ||
| 65 | #define PS2_MOUSE_INIT_DELAY 2000 | 65 | #define PS2_MOUSE_INIT_DELAY 2000 |
| 66 | #define BATTERY_POLL 30000 | 66 | |
| 67 | #define MAX_VOLTAGE 4.2 | 67 | #define BATTERY_PIN B5 |
| 68 | #define MIN_VOLTAGE 3.2 | ||
| 69 | 68 | ||
| 70 | #ifndef __ASSEMBLER__ // assembler doesn't like enum in .h file | 69 | #ifndef __ASSEMBLER__ // assembler doesn't like enum in .h file |
| 71 | enum led_sequence { | 70 | 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 @@ | |||
| 1 | #include "promethium.h" | 1 | #include "keyboard.h" |
| 2 | #include "analog.h" | ||
| 3 | #include "timer.h" | 2 | #include "timer.h" |
| 4 | #include "matrix.h" | 3 | #include "battery.h" |
| 5 | #include "bluefruit_le.h" | ||
| 6 | 4 | ||
| 7 | // 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} | 5 | #ifndef BATTERY_POLL |
| 6 | # define BATTERY_POLL 30000 | ||
| 7 | #endif | ||
| 8 | 8 | ||
| 9 | uint8_t battery_level(void) { | 9 | uint8_t battery_level(void) { |
| 10 | float voltage = bluefruit_le_read_battery_voltage() * 2 * 3.3 / 1024; | 10 | // maintain legacy behaviour and scale 0-100 percent to 0-255 |
| 11 | if (voltage < MIN_VOLTAGE) return 0; | 11 | uint16_t percent = battery_get_percent(); |
| 12 | if (voltage > MAX_VOLTAGE) return 255; | 12 | return (percent * 255) / 100; |
| 13 | return (voltage - MIN_VOLTAGE) / (MAX_VOLTAGE - MIN_VOLTAGE) * 255; | ||
| 14 | } | 13 | } |
| 15 | 14 | ||
| 16 | __attribute__ ((weak)) | 15 | __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 | |||
| 5 | CUSTOM_MATRIX = yes | 5 | CUSTOM_MATRIX = yes |
| 6 | 6 | ||
| 7 | WS2812_DRIVER_REQUIRED = yes | 7 | WS2812_DRIVER_REQUIRED = yes |
| 8 | ANALOG_DRIVER_REQUIRED = yes | 8 | BATTERY_DRIVER_REQUIRED = yes |
| 9 | 9 | ||
| 10 | SRC += rgbsps.c | 10 | SRC += rgbsps.c |
| 11 | SRC += matrix.c | 11 | SRC += matrix.c |
