add generic callback signaler
This commit is contained in:
parent
85dc35dcc2
commit
d4f0a3b90f
3 changed files with 32 additions and 0 deletions
14
include/cfglr_signaler_callback.h
Normal file
14
include/cfglr_signaler_callback.h
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
typedef void (*cfglr_callback_t)(cfglr_signaler_t *signaler, cfglr_element_t *element, cfglr_signal_e sig);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
cfglr_callback_t callback;
|
||||||
|
} cfglr_callback_handle_t;
|
||||||
|
|
||||||
|
void cfglr_signaler_callback_init(cfglr_signaler_t *signaler, cfglr_element_t *element, cfglr_handle_t *handle);
|
||||||
|
void cfglr_signaler_callback_dispatch(cfglr_signaler_t *signaler, cfglr_element_t *element, cfglr_signal_e sig);
|
||||||
|
|
||||||
|
#define CFGLR_SIGNALER_CALLBACK(FN_CALLBACK) (cfglr_signaler_t){\
|
||||||
|
.init = &cfglr_signaler_callback_init,\
|
||||||
|
.dispatch = &cfglr_signaler_callback_dispatch,\
|
||||||
|
.handle = (void*)FN_CALLBACK\
|
||||||
|
}
|
|
@ -115,7 +115,9 @@ struct cfglr_handle_struct {
|
||||||
uint8_t cfglr_init(cfglr_handle_t *handle);
|
uint8_t cfglr_init(cfglr_handle_t *handle);
|
||||||
uint8_t cfglr_fetch_data(cfglr_backend_t *backend, cfglr_element_t *element, cfglr_handle_t *handler);
|
uint8_t cfglr_fetch_data(cfglr_backend_t *backend, cfglr_element_t *element, cfglr_handle_t *handler);
|
||||||
|
|
||||||
|
#include "cfglr_log.h"
|
||||||
#include "cfglr_nvs.h"
|
#include "cfglr_nvs.h"
|
||||||
|
#include "cfglr_signaler_callback.h"
|
||||||
#include "cfglr_signaler_idf_event.h"
|
#include "cfglr_signaler_idf_event.h"
|
||||||
#include "cfglr_signaler_lvgl.h"
|
#include "cfglr_signaler_lvgl.h"
|
||||||
|
|
||||||
|
|
16
src/cfglr_signal_callback.c
Normal file
16
src/cfglr_signal_callback.c
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#include "configulator.h"
|
||||||
|
|
||||||
|
#define TAG "CFGLR_SIG_CB"
|
||||||
|
|
||||||
|
void cfglr_signaler_callback_init(cfglr_signaler_t *signaler, cfglr_element_t *element, cfglr_handle_t *handle) {
|
||||||
|
CFGLR_LOGI(TAG, "init");
|
||||||
|
}
|
||||||
|
|
||||||
|
void cfglr_signaler_callback_dispatch(cfglr_signaler_t *signaler, cfglr_element_t *element, cfglr_signal_e sig) {
|
||||||
|
CFGLR_LOGI(TAG, "dispatch");
|
||||||
|
|
||||||
|
if(signaler->handle != NULL) {
|
||||||
|
cfglr_callback_t callback = signaler->handle;
|
||||||
|
callback(signaler, element, sig);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue