My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

developer_menu.cpp 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /**********************
  2. * developer_menu.cpp *
  3. **********************/
  4. /****************************************************************************
  5. * Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
  6. * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
  7. * *
  8. * This program is free software: you can redistribute it and/or modify *
  9. * it under the terms of the GNU General Public License as published by *
  10. * the Free Software Foundation, either version 3 of the License, or *
  11. * (at your option) any later version. *
  12. * *
  13. * This program is distributed in the hope that it will be useful, *
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  16. * GNU General Public License for more details. *
  17. * *
  18. * To view a copy of the GNU General Public License, go to the following *
  19. * location: <http://www.gnu.org/licenses/>. *
  20. ****************************************************************************/
  21. #include "../config.h"
  22. #if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_DEVELOPER_MENU)
  23. #include "screens.h"
  24. #include "../archim2-flash/flash_storage.h"
  25. using namespace FTDI;
  26. using namespace Theme;
  27. void DeveloperMenu::onRedraw(draw_mode_t what) {
  28. if (what & BACKGROUND) {
  29. CommandProcessor cmd;
  30. cmd.cmd(CLEAR_COLOR_RGB(bg_color))
  31. .cmd(CLEAR(true,true,true))
  32. .font(font_medium)
  33. .tag(0);
  34. #ifdef SPI_FLASH_SS
  35. constexpr bool has_flash = true;
  36. #else
  37. constexpr bool has_flash = false;
  38. #endif
  39. #if ENABLED(SDSUPPORT)
  40. constexpr bool has_media = true;
  41. #else
  42. constexpr bool has_media = false;
  43. #endif
  44. cmd.cmd(COLOR_RGB(bg_text_enabled));
  45. #ifdef TOUCH_UI_PORTRAIT
  46. #define GRID_ROWS 10
  47. #define GRID_COLS 1
  48. cmd.font(font_large) .text ( BTN_POS(1,1), BTN_SIZE(1,1), F("Developer Menu"))
  49. .colors(normal_btn)
  50. .tag(2).font(font_medium) .button( BTN_POS(1,2), BTN_SIZE(1,1), F("Show All Widgets"))
  51. .tag(3) .button( BTN_POS(1,3), BTN_SIZE(1,1), F("Stress Test"))
  52. .tag(4) .button( BTN_POS(1,4), BTN_SIZE(1,1), F("Show Touch Registers"))
  53. .tag(5) .button( BTN_POS(1,5), BTN_SIZE(1,1), F("Play Song"))
  54. .tag(6).enabled(has_media).button( BTN_POS(1,6), BTN_SIZE(1,1), F("Play Video from Media"))
  55. .tag(7).enabled(has_flash).button( BTN_POS(1,7), BTN_SIZE(1,1), F("Play Video from SPI Flash"))
  56. .tag(8).enabled(has_flash).button( BTN_POS(1,8), BTN_SIZE(1,1), F("Load Video to SPI Flash"))
  57. .tag(9).enabled(has_flash).button( BTN_POS(1,9), BTN_SIZE(1,1), F("Erase SPI Flash"))
  58. .tag(1).colors(action_btn)
  59. .button( BTN_POS(1,10), BTN_SIZE(1,1), F("Back"));
  60. #else
  61. #define GRID_ROWS 6
  62. #define GRID_COLS 2
  63. cmd.font(font_medium) .text ( BTN_POS(1,1), BTN_SIZE(2,1), F("Developer Menu"))
  64. .colors(normal_btn)
  65. .tag(2).font(font_small) .button( BTN_POS(1,2), BTN_SIZE(1,1), F("Show All Widgets"))
  66. .tag(3) .button( BTN_POS(1,3), BTN_SIZE(1,1), F("Show Touch Registers"))
  67. .tag(9) .button( BTN_POS(1,4), BTN_SIZE(1,1), F("Show Pin States"))
  68. .tag(4) .button( BTN_POS(1,5), BTN_SIZE(1,1), F("Play Song"))
  69. .tag(5).enabled(has_media).button( BTN_POS(2,2), BTN_SIZE(1,1), F("Play Video from Media"))
  70. .tag(6).enabled(has_flash).button( BTN_POS(2,3), BTN_SIZE(1,1), F("Play Video from SPI Flash"))
  71. .tag(7).enabled(has_flash).button( BTN_POS(2,4), BTN_SIZE(1,1), F("Load Video to SPI Flash"))
  72. .tag(8).enabled(has_flash).button( BTN_POS(2,5), BTN_SIZE(1,1), F("Erase SPI Flash"))
  73. .tag(1).colors(action_btn)
  74. .button( BTN_POS(1,6), BTN_SIZE(2,1), F("Back"));
  75. #endif
  76. }
  77. }
  78. bool DeveloperMenu::onTouchEnd(uint8_t tag) {
  79. using namespace Theme;
  80. switch (tag) {
  81. case 1: GOTO_PREVIOUS(); break;
  82. case 2: GOTO_SCREEN(WidgetsScreen); break;
  83. case 3:
  84. PUSH_SCREEN(StressTestScreen);
  85. AlertDialogBox::show(F("Please do not run this test unattended as it may cause your printer to malfunction."));
  86. current_screen.forget();
  87. break;
  88. case 4: GOTO_SCREEN(TouchRegistersScreen); break;
  89. case 5: sound.play(js_bach_joy, PLAY_ASYNCHRONOUS); break;
  90. #if ENABLED(SDSUPPORT)
  91. case 6:
  92. if (!MediaPlayerScreen::playCardMedia())
  93. AlertDialogBox::showError(F("Cannot open STARTUP.AVI"));
  94. break;
  95. #endif
  96. #ifdef SPI_FLASH_SS
  97. case 7:
  98. if (!MediaPlayerScreen::playBootMedia())
  99. AlertDialogBox::showError(F("No boot media available"));
  100. break;
  101. case 8:
  102. {
  103. SpinnerDialogBox::show(F("Saving..."));
  104. UIFlashStorage::error_t res = UIFlashStorage::write_media_file(F("STARTUP.AVI"));
  105. SpinnerDialogBox::hide();
  106. reset_menu_timeout();
  107. switch (res) {
  108. case UIFlashStorage::SUCCESS:
  109. AlertDialogBox::show(F("File copied!"));
  110. break;
  111. case UIFlashStorage::READ_ERROR:
  112. AlertDialogBox::showError(F("Failed to read file"));
  113. break;
  114. case UIFlashStorage::VERIFY_ERROR:
  115. AlertDialogBox::showError(F("Failed to verify file"));
  116. break;
  117. case UIFlashStorage::FILE_NOT_FOUND:
  118. AlertDialogBox::showError(F("Cannot open STARTUP.AVI"));
  119. break;
  120. case UIFlashStorage::WOULD_OVERWRITE:
  121. AlertDialogBox::showError(F("Cannot overwrite existing media."));
  122. break;
  123. }
  124. break;
  125. }
  126. case 9: GOTO_SCREEN(ConfirmEraseFlashDialogBox); break;
  127. #endif
  128. case 10: GOTO_SCREEN(EndstopStatesScreen); break;
  129. default: return false;
  130. }
  131. return true;
  132. }
  133. #endif // TOUCH_UI_FTDI_EVE