underglow-layer: track layer changes with event & battery life optimization
I tried using event instead of the 25ms underglow_tick to update the underglow on layer change only. That didn't improve the battery life much.... The second change is cutting off the led strip power if the underglow is not defined for a layer. Power is restored if a layer with rgb is activated, and cut off as soon as the layer is disabled. This, on the other hand, improves the battery life a lot, especially if you don't use rgb on your base layer. If you are using rgb on your base layer, setting CONFIG_ZMK_RGB_UNDERGLOW_AUTO_OFF_IDLE is highly recommended.
This commit is contained in:
parent
6f9a411793
commit
0ca086a845
8 changed files with 61 additions and 16 deletions
|
|
@ -35,6 +35,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
|||
|
||||
#include <zmk/events/sensor_event.h>
|
||||
#include <zmk/sensors.h>
|
||||
#include <zmk/events/split_peripheral_layer_changed.h>
|
||||
|
||||
#if ZMK_KEYMAP_HAS_SENSORS
|
||||
static struct sensor_event last_sensor_event;
|
||||
|
|
@ -144,7 +145,9 @@ static uint32_t layers = 0;
|
|||
|
||||
static void split_svc_update_layers_callback(struct k_work *work) {
|
||||
LOG_DBG("Setting peripheral layers: %x", layers);
|
||||
set_peripheral_layers_state(layers);
|
||||
// set_peripheral_layers_state(layers);
|
||||
raise_zmk_split_peripheral_layer_changed(
|
||||
(struct zmk_split_peripheral_layer_changed){.layers = layers});
|
||||
}
|
||||
|
||||
static K_WORK_DEFINE(split_svc_update_layers_work, split_svc_update_layers_callback);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue