keyboard stuff
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove `bluefruit_le_read_battery_voltage` function (#25129)

authored by

Joel Challis and committed by
GitHub
ce8b8414 7e68cfc6

+11 -58
-1
builddefs/common_features.mk
··· 897 897 898 898 ifeq ($(strip $(BLUETOOTH_DRIVER)), bluefruit_le) 899 899 SPI_DRIVER_REQUIRED = yes 900 - ANALOG_DRIVER_REQUIRED = yes 901 900 SRC += $(DRIVER_PATH)/bluetooth/bluetooth.c 902 901 SRC += $(DRIVER_PATH)/bluetooth/bluefruit_le.cpp 903 902 endif
-21
drivers/bluetooth/bluefruit_le.cpp
··· 32 32 # define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE 33 33 #endif 34 34 35 - #define SAMPLE_BATTERY 36 35 #define ConnectionUpdateInterval 1000 /* milliseconds */ 37 - 38 - #ifndef BATTERY_LEVEL_PIN 39 - # define BATTERY_LEVEL_PIN B5 40 - #endif 41 36 42 37 static struct { 43 38 bool is_connected; ··· 48 43 #define UsingEvents 2 49 44 bool event_flags; 50 45 51 - #ifdef SAMPLE_BATTERY 52 - uint16_t last_battery_update; 53 - uint32_t vbat; 54 - #endif 55 46 uint16_t last_connection_update; 56 47 } state; 57 48 ··· 549 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 545 static bool process_queue_item(struct queue_item *item, uint16_t timeout) { ··· 653 636 while (!send_buf.enqueue(item)) { 654 637 send_buf_send_one(); 655 638 } 656 - } 657 - 658 - uint32_t bluefruit_le_read_battery_voltage(void) { 659 - return state.vbat; 660 639 } 661 640 662 641 bool bluefruit_le_set_mode_leds(bool on) {
-4
drivers/bluetooth/bluefruit_le.h
··· 45 45 * change. */ 46 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 48 extern bool bluefruit_le_set_mode_leds(bool on); 53 49 extern bool bluefruit_le_set_power_level(int8_t level); 54 50
+2 -3
keyboards/handwired/promethium/config.h
··· 63 63 //#define NO_ACTION_ONESHOT 64 64 65 65 #define PS2_MOUSE_INIT_DELAY 2000 66 - #define BATTERY_POLL 30000 67 - #define MAX_VOLTAGE 4.2 68 - #define MIN_VOLTAGE 3.2 66 + 67 + #define BATTERY_PIN B5 69 68 70 69 #ifndef __ASSEMBLER__ // assembler doesn't like enum in .h file 71 70 enum led_sequence {
+8 -9
keyboards/handwired/promethium/promethium.c
··· 1 - #include "promethium.h" 2 - #include "analog.h" 1 + #include "keyboard.h" 3 2 #include "timer.h" 4 - #include "matrix.h" 5 - #include "bluefruit_le.h" 3 + #include "battery.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 9 uint8_t battery_level(void) { 10 - float voltage = bluefruit_le_read_battery_voltage() * 2 * 3.3 / 1024; 11 - if (voltage < MIN_VOLTAGE) return 0; 12 - if (voltage > MAX_VOLTAGE) return 255; 13 - return (voltage - MIN_VOLTAGE) / (MAX_VOLTAGE - MIN_VOLTAGE) * 255; 10 + // maintain legacy behaviour and scale 0-100 percent to 0-255 11 + uint16_t percent = battery_get_percent(); 12 + return (percent * 255) / 100; 14 13 } 15 14 16 15 __attribute__ ((weak))
+1 -1
keyboards/handwired/promethium/rules.mk
··· 5 5 CUSTOM_MATRIX = yes 6 6 7 7 WS2812_DRIVER_REQUIRED = yes 8 - ANALOG_DRIVER_REQUIRED = yes 8 + BATTERY_DRIVER_REQUIRED = yes 9 9 10 10 SRC += rgbsps.c 11 11 SRC += matrix.c
-1
keyboards/matrix/falcon/config.h
··· 29 29 //pin setting 30 30 #define LED_POWER_PIN D5 31 31 #define CHG_EN_PIN E6 32 - #define BATTERY_LEVEL_PIN F0
-18
keyboards/tokyokeyboard/alix40/config.h
··· 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