mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-06-06 16:32:49 +00:00
Remove bluefruit_le_read_battery_voltage
function (#25129)
This commit is contained in:
parent
7e68cfc6fa
commit
ce8b8414d9
@ -897,7 +897,6 @@ ifeq ($(strip $(BLUETOOTH_ENABLE)), yes)
|
|||||||
|
|
||||||
ifeq ($(strip $(BLUETOOTH_DRIVER)), bluefruit_le)
|
ifeq ($(strip $(BLUETOOTH_DRIVER)), bluefruit_le)
|
||||||
SPI_DRIVER_REQUIRED = yes
|
SPI_DRIVER_REQUIRED = yes
|
||||||
ANALOG_DRIVER_REQUIRED = yes
|
|
||||||
SRC += $(DRIVER_PATH)/bluetooth/bluetooth.c
|
SRC += $(DRIVER_PATH)/bluetooth/bluetooth.c
|
||||||
SRC += $(DRIVER_PATH)/bluetooth/bluefruit_le.cpp
|
SRC += $(DRIVER_PATH)/bluetooth/bluefruit_le.cpp
|
||||||
endif
|
endif
|
||||||
|
@ -32,13 +32,8 @@
|
|||||||
# define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE
|
# define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SAMPLE_BATTERY
|
|
||||||
#define ConnectionUpdateInterval 1000 /* milliseconds */
|
#define ConnectionUpdateInterval 1000 /* milliseconds */
|
||||||
|
|
||||||
#ifndef BATTERY_LEVEL_PIN
|
|
||||||
# define BATTERY_LEVEL_PIN B5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
bool is_connected;
|
bool is_connected;
|
||||||
bool initialized;
|
bool initialized;
|
||||||
@ -48,10 +43,6 @@ static struct {
|
|||||||
#define UsingEvents 2
|
#define UsingEvents 2
|
||||||
bool event_flags;
|
bool event_flags;
|
||||||
|
|
||||||
#ifdef SAMPLE_BATTERY
|
|
||||||
uint16_t last_battery_update;
|
|
||||||
uint32_t vbat;
|
|
||||||
#endif
|
|
||||||
uint16_t last_connection_update;
|
uint16_t last_connection_update;
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
@ -549,14 +540,6 @@ void bluefruit_le_task(void) {
|
|||||||
set_connected(atoi(resbuf));
|
set_connected(atoi(resbuf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SAMPLE_BATTERY
|
|
||||||
if (timer_elapsed(state.last_battery_update) > BatteryUpdateInterval && resp_buf.empty()) {
|
|
||||||
state.last_battery_update = timer_read();
|
|
||||||
|
|
||||||
state.vbat = analogReadPin(BATTERY_LEVEL_PIN);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool process_queue_item(struct queue_item *item, uint16_t timeout) {
|
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) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t bluefruit_le_read_battery_voltage(void) {
|
|
||||||
return state.vbat;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bluefruit_le_set_mode_leds(bool on) {
|
bool bluefruit_le_set_mode_leds(bool on) {
|
||||||
if (!state.configured) {
|
if (!state.configured) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -45,10 +45,6 @@ extern void bluefruit_le_send_consumer(uint16_t usage);
|
|||||||
* change. */
|
* change. */
|
||||||
extern void bluefruit_le_send_mouse(report_mouse_t *report);
|
extern void bluefruit_le_send_mouse(report_mouse_t *report);
|
||||||
|
|
||||||
/* Compute battery voltage by reading an analog pin.
|
|
||||||
* Returns the integer number of millivolts */
|
|
||||||
extern uint32_t bluefruit_le_read_battery_voltage(void);
|
|
||||||
|
|
||||||
extern bool bluefruit_le_set_mode_leds(bool on);
|
extern bool bluefruit_le_set_mode_leds(bool on);
|
||||||
extern bool bluefruit_le_set_power_level(int8_t level);
|
extern bool bluefruit_le_set_power_level(int8_t level);
|
||||||
|
|
||||||
|
@ -63,9 +63,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
//#define NO_ACTION_ONESHOT
|
//#define NO_ACTION_ONESHOT
|
||||||
|
|
||||||
#define PS2_MOUSE_INIT_DELAY 2000
|
#define PS2_MOUSE_INIT_DELAY 2000
|
||||||
#define BATTERY_POLL 30000
|
|
||||||
#define MAX_VOLTAGE 4.2
|
#define BATTERY_PIN B5
|
||||||
#define MIN_VOLTAGE 3.2
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLER__ // assembler doesn't like enum in .h file
|
#ifndef __ASSEMBLER__ // assembler doesn't like enum in .h file
|
||||||
enum led_sequence {
|
enum led_sequence {
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
#include "promethium.h"
|
#include "keyboard.h"
|
||||||
#include "analog.h"
|
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "matrix.h"
|
#include "battery.h"
|
||||||
#include "bluefruit_le.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) {
|
uint8_t battery_level(void) {
|
||||||
float voltage = bluefruit_le_read_battery_voltage() * 2 * 3.3 / 1024;
|
// maintain legacy behaviour and scale 0-100 percent to 0-255
|
||||||
if (voltage < MIN_VOLTAGE) return 0;
|
uint16_t percent = battery_get_percent();
|
||||||
if (voltage > MAX_VOLTAGE) return 255;
|
return (percent * 255) / 100;
|
||||||
return (voltage - MIN_VOLTAGE) / (MAX_VOLTAGE - MIN_VOLTAGE) * 255;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
|
@ -5,7 +5,7 @@ PS2_DRIVER = interrupt
|
|||||||
CUSTOM_MATRIX = yes
|
CUSTOM_MATRIX = yes
|
||||||
|
|
||||||
WS2812_DRIVER_REQUIRED = yes
|
WS2812_DRIVER_REQUIRED = yes
|
||||||
ANALOG_DRIVER_REQUIRED = yes
|
BATTERY_DRIVER_REQUIRED = yes
|
||||||
|
|
||||||
SRC += rgbsps.c
|
SRC += rgbsps.c
|
||||||
SRC += matrix.c
|
SRC += matrix.c
|
||||||
|
@ -29,4 +29,3 @@
|
|||||||
//pin setting
|
//pin setting
|
||||||
#define LED_POWER_PIN D5
|
#define LED_POWER_PIN D5
|
||||||
#define CHG_EN_PIN E6
|
#define CHG_EN_PIN E6
|
||||||
#define BATTERY_LEVEL_PIN F0
|
|
||||||
|
@ -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
|
|
Loading…
Reference in New Issue
Block a user