Running Sparklet over RTOS

In case an RTOS is used, create a high priority task for Sparklet with required stack size. Running it at high priority will keep the UI responsive. For example in FreeRTOS, a task for Sparklet with the given stack size and priority can be created similar to the following example snippet:

 1#define SPARKLET_TASK_STACK_SIZE  (92 * 1024)
 2#define SPARKLET_TASK_PRIORITY   4
 3TaskHandle_t sparklet_task_handle;
 4xTaskCreate((TaskFunction_t)sparklet_task,                   /* pointer to the task  */
 5(char const *)"sparklet_task",                               /* task name for kernel awareness debugging */
 6SPARKLET_TASK_STACK_SIZE / sizeof(portSTACK_TYPE),   /* task stack size   */
 7NULL,                        /* optional task startup argument  */
 8SPARKLET_TASK_PRIORITY,              /* initial priority   */
 9&sparklet_task_handle                /* optional task handle to create   */
10);

The function sparklet_task() should include all core APIs and the following is an example snippet

 1void sparklet_task ()
 2{
 3  sgui_rh850_mem_init( (uint32_t)loc_LocalHeap, LOCAL_NUM_BLOCKS, LOCAL_BLOCK_SIZE, \
 4  VRAM_BASE, VRAM_NUM_BLOCKS, VRAM_BLOCK_SIZE, \
 5  SDRAM_BASE, SDRAM_NUM_BLOCKS, SDRAM_BLOCK_SIZE, \
 6  CAMERA_BASE, CAMERA_BLOCK_SIZE, CAPTURE_BUF);
 7  //Initialize the SGUI
 8  shal_init_signal();
 9  sgui_init ();
10  sgui_event_manager_init ();
11  rs_exec_init ();
12  sgui_screens_init ();
13  sgui_sparklet_enable(1);
14  while (1)
15    {
16      sgui_process ();
17      rs_exec_process();
18    }
19}