Skip to content

Commit

Permalink
refactor(battery): Auto enable battery drivers
Browse files Browse the repository at this point in the history
CONFIG_ZMK_BATTERY_NRF_VDDH and CONFIG_ZMK_BATTERY_VOLTAGE_DIVIDER are
now automatically enabled if a DT node with the matching "compatible"
property is present and enabled, so they no longer need to be manually
set for each board.
  • Loading branch information
joelspadin authored and petejohanson committed Apr 26, 2022
1 parent 6d6efa3 commit 11ab525
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 35 deletions.
3 changes: 0 additions & 3 deletions app/boards/arm/bluemicro840/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,4 @@ config ZMK_BLE
config ZMK_USB
default y

config ZMK_BATTERY_VOLTAGE_DIVIDER
default y

endif # BOARD_BLUEMICRO840_V1
3 changes: 0 additions & 3 deletions app/boards/arm/bt60/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ config ZMK_BLE
config ZMK_USB
default y

config ZMK_BATTERY_VOLTAGE_DIVIDER
default y

config ZMK_KEYBOARD_NAME
default "BT60"

Expand Down
3 changes: 0 additions & 3 deletions app/boards/arm/mikoto/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,4 @@ choice BOARD_MIKOTO_CHARGER_CURRENT
default BOARD_MIKOTO_CHARGER_CURRENT_100MA
endchoice

config ZMK_BATTERY_VOLTAGE_DIVIDER
default y

endif # BOARD_MIKOTO_520
3 changes: 0 additions & 3 deletions app/boards/arm/nice60/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,4 @@ config ZMK_BLE
config ZMK_USB
default y

config ZMK_BATTERY_VOLTAGE_DIVIDER
default y

endif # BOARD_NICE60
14 changes: 0 additions & 14 deletions app/boards/arm/nice_nano/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,3 @@ config ZMK_USB
default y

endif # BOARD_NICE_NANO || BOARD_NICE_NANO_V2

if BOARD_NICE_NANO

config ZMK_BATTERY_VOLTAGE_DIVIDER
default y

endif # BOARD_NICE_NANO

if BOARD_NICE_NANO_V2

config ZMK_BATTERY_NRF_VDDH
default y

endif # BOARD_NICE_NANO_V2
3 changes: 0 additions & 3 deletions app/boards/arm/nrfmicro/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ if BOARD_NRFMICRO_13
config BOARD_NRFMICRO_CHARGER
default y

config ZMK_BATTERY_VOLTAGE_DIVIDER
default y

endif # BOARD_NRFMICRO_13

endif # BOARD_NRFMICRO_11 || BOARD_NRFMICRO_11_FLIPPED || BOARD_NRFMICRO_13
3 changes: 0 additions & 3 deletions app/boards/arm/s40nc/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,4 @@ config ZMK_BLE
config ZMK_USB
default y

config ZMK_BATTERY_VOLTAGE_DIVIDER
default y

endif # BOARD_S40NC
1 change: 0 additions & 1 deletion app/boards/seeeduino_xiao_ble.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ CONFIG_CONSOLE=n
CONFIG_SERIAL=n
CONFIG_UART_CONSOLE=n
CONFIG_UART_INTERRUPT_DRIVEN=n
CONFIG_ZMK_BATTERY_VOLTAGE_DIVIDER=y
CONFIG_ZMK_USB=y
CONFIG_ZMK_BLE=y

9 changes: 7 additions & 2 deletions app/drivers/sensor/battery/Kconfig
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
# Copyright (c) 2020-2021 The ZMK Contributors
# SPDX-License-Identifier: MIT

DT_COMPAT_ZMK_BATTERY_NRF_VDDH := zmk,battery-nrf-vddh
DT_COMPAT_ZMK_BATTERY_VOLTAGE_DIVIDER := zmk,battery-voltage-divider

config ZMK_BATTERY
bool "ZMK battery monitoring"
help
Enable battery monitoring

config ZMK_BATTERY_NRF_VDDH
bool "ZMK nRF VDDH battery monitoring"
bool
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_BATTERY_NRF_VDDH))
select ADC
select ZMK_BATTERY
help
Enable ZMK nRF VDDH voltage driver for battery monitoring.

config ZMK_BATTERY_VOLTAGE_DIVIDER
bool "ZMK battery voltage divider"
bool
default $(dt_compat_enabled,$(DT_COMPAT_ZMK_BATTERY_VOLTAGE_DIVIDER))
select ADC
select ZMK_BATTERY
help
Expand Down

0 comments on commit 11ab525

Please sign in to comment.