samples: mesh_badge: conversion of k_work API
Replace all existing deprecated API with the recommended alternative. Be aware that this does not address architectural errors in the use of the work API. Fixes #34097 Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no> Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
parent
1787644930
commit
20f502288a
2 changed files with 18 additions and 18 deletions
|
@ -84,7 +84,7 @@ int get_apds9960_val(struct sensor_value *val)
|
||||||
|
|
||||||
#define MOTION_TIMEOUT K_MINUTES(30)
|
#define MOTION_TIMEOUT K_MINUTES(30)
|
||||||
|
|
||||||
static struct k_delayed_work motion_work;
|
static struct k_work_delayable motion_work;
|
||||||
|
|
||||||
static void motion_timeout(struct k_work *work)
|
static void motion_timeout(struct k_work *work)
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,7 @@ static void motion_timeout(struct k_work *work)
|
||||||
printk("power save\n");
|
printk("power save\n");
|
||||||
|
|
||||||
if (!mesh_is_initialized()) {
|
if (!mesh_is_initialized()) {
|
||||||
k_delayed_work_submit(&motion_work, MOTION_TIMEOUT);
|
k_work_schedule(&motion_work, MOTION_TIMEOUT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ static void motion_handler(const struct device *dev,
|
||||||
printk("failed to resume mesh (err %d)\n", err);
|
printk("failed to resume mesh (err %d)\n", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
k_delayed_work_submit(&motion_work, MOTION_TIMEOUT);
|
k_work_reschedule(&motion_work, MOTION_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void configure_accel(void)
|
static void configure_accel(void)
|
||||||
|
@ -138,8 +138,8 @@ static void configure_accel(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
k_delayed_work_init(&motion_work, motion_timeout);
|
k_work_init_delayable(&motion_work, motion_timeout);
|
||||||
k_delayed_work_submit(&motion_work, MOTION_TIMEOUT);
|
k_work_schedule(&motion_work, MOTION_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
int periphs_init(void)
|
int periphs_init(void)
|
||||||
|
|
|
@ -52,8 +52,8 @@ static const struct device *epd_dev;
|
||||||
static bool pressed;
|
static bool pressed;
|
||||||
static uint8_t screen_id = SCREEN_MAIN;
|
static uint8_t screen_id = SCREEN_MAIN;
|
||||||
static const struct device *gpio;
|
static const struct device *gpio;
|
||||||
static struct k_delayed_work epd_work;
|
static struct k_work_delayable epd_work;
|
||||||
static struct k_delayed_work long_press_work;
|
static struct k_work_delayable long_press_work;
|
||||||
static char str_buf[256];
|
static char str_buf[256];
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
@ -73,7 +73,7 @@ static struct {
|
||||||
.flags = DT_GPIO_FLAGS(DT_ALIAS(led2), gpios)}
|
.flags = DT_GPIO_FLAGS(DT_ALIAS(led2), gpios)}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct k_delayed_work led_timer;
|
struct k_work_delayable led_timer;
|
||||||
|
|
||||||
static size_t print_line(enum font_size font_size, int row, const char *text,
|
static size_t print_line(enum font_size font_size, int row, const char *text,
|
||||||
size_t len, bool center)
|
size_t len, bool center)
|
||||||
|
@ -133,7 +133,7 @@ static size_t get_len(enum font_size font, const char *text)
|
||||||
|
|
||||||
void board_blink_leds(void)
|
void board_blink_leds(void)
|
||||||
{
|
{
|
||||||
k_delayed_work_submit(&led_timer, K_MSEC(100));
|
k_work_reschedule(&led_timer, K_MSEC(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_show_text(const char *text, bool center, k_timeout_t duration)
|
void board_show_text(const char *text, bool center, k_timeout_t duration)
|
||||||
|
@ -163,7 +163,7 @@ void board_show_text(const char *text, bool center, k_timeout_t duration)
|
||||||
cfb_framebuffer_finalize(epd_dev);
|
cfb_framebuffer_finalize(epd_dev);
|
||||||
|
|
||||||
if (!K_TIMEOUT_EQ(duration, K_FOREVER)) {
|
if (!K_TIMEOUT_EQ(duration, K_FOREVER)) {
|
||||||
k_delayed_work_submit(&epd_work, duration);
|
k_work_reschedule(&epd_work, duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ static void show_sensors_data(k_timeout_t interval)
|
||||||
|
|
||||||
cfb_framebuffer_finalize(epd_dev);
|
cfb_framebuffer_finalize(epd_dev);
|
||||||
|
|
||||||
k_delayed_work_submit(&epd_work, interval);
|
k_work_reschedule(&epd_work, interval);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -459,11 +459,11 @@ static void button_interrupt(const struct device *dev,
|
||||||
printk("Button %s\n", pressed ? "pressed" : "released");
|
printk("Button %s\n", pressed ? "pressed" : "released");
|
||||||
|
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
k_delayed_work_submit(&long_press_work, LONG_PRESS_TIMEOUT);
|
k_work_reschedule(&long_press_work, LONG_PRESS_TIMEOUT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_delayed_work_cancel(&long_press_work);
|
k_work_cancel_delayable(&long_press_work);
|
||||||
|
|
||||||
if (!mesh_is_initialized()) {
|
if (!mesh_is_initialized()) {
|
||||||
return;
|
return;
|
||||||
|
@ -552,7 +552,7 @@ static void led_timeout(struct k_work *work)
|
||||||
i = led_cntr++ % ARRAY_SIZE(leds);
|
i = led_cntr++ % ARRAY_SIZE(leds);
|
||||||
set_led_state(i, 1);
|
set_led_state(i, 1);
|
||||||
|
|
||||||
k_delayed_work_submit(&led_timer, K_MSEC(100));
|
k_work_reschedule(&led_timer, K_MSEC(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int configure_leds(void)
|
static int configure_leds(void)
|
||||||
|
@ -571,7 +571,7 @@ static int configure_leds(void)
|
||||||
GPIO_OUTPUT_INACTIVE);
|
GPIO_OUTPUT_INACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
k_delayed_work_init(&led_timer, led_timeout);
|
k_work_init_delayable(&led_timer, led_timeout);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,7 +587,7 @@ static int erase_storage(void)
|
||||||
|
|
||||||
void board_refresh_display(void)
|
void board_refresh_display(void)
|
||||||
{
|
{
|
||||||
k_delayed_work_submit(&epd_work, K_NO_WAIT);
|
k_work_reschedule(&epd_work, K_NO_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
int board_init(void)
|
int board_init(void)
|
||||||
|
@ -615,8 +615,8 @@ int board_init(void)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_delayed_work_init(&epd_work, epd_update);
|
k_work_init_delayable(&epd_work, epd_update);
|
||||||
k_delayed_work_init(&long_press_work, long_press);
|
k_work_init_delayable(&long_press_work, long_press);
|
||||||
|
|
||||||
pressed = button_is_pressed();
|
pressed = button_is_pressed();
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue