ui.c 943 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "ui.h"
  2. #include <unistd.h>
  3. #include <stdlib.h>
  4. #include "menu.h"
  5. #include "thread.h"
  6. #include "cfg.h"
  7. #if 1
  8. #define LOGD log_d
  9. #define LOGE log_e
  10. #else
  11. #define LOGD printf
  12. #define LOGE printf
  13. #endif
  14. typedef struct {
  15. int fd;
  16. }ui_handle_t;
  17. static ui_handle_t uiHandle={0};
  18. static void msleep(int ms)
  19. {
  20. usleep(ms*1000);
  21. }
  22. static void *ui_thread(void *arg)
  23. {
  24. int r;
  25. thread_handle_t *th=(thread_handle_t*)arg;
  26. ui_handle_t *h=(ui_handle_t*)th->arg;
  27. menu_init();
  28. while(th->quit==0) {
  29. menu_handle();
  30. msleep(50);
  31. }
  32. menu_deinit();
  33. pthread_exit(NULL);
  34. }
  35. /////////////////////////////////////////////////////
  36. static void rm_qt(void)
  37. {
  38. system("killall Qt_Test; rm /root/run/app/Qt_Test");
  39. }
  40. int ui_init(void)
  41. {
  42. ui_handle_t *h=&uiHandle;
  43. #ifdef USE_UI
  44. //rm_qt();
  45. thread_start(THREAD_ID_UI, ui_thread, h);
  46. #endif
  47. return 0;
  48. }