ui.c 864 B

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