-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Disable battery sensors if reporting is off #1867
fix: Disable battery sensors if reporting is off #1867
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thought on the approach chosen here.
app/drivers/sensor/battery/Kconfig
Outdated
select ZMK_BATTERY | ||
imply ZMK_BATTERY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems reasonable, but why not also make this depends on SENSOR
as an alternative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand you correctly that sounds like one of the other alternatives I mentioned:
Another option to directly disable the symbols would be to add depends on ZMK_BATTERY_REPORTING on each sensor, but this seemed slightly better to me. Let me know if that makes more sense.
But depends on SENSOR
is probably better that that 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although, in that case the battery sensors would still get compiled in if SENSOR
is enabled through some other symbol like ZMK_KEYMAP_SENSORS
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a fixup commit that converts to that; everything builds OK but enabling sensors gets the battery sensors (but not reporting) enabled as well:
> west build -d build/kl2 -b nice_nano_v2 -- -DSHIELD=kyria_left -DCONFIG_ZMK_BATTERY_REPORTING=n -DCONFIG_EC11=y
[...]
> rg BATTERY build/kl2/zephyr/.config
87:# CONFIG_ZMK_BATTERY_REPORTING is not set
238:CONFIG_DT_HAS_ZMK_BATTERY_NRF_VDDH_ENABLED=y
481:CONFIG_ZMK_BATTERY=y
482:CONFIG_ZMK_BATTERY_NRF_VDDH=y
Not sure if that's an issue or not, I can keep or drop the commit depending on what you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's expected behavior, if the nodes are enabled, and the necessary support Kconfig symbols are enabled, we auto-enable the driver. You'd either disable the node in the DTS, or disable it explicitly in the Kconfig as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, does the current state look good in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I believe this is correct now. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Currenly when
ZMK_BATTERY_REPORTING
is turned off, builds with battery sensors fail due to a kernel init priority missing (ex. 1, 2), which I think is due toSENSOR
Kconfig not getting selected.Ideally the sensors wouldn't be enabled at all if battery level reporting is disabled but having them in the DT automatically enables them. This change disables them (in a bit of a roundabout way) through disabling
ZMK_BATTERY
:zmk/app/drivers/sensor/CMakeLists.txt
Line 4 in bbb27ac
Another option to directly disable the symbols would be to add
depends on ZMK_BATTERY_REPORTING
on each sensor, but this seemed slightly better to me. Let me know if that makes more sense.Alternatively, maybe there is a more direct way to fix the kernel init priority warning, in which case the sensors would get compiled but not have an effect if reporting is disabled.