S&B Volcano vaporizer remote control with Pi Pico W
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

state_about.c 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * state_about.c
  3. *
  4. * Copyright (c) 2023 Thomas Buck (thomas@xythobuz.de)
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * See <http://www.gnu.org/licenses/>.
  17. */
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include "config.h"
  21. #include "buttons.h"
  22. #include "log.h"
  23. #include "lcd.h"
  24. #include "text.h"
  25. #include "textbox.h"
  26. #include "menu.h"
  27. #include "state.h"
  28. #include "state_about.h"
  29. #define xstr(s) str(s)
  30. #define str(s) #s
  31. static const char *about_text =
  32. "Volcano RC Gadget\n"
  33. "by xythobuz\n"
  34. "Licensed as GPLv3\n"
  35. "\n"
  36. "V" xstr(APP_VERSION_MAJOR) "." xstr(APP_VERSION_MINOR) "\n"
  37. #ifdef NDEBUG
  38. "Release Build\n"
  39. #else // NDEBUG
  40. "Debug Build\n"
  41. #endif // NDEBUG
  42. __DATE__ " " __TIME__ "\n"
  43. "\n"
  44. "Included libs:\n"
  45. "hathach/tinyusb\n"
  46. "abbrev/fatfs\n"
  47. "bluekitchen/btstack\n"
  48. "mcufont/mcufont\n"
  49. "hepingood/st7789\n"
  50. "usedbytes/picowota\n"
  51. "lwip-tcpip/lwip\n"
  52. "micropython/dhcpserver\n"
  53. "\n"
  54. "This program is free software: you can redistribute it and/or modify "
  55. "it under the terms of the GNU General Public License as published by "
  56. "the Free Software Foundation, either version 3 of the License, or "
  57. "(at your option) any later version.\n"
  58. "\n"
  59. "This program is distributed in the hope that it will be useful, "
  60. "but WITHOUT ANY WARRANTY; without even the implied warranty of "
  61. "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
  62. "GNU General Public License for more details.\n"
  63. "\n"
  64. "See <http://www.gnu.org/licenses/>.\n"
  65. ;
  66. static const uint16_t step_size = 10;
  67. static const uint16_t max_height = MENU_BOX_HEIGHT(MENU_MAX_LINES, 20, 2);
  68. static uint16_t off = 0;
  69. static bool held_up = false;
  70. static bool held_down = false;
  71. static int16_t last_draw_off = 0;
  72. static void draw(void) {
  73. int16_t r;
  74. r = text_box(about_text, false,
  75. "DejaVuSerif16",
  76. 0, LCD_WIDTH,
  77. 50, max_height,
  78. -off);
  79. last_draw_off = r;
  80. }
  81. static void about_buttons(enum buttons btn, bool state) {
  82. if (state && (btn == BTN_Y)) {
  83. state_switch(STATE_SCAN);
  84. } else if (btn == BTN_UP) {
  85. held_up = state;
  86. } else if (btn == BTN_DOWN) {
  87. held_down = state;
  88. }
  89. }
  90. void state_about_enter(void) {
  91. buttons_callback(about_buttons);
  92. off = 0;
  93. draw();
  94. }
  95. void state_about_exit(void) {
  96. buttons_callback(NULL);
  97. }
  98. void state_about_run(void) {
  99. if (held_up) {
  100. if (off >= step_size) {
  101. off -= step_size;
  102. draw();
  103. }
  104. }
  105. if (held_down) {
  106. if (last_draw_off >= max_height) {
  107. off += step_size;
  108. draw();
  109. }
  110. }
  111. }