S&B Volcano vaporizer remote control with Pi Pico W
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

state_about.c 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. "\n"
  53. "This program is free software: you can redistribute it and/or modify "
  54. "it under the terms of the GNU General Public License as published by "
  55. "the Free Software Foundation, either version 3 of the License, or "
  56. "(at your option) any later version.\n"
  57. "\n"
  58. "This program is distributed in the hope that it will be useful, "
  59. "but WITHOUT ANY WARRANTY; without even the implied warranty of "
  60. "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
  61. "GNU General Public License for more details.\n"
  62. "\n"
  63. "See <http://www.gnu.org/licenses/>.\n"
  64. ;
  65. static const uint16_t step_size = 10;
  66. static const uint16_t max_height = MENU_BOX_HEIGHT(MENU_MAX_LINES, 20, 2);
  67. static uint16_t off = 0;
  68. static bool held_up = false;
  69. static bool held_down = false;
  70. static int16_t last_draw_off = 0;
  71. static void draw(void) {
  72. int16_t r;
  73. r = text_box(about_text, false,
  74. "DejaVuSerif16",
  75. 0, LCD_WIDTH,
  76. 50, max_height,
  77. -off);
  78. last_draw_off = r;
  79. }
  80. static void about_buttons(enum buttons btn, bool state) {
  81. if (state && (btn == BTN_Y)) {
  82. state_switch(STATE_SCAN);
  83. } else if (btn == BTN_UP) {
  84. held_up = state;
  85. } else if (btn == BTN_DOWN) {
  86. held_down = state;
  87. }
  88. }
  89. void state_about_enter(void) {
  90. buttons_callback(about_buttons);
  91. off = 0;
  92. draw();
  93. }
  94. void state_about_exit(void) {
  95. buttons_callback(NULL);
  96. }
  97. void state_about_run(void) {
  98. if (held_up) {
  99. if (off >= step_size) {
  100. off -= step_size;
  101. draw();
  102. }
  103. }
  104. if (held_down) {
  105. if (last_draw_off >= max_height) {
  106. off += step_size;
  107. draw();
  108. }
  109. }
  110. }