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 | |
| parent | 7e68cfc6fa4adf4b17e06cd5138cc9c2ad40f3e3 (diff) | |
Remove `bluefruit_le_read_battery_voltage` function (#25129)
| -rw-r--r-- | builddefs/common_features.mk | 1 | ||||
| -rw-r--r-- | drivers/bluetooth/bluefruit_le.cpp | 21 | ||||
| -rw-r--r-- | drivers/bluetooth/bluefruit_le.h | 4 | ||||
| -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 | ||||
| -rw-r--r-- | keyboards/matrix/falcon/config.h | 1 | ||||
| -rw-r--r-- | keyboards/tokyokeyboard/alix40/config.h | 18 |
8 files changed, 11 insertions, 58 deletions
diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index f30a456fc3..ec856715b0 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk | |||
| @@ -897,7 +897,6 @@ ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) | |||
| 897 | 897 | ||
| 898 | ifeq ($(strip $(BLUETOOTH_DRIVER)), bluefruit_le) | 898 | ifeq ($(strip $(BLUETOOTH_DRIVER)), bluefruit_le) |
| 899 | SPI_DRIVER_REQUIRED = yes | 899 | SPI_DRIVER_REQUIRED = yes |
| 900 | ANALOG_DRIVER_REQUIRED = yes | ||
| 901 | SRC += $(DRIVER_PATH)/bluetooth/bluetooth.c | 900 | SRC += $(DRIVER_PATH)/bluetooth/bluetooth.c |
| 902 | SRC += $(DRIVER_PATH)/bluetooth/bluefruit_le.cpp | 901 | SRC += $(DRIVER_PATH)/bluetooth/bluefruit_le.cpp |
| 903 | endif | 902 | endif |
diff --git a/drivers/bluetooth/bluefruit_le.cpp b/drivers/bluetooth/bluefruit_le.cpp index 218eca2195..5fdd104dcf 100644 --- a/drivers/bluetooth/bluefruit_le.cpp +++ b/drivers/bluetooth/bluefruit_le.cpp | |||
| @@ -32,13 +32,8 @@ | |||
| 32 | # define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE | 32 | # define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | #define SAMPLE_BATTERY | ||
| 36 | #define ConnectionUpdateInterval 1000 /* milliseconds */ | 35 | #define ConnectionUpdateInterval 1000 /* milliseconds */ |
| 37 | 36 | ||
| 38 | #ifndef BATTERY_LEVEL_PIN | ||
| 39 | # define BATTERY_LEVEL_PIN B5 | ||
| 40 | #endif | ||
| 41 | |||
| 42 | static struct { | 37 | static struct { |
| 43 | bool is_connected; | 38 | bool is_connected; |
| 44 | bool initialized; | 39 | bool initialized; |
| @@ -48,10 +43,6 @@ static struct { | |||
| 48 | #define UsingEvents 2 | 43 | #define UsingEvents 2 |
| 49 | bool event_flags; | 44 | bool event_flags; |
| 50 | 45 | ||
| 51 | #ifdef SAMPLE_BATTERY | ||
| 52 | uint16_t last_battery_update; | ||
| 53 | uint32_t vbat; | ||
| 54 | #endif | ||
| 55 | uint16_t last_connection_update; | 46 | uint16_t last_connection_update; |
| 56 | } state; | 47 | } state; |
| 57 | 48 | ||
| @@ -549,14 +540,6 @@ void bluefruit_le_task(void) { | |||
| 549 | set_connected(atoi(resbuf)); | 540 | set_connected(atoi(resbuf)); |
| 550 | } | 541 | } |
| 551 | } | 542 | } |
| 552 | |||
| 553 | #ifdef SAMPLE_BATTERY | ||
| 554 | if (timer_elapsed(state.last_battery_update) > BatteryUpdateInterval && resp_buf.empty()) { | ||
| 555 | state.last_battery_update = timer_read(); | ||
| 556 | |||
| 557 | state.vbat = analogReadPin(BATTERY_LEVEL_PIN); | ||
| 558 | } | ||
| 559 | #endif | ||
| 560 | } | 543 | } |
| 561 | 544 | ||
| 562 | static bool process_queue_item(struct queue_item *item, uint16_t timeout) { | 545 | static bool process_queue_item(struct queue_item *item, uint16_t timeout) { |
| @@ -655,10 +638,6 @@ void bluefruit_le_send_mouse(report_mouse_t *report) { | |||
| 655 | } | 638 | } |
| 656 | } | 639 | } |
| 657 | 640 | ||
| 658 | uint32_t bluefruit_le_read_battery_voltage(void) { | ||
| 659 | return state.vbat; | ||
| 660 | } | ||
| 661 | |||
| 662 | bool bluefruit_le_set_mode_leds(bool on) { | 641 | bool bluefruit_le_set_mode_leds(bool on) { |
| 663 | if (!state.configured) { | 642 | if (!state.configured) { |
| 664 | return false; | 643 | return false; |
diff --git a/drivers/bluetooth/bluefruit_le.h b/drivers/bluetooth/bluefruit_le.h index a3de03c35c..5efe92b6e0 100644 --- a/drivers/bluetooth/bluefruit_le.h +++ b/drivers/bluetooth/bluefruit_le.h | |||
| @@ -45,10 +45,6 @@ extern void bluefruit_le_send_consumer(uint16_t usage); | |||
| 45 | * change. */ | 45 | * change. */ |
| 46 | extern void bluefruit_le_send_mouse(report_mouse_t *report); | 46 | extern void bluefruit_le_send_mouse(report_mouse_t *report); |
| 47 | 47 | ||
| 48 | /* Compute battery voltage by reading an analog pin. | ||
| 49 | * Returns the integer number of millivolts */ | ||
| 50 | extern uint32_t bluefruit_le_read_battery_voltage(void); | ||
| 51 | |||
| 52 | extern bool bluefruit_le_set_mode_leds(bool on); | 48 | extern bool bluefruit_le_set_mode_leds(bool on); |
| 53 | extern bool bluefruit_le_set_power_level(int8_t level); | 49 | extern bool bluefruit_le_set_power_level(int8_t level); |
| 54 | 50 | ||
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 |
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 @@ | |||
| 29 | //pin setting | 29 | //pin setting |
| 30 | #define LED_POWER_PIN D5 | 30 | #define LED_POWER_PIN D5 |
| 31 | #define CHG_EN_PIN E6 | 31 | #define CHG_EN_PIN E6 |
| 32 | #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 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2021 quadcube <james@quadcube.xyz> | ||
| 3 | This program is free software: you can redistribute it and/or modify | ||
| 4 | it under the terms of the GNU General Public License as published by | ||
| 5 | the Free Software Foundation, either version 2 of the License, or | ||
| 6 | (at your option) any later version. | ||
| 7 | This program is distributed in the hope that it will be useful, | ||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 10 | GNU General Public License for more details. | ||
| 11 | You should have received a copy of the GNU General Public License | ||
| 12 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #pragma once | ||
| 16 | |||
| 17 | /* Bluetooth */ | ||
| 18 | #define BATTERY_LEVEL_PIN B6 | ||
