S&B Volcano vaporizer remote control with Pi Pico W
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

state_about.c 3.0KB

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