Callbacks
rs_data_info_write_user_callback
Defined in <rs_data_info.h> |
Version |
---|---|
int rs_data_info_write_user_callback (RS_DATA_ID data_id, void *ptr_value); |
Since 3.1 |
This function is the callback routine when data is changing from inside the Sparklet and provides a way to the user to allow/disallow the update. If the function returns 0, the value is allowed to change and if non-zero value is returned, it is not.
PARAMETERS:
data_id |
ID of the Data |
ptr_value |
Pointer to the memory containing the value being updated |
RETURN VALUE:
0 - Allows update
1 - Disallows update
Example:
The below code allows the value change if the uin16_t is in the range 10 to 100 and not otherwise.
1int rs_data_info_write_user_callback(RS_DATA_ID data_id, void* ptr_value)
2{
3 Uint16_t u16_value = *(uint16_t *) ptr_value;
4 if ((u16_value > 10) && (u16_value < 100))
5 return 0;
6 return 1;
7}
rs_user_action_callback
Defined in <rs_data_info.h> |
Version |
---|---|
INT32S rs_user_action_callback(INT32U u32_event, INT32U u32_id, void* ptr_value2, void* ptr_value3) |
Since 3.1 |
This function is the callback routine to handle different types of events from within the Sparklet engine.
PARAMETERS:
u32_event |
Type of the event |
u32_id |
ID of the associated widget. |
ptr_value2 |
Pointer to memory containing relevant information. |
ptr_value3 |
Pointer to memory containing relevant information. |
RETURN VALUE:
0 - Success
The following values are possible in the type along with the given associated information.
Event(u32_event) |
ID(u32_id) |
Argument 1(ptr_value2) |
Argument 2(ptr_value3) |
RS_CALLBACK_EVENT_STATE_CHANGE |
ID of the State machine |
S32_new_state |
S32_old_state |
RS_CALLBACK_BUTTON_ACTION |
Button Widget |
SCALLBACK_EVENT_INFO |
NULL |
RS_CALLBACK_SWIPEBUTTON_ACTION |
Swipe button |
SCALLBACK_EVENT_INFO |
NULL |
RS_CALLBACK_SCROLLBAR_ACTION |
Scrollbar |
s16_cur_pos |
s16_num_pos |
RS_CALLBACK_EFX_ANIM_COMPLETE |
Image Holder |
s16_cur_frame |
NULL |
RS_CALLBACK_CUSTOM_EVENT_HANDLED |
Custom Event ID |
NULL |
NULL |
RS_CALLBACK_SLIDER_ACTION |
Slider Widget |
SCALLBACK_EVENT_INFO |
NULL |
RS_CALLBACK_EFX_ANIM_UPDATED |
Image Holder |
NULL |
NULL |
RS_CALLBACK_DIALOG_ACTION |
Dialog ID |
Action type |
NULL |
The SCALLBACK_EVENT_INFO structure is as follows:
1typedef struct __scallback_event_info
2{
3 uint8_t ub_type; /*! < Type of the event*/
4 uint8_t ub_sub_type; /*! < Subtype of the event*/
5 int16_t s16_pos_x; /*! < Argument/Location of the event*/
6 int16_t s16_pos_y; /*! < Argument/Location of the event*/
7} SCALLBACK_EVENT_INFO;
Example:
The below code prints when a state machine changes
1int rs_user_action_callback(INT32U u32_event, INT32U s32_id, void* ptr_value2, void* ptr_value3)
2{
3 if (u32_event == RS_CALLBACK_EVENT_STATE_CHANGE)
4 {
5 dprintf("Changed state of SM %d from %d to %d\r\n", s32_id, *(INT32S*) ptr_value3, *(INT32S*) ptr_value2);
6 }
7 return 0;
8}
sgui_app_report_error
Defined in <sgui_errors.h> |
Version |
---|---|
int sgui_app_report_error (int error_code, int sub_code, void *ptr_extra_info); |
Since 3.1 |
This function is the error callback routine called at different error scenarios.
PARAMETERS:
error_code |
Error code |
sub_code |
Error sub code |
ptr_extra_info |
Error description |
ERROR CODE: For more information, refer to the Error Codes page.
Example:
The below code prints the error code on occurrence of error.
1int sgui_app_report_error (int error_code, int sub_code, void *ptr_extra_info)
2{
3 printf ("Sparklet error %d occurred\r\n", error_code);
4}
sgui_cb_is_point_for_touch
Defined in <rs_data_info.h> |
Version |
---|---|
sgui_cb_is_point_for_touch(INT16U uw_id, INT16S s16_x, INT16S s16_y); |
Since 3.1 |
This function is the callback routine for all touch callbacks for each widget. If the function returns 0, the touch action is discarded.
PARAMETERS:
uw_id |
ID of the widget |
s16_x |
X Coordinate within the widget |
s16_y |
Y Coordinate within the widget |
RETURN VALUE:
0 - Success
Example:
The below code accepts touch event only with a small vertical band starting from x location 10 and 30.
1int sgui_cb_is_point_for_touch(INT16U uw_id, INT16S s16_x, INT16S s16_y)
2{
3 if ((x > 10) && (x < 30))
4 return 1;
5 return 0;
6}
scb_debug_out
Defined in <sparklet_api.h> |
Version |
---|---|
void scb_debug_out (char *ptr_dbg_text); |
Since 3.3.3 |
This function is the callback routine that is invoked when a debug information is to be printed out on the console.
For more information visit Support for debugging.
PARAMETERS:
ptr_dbg_text |
Text containing the debug information |
RETURN VALUE:
None
Example:
The below code prints out the incoming text over console.
1void scb_debug_out (char *ptr_dbg_text)
2{
3 printf (ptr_dbg_text);
4}