程式語言 - uC/GUI - Create Timer(Period)



參考資訊:
https://github.com/piyushpandey013/ucGUI
https://github.com/yongzhena/ucgui-linux

main.c

#include <stdio.h>
#include <stdlib.h>
   
#include "GUI.h"
  
static GUI_TIMER_HANDLE hTimer = 0;
 
static void timer_handler(GUI_TIMER_MESSAGE* pTM)
{
    printf("call %s()\n", __func__);
    GUI_TIMER_Restart(hTimer);
}
  
int main(int argc, char *argv[])
{
    GUI_Init();
    GUI_SetBkColor(GUI_GRAY);
    GUI_Clear();
 
    hTimer = GUI_TIMER_Create(timer_handler, 0, 0, 0);
    GUI_TIMER_SetPeriod(hTimer, 1000);
    GUI_TIMER_Restart(hTimer);
    GUI_Delay(3000);
    GUI_TIMER_Delete(hTimer);
    return 0;
}

編譯、執行

$ gcc main.c -o main libucgui.a -IGUI_X -IGUI/Core -IGUI/Widget -IGUI/WM -lSDL
$ ./main
    call timer_handler()
    call timer_handler()
    call timer_handler()