samples: subsys: display: lvgl: add option to control sw0

Add a new option to control the behavior of sw0. This option also allows
to select GPIO when needed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2024-12-17 10:37:22 +01:00 committed by Benjamin Cabé
parent 75154a6443
commit cf4fb7a560
2 changed files with 16 additions and 4 deletions

View file

@ -0,0 +1,12 @@
# Copyright (c) 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
source "Kconfig.zephyr"
mainmenu "LVGL Sample"
config RESET_COUNTER_SW0
bool "Reset counter when sw0 is pressed"
depends on $(dt_alias_enabled,sw0)
select GPIO
default y

View file

@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(app);
static uint32_t count;
#ifdef CONFIG_GPIO
#ifdef CONFIG_RESET_COUNTER_SW0
static struct gpio_dt_spec button_gpio = GPIO_DT_SPEC_GET_OR(
DT_ALIAS(sw0), gpios, {0});
static struct gpio_callback button_callback;
@ -35,7 +35,7 @@ static void button_isr_callback(const struct device *port,
count = 0;
}
#endif /* CONFIG_GPIO */
#endif /* CONFIG_RESET_COUNTER_SW0 */
#ifdef CONFIG_LV_Z_ENCODER_INPUT
static const struct device *lvgl_encoder =
@ -67,7 +67,7 @@ int main(void)
return 0;
}
#ifdef CONFIG_GPIO
#ifdef CONFIG_RESET_COUNTER_SW0
if (gpio_is_ready_dt(&button_gpio)) {
int err;
@ -93,7 +93,7 @@ int main(void)
return 0;
}
}
#endif /* CONFIG_GPIO */
#endif /* CONFIG_RESET_COUNTER_SW0 */
#ifdef CONFIG_LV_Z_ENCODER_INPUT
lv_obj_t *arc;