Remove bluefruit_le_read_battery_voltage function (#25129)

This commit is contained in:
Joel Challis 2025-04-19 22:52:25 +01:00 committed by GitHub
parent 7e68cfc6fa
commit ce8b8414d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 11 additions and 58 deletions

View file

@ -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 {

View file

@ -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))

View file

@ -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