Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

78 строки
2.0 KiB

  1. #include "core/common.h"
  2. #include "core/buttons.h"
  3. #include "core/display.h"
  4. #include <EPD.h>
  5. #include "ModeRunner.h"
  6. #include "ReaderMode.h"
  7. #include "MainMenuMode.h"
  8. static int baseY = 35;
  9. static int menuSkip = 20;
  10. static int x = 40;
  11. static int menu_options_size = 4;
  12. void draw_menu_option(char* text, int line, bool selected)
  13. {
  14. EPD_print(text, CENTER, baseY + line * menuSkip);
  15. }
  16. void draw_menu_cursor(int cursor)
  17. {
  18. EPD_drawRect(x, baseY + cursor * menuSkip,
  19. EPD_DISPLAY_WIDTH - 2*x, menuSkip + 1, 0x0F);
  20. }
  21. void MainMenuMode::start()
  22. {
  23. display_refresh();
  24. }
  25. void MainMenuMode::loop()
  26. {
  27. display_clear();
  28. EPD_setFont(COMIC24_FONT, NULL);
  29. EPD_print("Main Menu", CENTER, 0);
  30. int line = 0;
  31. EPD_setFont(DEJAVU18_FONT, NULL);
  32. draw_menu_option("Continue Reading", line, this->cursor == line); line++;
  33. draw_menu_option("Internal Memory", line, this->cursor == line); line++;
  34. draw_menu_option("SD Card", line, this->cursor == line); line++;
  35. draw_menu_option("Settings", line, this->cursor == line); line++;
  36. draw_menu_cursor(this->cursor);
  37. display_update();
  38. while(1) {
  39. delay(5);
  40. if (buttons_pressed_ok()) {
  41. switch (this->cursor) {
  42. case 0: // reading
  43. display_refresh();
  44. getModeRunner()->startInnerMode(new ReaderMode());
  45. return;
  46. case 1: // memory
  47. // TODO
  48. break;
  49. case 2: // sd card
  50. // TODO
  51. break;
  52. case 3: // settings
  53. // TODO
  54. break;
  55. }
  56. break;
  57. }
  58. if (buttons_pressed_minus()) {
  59. this->cursor = (this->cursor + menu_options_size - 1) % menu_options_size;
  60. break;
  61. }
  62. if (buttons_pressed_plus()) {
  63. this->cursor = (this->cursor + 1) % menu_options_size;
  64. break;
  65. }
  66. }
  67. }
  68. void MainMenuMode::finish()
  69. {}