acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
lv_msg.h (3490B)
1 /** 2 * @file lv_msg.h 3 * 4 */ 5 6 #ifndef LV_MSG_H 7 #define LV_MSG_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 #include "../../../core/lv_obj.h" 17 #if LV_USE_MSG 18 19 /********************* 20 * DEFINES 21 *********************/ 22 23 /********************** 24 * TYPEDEFS 25 **********************/ 26 27 typedef struct { 28 uint32_t id; /*Identifier of the message*/ 29 void * user_data; /*Set the the user_data set in `lv_msg_subscribe`*/ 30 void * _priv_data; /*Used internally*/ 31 const void * payload; /*Pointer to the data of the message*/ 32 } lv_msg_t; 33 34 typedef void (*lv_msg_subscribe_cb_t)(void * s, lv_msg_t * msg); 35 36 typedef void (*lv_msg_request_cb_t)(void * r, uint32_t msg_id); 37 38 /********************** 39 * GLOBAL PROTOTYPES 40 **********************/ 41 42 /** 43 * Called internally to initialize the message module 44 */ 45 void lv_msg_init(void); 46 47 /** 48 * Subscribe to an `msg_id` 49 * @param msg_id the message ID to listen to 50 * @param cb callback to call if a message with `msg_id` was sent 51 * @param user_data arbitrary data which will be available in `cb` too 52 * @return pointer to a "subscribe object". It can be used the unsubscribe. 53 */ 54 void * lv_msg_subsribe(uint32_t msg_id, lv_msg_subscribe_cb_t cb, void * user_data); 55 56 /** 57 * Subscribe an `lv_obj` to a message. 58 * `LV_EVENT_MSG_RECEIVED` will be triggered if a message with matching ID was sent 59 * @param msg_id the message ID to listen to 60 * @param obj pointer to an `lv_obj` 61 * @param user_data arbitrary data which will be available in `cb` too 62 * @return pointer to a "subscribe object". It can be used the unsubscribe. 63 */ 64 void * lv_msg_subsribe_obj(uint32_t msg_id, lv_obj_t * obj, void * user_data); 65 66 /** 67 * Cancel a previous subscription 68 * @param s pointer to a "subscibe object". 69 * Return value of `lv_msg_subsribe` or `lv_msg_subsribe_obj` 70 */ 71 void lv_msg_unsubscribe(void * s); 72 73 /** 74 * Send a message with a given ID and payload 75 * @param msg_id ID of the message to send 76 * @param data pointer to the data to send 77 */ 78 void lv_msg_send(uint32_t msg_id, const void * payload); 79 80 /** 81 * Get the ID of a message object. Typically used in the subscriber callback. 82 * @param m pointer to a message object 83 * @return the ID of the message 84 */ 85 uint32_t lv_msg_get_id(lv_msg_t * m); 86 87 /** 88 * Get the payload of a message object. Typically used in the subscriber callback. 89 * @param m pointer to a message object 90 * @return the payload of the message 91 */ 92 const void * lv_msg_get_payload(lv_msg_t * m); 93 94 /** 95 * Get the user data of a message object. Typically used in the subscriber callback. 96 * @param m pointer to a message object 97 * @return the user data of the message 98 */ 99 void * lv_msg_get_user_data(lv_msg_t * m); 100 101 /** 102 * Get the message object from an event object. Can be used in `LV_EVENT_MSG_RECEIVED` events. 103 * @param e pointer to an event object 104 * @return the message object or NULL if called with unrelated event code. 105 */ 106 lv_msg_t * lv_event_get_msg(lv_event_t * e); 107 108 /********************** 109 * GLOBAL VARIABLES 110 **********************/ 111 112 extern lv_event_code_t LV_EVENT_MSG_RECEIVED; 113 114 /********************** 115 * MACROS 116 **********************/ 117 118 #endif /*LV_USE_MSG*/ 119 120 #ifdef __cplusplus 121 } /*extern "C"*/ 122 #endif 123 124 #endif /*LV_MSG_H*/