From 11ab52582c0aa66de221d80795af63ea3a9b5428 Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Mon, 18 Apr 2022 21:02:20 -0500 Subject: [PATCH] refactor(battery): Auto enable battery drivers 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. --- app/boards/arm/bluemicro840/Kconfig.defconfig | 3 --- app/boards/arm/bt60/Kconfig.defconfig | 3 --- app/boards/arm/mikoto/Kconfig.defconfig | 3 --- app/boards/arm/nice60/Kconfig.defconfig | 3 --- app/boards/arm/nice_nano/Kconfig.defconfig | 14 -------------- app/boards/arm/nrfmicro/Kconfig.defconfig | 3 --- app/boards/arm/s40nc/Kconfig.defconfig | 3 --- app/boards/seeeduino_xiao_ble.conf | 1 - app/drivers/sensor/battery/Kconfig | 9 +++++++-- 9 files changed, 7 insertions(+), 35 deletions(-) diff --git a/app/boards/arm/bluemicro840/Kconfig.defconfig b/app/boards/arm/bluemicro840/Kconfig.defconfig index bc68f311..5d911ec6 100644 --- a/app/boards/arm/bluemicro840/Kconfig.defconfig +++ b/app/boards/arm/bluemicro840/Kconfig.defconfig @@ -24,7 +24,4 @@ config ZMK_BLE config ZMK_USB default y -config ZMK_BATTERY_VOLTAGE_DIVIDER - default y - endif # BOARD_BLUEMICRO840_V1 diff --git a/app/boards/arm/bt60/Kconfig.defconfig b/app/boards/arm/bt60/Kconfig.defconfig index 7e7ab124..bad1e7cd 100644 --- a/app/boards/arm/bt60/Kconfig.defconfig +++ b/app/boards/arm/bt60/Kconfig.defconfig @@ -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" diff --git a/app/boards/arm/mikoto/Kconfig.defconfig b/app/boards/arm/mikoto/Kconfig.defconfig index 2ca77b9e..6aafc613 100644 --- a/app/boards/arm/mikoto/Kconfig.defconfig +++ b/app/boards/arm/mikoto/Kconfig.defconfig @@ -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 diff --git a/app/boards/arm/nice60/Kconfig.defconfig b/app/boards/arm/nice60/Kconfig.defconfig index 42d417ab..39cf1540 100644 --- a/app/boards/arm/nice60/Kconfig.defconfig +++ b/app/boards/arm/nice60/Kconfig.defconfig @@ -22,7 +22,4 @@ config ZMK_BLE config ZMK_USB default y -config ZMK_BATTERY_VOLTAGE_DIVIDER - default y - endif # BOARD_NICE60 diff --git a/app/boards/arm/nice_nano/Kconfig.defconfig b/app/boards/arm/nice_nano/Kconfig.defconfig index 24571653..ad3fefef 100644 --- a/app/boards/arm/nice_nano/Kconfig.defconfig +++ b/app/boards/arm/nice_nano/Kconfig.defconfig @@ -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 diff --git a/app/boards/arm/nrfmicro/Kconfig.defconfig b/app/boards/arm/nrfmicro/Kconfig.defconfig index 754a430e..159d9ade 100644 --- a/app/boards/arm/nrfmicro/Kconfig.defconfig +++ b/app/boards/arm/nrfmicro/Kconfig.defconfig @@ -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 diff --git a/app/boards/arm/s40nc/Kconfig.defconfig b/app/boards/arm/s40nc/Kconfig.defconfig index 0f407151..266f8443 100644 --- a/app/boards/arm/s40nc/Kconfig.defconfig +++ b/app/boards/arm/s40nc/Kconfig.defconfig @@ -25,7 +25,4 @@ config ZMK_BLE config ZMK_USB default y -config ZMK_BATTERY_VOLTAGE_DIVIDER - default y - endif # BOARD_S40NC diff --git a/app/boards/seeeduino_xiao_ble.conf b/app/boards/seeeduino_xiao_ble.conf index 22e6a9b5..92367028 100644 --- a/app/boards/seeeduino_xiao_ble.conf +++ b/app/boards/seeeduino_xiao_ble.conf @@ -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 diff --git a/app/drivers/sensor/battery/Kconfig b/app/drivers/sensor/battery/Kconfig index fd8cd26d..d7c82bb0 100644 --- a/app/drivers/sensor/battery/Kconfig +++ b/app/drivers/sensor/battery/Kconfig @@ -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