ui.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #include "ui.h"
  2. #include "lcd.h"
  3. #include "key.h"
  4. #include "beep.h"
  5. #include "thread.h"
  6. #if 1
  7. #define LOGD log_d
  8. #define LOGE log_e
  9. #else
  10. #define LOGD printf
  11. #define LOGE printf
  12. #endif
  13. typedef struct {
  14. int fd;
  15. }ui_handle_t;
  16. static ui_handle_t uiHandle={0};
  17. static int menu_init(ui_handle_t *h)
  18. {
  19. //key_init(h);
  20. lcd_init(LCD_WIDTH,LCD_HEIGHT,LCD_COLOR);
  21. lcd_fill(0);
  22. //lcd_draw_string(10, 10, 80, 30, "Smart 123456789", FONT_08, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
  23. lcd_draw_string(10, 10, 80, 30, "输出: 12.0V", FONT_12, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
  24. //lcd_draw_string(10, 40, 80, 30, "输出入通道: 12.0V", FONT_16, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
  25. //lcd_draw_string(10, 30, 80, 30, "Voltage: 22.4V", FONT_12, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
  26. lcd_refresh();
  27. return 0;
  28. }
  29. static int menu_deinit(ui_handle_t *h)
  30. {
  31. //key_deinit(h);
  32. lcd_deinit();
  33. return 0;
  34. }
  35. static int menu_handle(ui_handle_t *h)
  36. {
  37. int r;
  38. //r = key_get(h, &kd);
  39. if(r==0) {
  40. //switch(kd.key) {
  41. // case KEY_LEFT:
  42. // break;
  43. //}
  44. }
  45. return 0;
  46. }
  47. static void *ui_thread(void *arg)
  48. {
  49. int r;
  50. thread_handle_t *th=(thread_handle_t*)arg;
  51. ui_handle_t *h=(ui_handle_t*)th->arg;
  52. menu_init(h);
  53. while(th->quit==0) {
  54. menu_handle(h);
  55. }
  56. menu_deinit(h);
  57. pthread_exit(NULL);
  58. }
  59. /////////////////////////////////////////////////////
  60. int ui_init(void)
  61. {
  62. ui_handle_t *h=&uiHandle;
  63. thread_start(THREAD_ID_UI, ui_thread, h);
  64. return 0;
  65. }