/* * Copyright (C) 2023 Daniele Lacamera * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include #ifndef TASK_H_INCLUDED #define TASK_H_INCLUDED #define EV_NONE (0) /* Events are ordered by priority (lower position = higher prio) */ #define EV_BUTTON (1 << 1) #define EV_HEARTBEAT (1 << 3) #define EV_SYSTICK (1 << 5) #define EV_SERIAL (1 << 6) #define EV_VESSELDATA (1 << 7) struct task { void (*init)(void); void (*run)(uint32_t ev, void *arg); uint32_t events; const char *name; struct screen *screen; struct task *next; }; struct screen { struct task *task; void (*draw)(void); void (*refresh)(void); const char *name; int id; struct screen *next; }; void register_task(struct task *t); void register_screen(struct task *t, struct screen *s); void task_add_events(struct task *t, uint32_t ev); void task_del_events(struct task *t, uint32_t ev); void trigger_event(uint32_t ev); struct screen *screen_get_focus(void); struct screen *screens(void); #endif