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.

screens.h 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. /*************
  2. * screens.h *
  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. #pragma once
  22. #include "../ftdi_eve_lib/ftdi_eve_lib.h"
  23. #include "../language/language.h"
  24. #include "../theme/theme.h"
  25. #include "string_format.h"
  26. extern tiny_timer_t refresh_timer;
  27. /********************************* DL CACHE SLOTS ******************************/
  28. // In order to reduce SPI traffic, we cache display lists (DL) in RAMG. This
  29. // is done using the CLCD::DLCache class, which takes a unique ID for each
  30. // cache location. These IDs are defined here:
  31. enum {
  32. STATUS_SCREEN_CACHE,
  33. MENU_SCREEN_CACHE,
  34. TUNE_SCREEN_CACHE,
  35. ADJUST_OFFSETS_SCREEN_CACHE,
  36. ALERT_BOX_CACHE,
  37. SPINNER_CACHE,
  38. ADVANCED_SETTINGS_SCREEN_CACHE,
  39. MOVE_AXIS_SCREEN_CACHE,
  40. TEMPERATURE_SCREEN_CACHE,
  41. STEPS_SCREEN_CACHE,
  42. STEPPER_CURRENT_SCREEN_CACHE,
  43. STEPPER_BUMP_SENSITIVITY_SCREEN_CACHE,
  44. ZOFFSET_SCREEN_CACHE,
  45. NOZZLE_OFFSET_SCREEN_CACHE,
  46. BACKLASH_COMPENSATION_SCREEN_CACHE,
  47. MAX_FEEDRATE_SCREEN_CACHE,
  48. MAX_VELOCITY_SCREEN_CACHE,
  49. MAX_ACCELERATION_SCREEN_CACHE,
  50. DEFAULT_ACCELERATION_SCREEN_CACHE,
  51. #if DISABLED(CLASSIC_JERK)
  52. JUNC_DEV_SCREEN_CACHE,
  53. #else
  54. JERK_SCREEN_CACHE,
  55. #endif
  56. #if EITHER(LIN_ADVANCE, FILAMENT_RUNOUT_SENSOR)
  57. FILAMENT_MENU_CACHE,
  58. #endif
  59. #if ENABLED(LIN_ADVANCE)
  60. LINEAR_ADVANCE_SCREEN_CACHE,
  61. #endif
  62. #if ENABLED(FILAMENT_RUNOUT_SENSOR)
  63. FILAMENT_RUNOUT_SCREEN_CACHE,
  64. #endif
  65. #ifdef LULZBOT_USE_BIOPRINTER_UI
  66. PRINTING_SCREEN_CACHE,
  67. #endif
  68. CHANGE_FILAMENT_SCREEN_CACHE,
  69. INTERFACE_SETTINGS_SCREEN_CACHE,
  70. INTERFACE_SOUNDS_SCREEN_CACHE,
  71. LOCK_SCREEN_CACHE,
  72. FILES_SCREEN_CACHE,
  73. DISPLAY_TIMINGS_SCREEN_CACHE
  74. };
  75. // To save MCU RAM, the status message is "baked" in to the status screen
  76. // cache, so we reserve a large chunk of memory for the DL cache
  77. #define STATUS_SCREEN_DL_SIZE 2048
  78. #define ALERT_BOX_DL_SIZE 3072
  79. #define SPINNER_DL_SIZE 3072
  80. #define FILE_SCREEN_DL_SIZE 3072
  81. #define PRINTING_SCREEN_DL_SIZE 2048
  82. /************************* MENU SCREEN DECLARATIONS *************************/
  83. class BaseScreen : public UIScreen {
  84. protected:
  85. #ifdef LCD_TIMEOUT_TO_STATUS
  86. static uint32_t last_interaction;
  87. #endif
  88. static bool buttonIsPressed(uint8_t tag);
  89. public:
  90. static bool buttonStyleCallback(CommandProcessor &, uint8_t, uint8_t &, uint16_t &, bool);
  91. static void reset_menu_timeout();
  92. static void onEntry();
  93. static void onIdle();
  94. };
  95. class BootScreen : public BaseScreen, public UncachedScreen {
  96. private:
  97. static void showSplashScreen();
  98. public:
  99. static void onRedraw(draw_mode_t);
  100. static void onIdle();
  101. };
  102. class AboutScreen : public BaseScreen, public UncachedScreen {
  103. public:
  104. static void onEntry();
  105. static void onRedraw(draw_mode_t);
  106. static bool onTouchEnd(uint8_t tag);
  107. };
  108. #if ENABLED(PRINTCOUNTER)
  109. class StatisticsScreen : public BaseScreen, public UncachedScreen {
  110. public:
  111. static void onRedraw(draw_mode_t);
  112. static bool onTouchEnd(uint8_t tag);
  113. };
  114. #endif
  115. class KillScreen {
  116. // The KillScreen is behaves differently than the
  117. // others, so we do not bother extending UIScreen.
  118. public:
  119. static void show(progmem_str msg);
  120. };
  121. class DialogBoxBaseClass : public BaseScreen {
  122. protected:
  123. template<typename T> static void drawMessage(const T, int16_t font = 0);
  124. static void drawYesNoButtons(uint8_t default_btn = 0);
  125. static void drawOkayButton();
  126. static void drawSpinner();
  127. static void drawButton(const progmem_str);
  128. static void onRedraw(draw_mode_t) {};
  129. public:
  130. static bool onTouchEnd(uint8_t tag);
  131. static void onIdle();
  132. };
  133. class AlertDialogBox : public DialogBoxBaseClass, public CachedScreen<ALERT_BOX_CACHE,ALERT_BOX_DL_SIZE> {
  134. public:
  135. static void onEntry();
  136. static void onRedraw(draw_mode_t);
  137. template<typename T> static void show(T);
  138. template<typename T> static void showError(T);
  139. static void hide();
  140. };
  141. class RestoreFailsafeDialogBox : public DialogBoxBaseClass, public UncachedScreen {
  142. public:
  143. static void onRedraw(draw_mode_t);
  144. static bool onTouchEnd(uint8_t tag);
  145. };
  146. class SaveSettingsDialogBox : public DialogBoxBaseClass, public UncachedScreen {
  147. private:
  148. static bool needs_save;
  149. public:
  150. static void onRedraw(draw_mode_t);
  151. static bool onTouchEnd(uint8_t tag);
  152. static void promptToSaveSettings();
  153. static void settingsChanged() {needs_save = true;}
  154. };
  155. class ConfirmStartPrintDialogBox : public DialogBoxBaseClass, public UncachedScreen {
  156. private:
  157. inline static const char *getShortFilename() {return getFilename(false);}
  158. inline static const char *getLongFilename() {return getFilename(true);}
  159. static const char *getFilename(bool longName);
  160. public:
  161. static void onEntry();
  162. static void onRedraw(draw_mode_t);
  163. static bool onTouchEnd(uint8_t);
  164. static void show(uint8_t file_index);
  165. };
  166. class ConfirmAbortPrintDialogBox : public DialogBoxBaseClass, public UncachedScreen {
  167. public:
  168. static void onRedraw(draw_mode_t);
  169. static bool onTouchEnd(uint8_t tag);
  170. };
  171. #if ENABLED(CALIBRATION_GCODE)
  172. class ConfirmAutoCalibrationDialogBox : public DialogBoxBaseClass, public UncachedScreen {
  173. public:
  174. static void onRedraw(draw_mode_t);
  175. static bool onTouchEnd(uint8_t tag);
  176. };
  177. #endif
  178. class ConfirmUserRequestAlertBox : public AlertDialogBox {
  179. public:
  180. static void onRedraw(draw_mode_t);
  181. static bool onTouchEnd(uint8_t);
  182. static void hide();
  183. static void show(const char*);
  184. };
  185. class SpinnerDialogBox : public DialogBoxBaseClass, public CachedScreen<SPINNER_CACHE,SPINNER_DL_SIZE> {
  186. public:
  187. static void onRedraw(draw_mode_t);
  188. static void onIdle();
  189. static void show(const progmem_str);
  190. static void hide();
  191. static void enqueueAndWait_P(const progmem_str commands);
  192. static void enqueueAndWait_P(const progmem_str message, const progmem_str commands);
  193. };
  194. #ifndef LULZBOT_USE_BIOPRINTER_UI
  195. class StatusScreen : public BaseScreen, public CachedScreen<STATUS_SCREEN_CACHE,STATUS_SCREEN_DL_SIZE> {
  196. private:
  197. static void draw_axis_position(draw_mode_t);
  198. static void draw_temperature(draw_mode_t);
  199. static void draw_progress(draw_mode_t);
  200. static void draw_interaction_buttons(draw_mode_t);
  201. static void draw_status_message(draw_mode_t, const char * const);
  202. public:
  203. static void loadBitmaps();
  204. static void setStatusMessage(const char *);
  205. static void setStatusMessage(progmem_str);
  206. static void onRedraw(draw_mode_t);
  207. static void onStartup();
  208. static void onEntry();
  209. static void onIdle();
  210. static bool onTouchEnd(uint8_t tag);
  211. };
  212. #else
  213. class StatusScreen : public BaseScreen, public CachedScreen<STATUS_SCREEN_CACHE> {
  214. private:
  215. static float increment;
  216. static bool jog_xy;
  217. static bool fine_motion;
  218. static void draw_temperature(draw_mode_t what);
  219. static void draw_syringe(draw_mode_t what);
  220. static void draw_arrows(draw_mode_t what);
  221. static void draw_overlay_icons(draw_mode_t what);
  222. static void draw_fine_motion(draw_mode_t what);
  223. static void draw_buttons(draw_mode_t what);
  224. public:
  225. static void loadBitmaps();
  226. static void unlockMotors();
  227. static void setStatusMessage(const char *);
  228. static void setStatusMessage(progmem_str);
  229. static void onRedraw(draw_mode_t);
  230. static bool onTouchStart(uint8_t tag);
  231. static bool onTouchHeld(uint8_t tag);
  232. static bool onTouchEnd(uint8_t tag);
  233. static void onIdle();
  234. };
  235. class BioPrintingDialogBox : public BaseScreen, public CachedScreen<PRINTING_SCREEN_CACHE,PRINTING_SCREEN_DL_SIZE> {
  236. private:
  237. static void draw_status_message(draw_mode_t, const char * const);
  238. static void draw_progress(draw_mode_t);
  239. static void draw_time_remaining(draw_mode_t);
  240. static void draw_interaction_buttons(draw_mode_t);
  241. public:
  242. static void onRedraw(draw_mode_t);
  243. static void show();
  244. static void setStatusMessage(const char *);
  245. static void setStatusMessage(progmem_str);
  246. static void onIdle();
  247. static bool onTouchEnd(uint8_t tag);
  248. };
  249. class BioConfirmHomeXYZ : public DialogBoxBaseClass, public UncachedScreen {
  250. public:
  251. static void onRedraw(draw_mode_t);
  252. static bool onTouchEnd(uint8_t tag);
  253. };
  254. class BioConfirmHomeE : public DialogBoxBaseClass, public UncachedScreen {
  255. public:
  256. static void onRedraw(draw_mode_t);
  257. static bool onTouchEnd(uint8_t tag);
  258. };
  259. #endif
  260. class MainMenu : public BaseScreen, public CachedScreen<MENU_SCREEN_CACHE> {
  261. public:
  262. static void onRedraw(draw_mode_t);
  263. static bool onTouchEnd(uint8_t tag);
  264. };
  265. class TuneMenu : public BaseScreen, public CachedScreen<TUNE_SCREEN_CACHE> {
  266. public:
  267. static void onRedraw(draw_mode_t);
  268. static bool onTouchEnd(uint8_t tag);
  269. };
  270. class TouchCalibrationScreen : public BaseScreen, public UncachedScreen {
  271. public:
  272. static void onRefresh();
  273. static void onEntry();
  274. static void onRedraw(draw_mode_t);
  275. static void onIdle();
  276. };
  277. class TouchRegistersScreen : public BaseScreen, public UncachedScreen {
  278. public:
  279. static void onRedraw(draw_mode_t);
  280. static bool onTouchEnd(uint8_t tag);
  281. };
  282. class AdvancedSettingsMenu : public BaseScreen, public CachedScreen<ADVANCED_SETTINGS_SCREEN_CACHE> {
  283. public:
  284. static void onRedraw(draw_mode_t);
  285. static bool onTouchEnd(uint8_t tag);
  286. };
  287. class ChangeFilamentScreen : public BaseScreen, public CachedScreen<CHANGE_FILAMENT_SCREEN_CACHE> {
  288. private:
  289. static uint8_t getSoftenTemp();
  290. static ExtUI::extruder_t getExtruder();
  291. static void drawTempGradient(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
  292. static uint32_t getTempColor(uint32_t temp);
  293. public:
  294. static void onEntry();
  295. static void onExit();
  296. static void onRedraw(draw_mode_t);
  297. static bool onTouchStart(uint8_t tag);
  298. static bool onTouchEnd(uint8_t tag);
  299. static bool onTouchHeld(uint8_t tag);
  300. static void onIdle();
  301. };
  302. class BaseNumericAdjustmentScreen : public BaseScreen {
  303. public:
  304. enum precision_default_t {
  305. DEFAULT_LOWEST,
  306. DEFAULT_MIDRANGE,
  307. DEFAULT_HIGHEST
  308. };
  309. protected:
  310. class widgets_t {
  311. private:
  312. draw_mode_t _what;
  313. uint8_t _line;
  314. uint32_t _color;
  315. uint8_t _decimals;
  316. progmem_str _units;
  317. enum style_t {
  318. BTN_NORMAL,
  319. BTN_ACTION,
  320. BTN_TOGGLE,
  321. BTN_DISABLED,
  322. TEXT_AREA,
  323. TEXT_LABEL
  324. } _style;
  325. protected:
  326. void _draw_increment_btn(CommandProcessor &, uint8_t line, const uint8_t tag);
  327. void _button(CommandProcessor &, uint8_t tag, int16_t x, int16_t y, int16_t w, int16_t h, progmem_str, bool enabled = true, bool highlight = false);
  328. void _button_style(CommandProcessor &cmd, style_t style);
  329. public:
  330. widgets_t(draw_mode_t);
  331. widgets_t &color(uint32_t color) {_color = color; return *this;}
  332. widgets_t &units(progmem_str units) {_units = units; return *this;}
  333. widgets_t &draw_mode(draw_mode_t what) {_what = what; return *this;}
  334. widgets_t &precision(uint8_t decimals, precision_default_t = DEFAULT_HIGHEST);
  335. void heading (progmem_str label);
  336. void adjuster_sram_val (uint8_t tag, progmem_str label, const char *value, bool is_enabled = true);
  337. void adjuster (uint8_t tag, progmem_str label, const char *value, bool is_enabled = true);
  338. void adjuster (uint8_t tag, progmem_str label, float value=0, bool is_enabled = true);
  339. void button (uint8_t tag, progmem_str label, bool is_enabled = true);
  340. void text_field (uint8_t tag, progmem_str label, const char *value, bool is_enabled = true);
  341. void two_buttons (uint8_t tag1, progmem_str label1,
  342. uint8_t tag2, progmem_str label2, bool is_enabled = true);
  343. void toggle (uint8_t tag, progmem_str label, bool value, bool is_enabled = true);
  344. void home_buttons (uint8_t tag);
  345. void increments ();
  346. };
  347. static float getIncrement();
  348. public:
  349. static void onEntry();
  350. static bool onTouchEnd(uint8_t tag);
  351. };
  352. class MoveAxisScreen : public BaseNumericAdjustmentScreen, public CachedScreen<MOVE_AXIS_SCREEN_CACHE> {
  353. private:
  354. static float getManualFeedrate(uint8_t axis, float increment_mm);
  355. public:
  356. static void setManualFeedrate(ExtUI::axis_t, float increment_mm);
  357. static void setManualFeedrate(ExtUI::extruder_t, float increment_mm);
  358. static void onEntry();
  359. static void onRedraw(draw_mode_t);
  360. static bool onTouchHeld(uint8_t tag);
  361. static void onIdle();
  362. };
  363. class StepsScreen : public BaseNumericAdjustmentScreen, public CachedScreen<STEPS_SCREEN_CACHE> {
  364. public:
  365. static void onRedraw(draw_mode_t);
  366. static bool onTouchHeld(uint8_t tag);
  367. };
  368. #if HAS_TRINAMIC
  369. class StepperCurrentScreen : public BaseNumericAdjustmentScreen, public CachedScreen<STEPPER_CURRENT_SCREEN_CACHE> {
  370. public:
  371. static void onRedraw(draw_mode_t);
  372. static bool onTouchHeld(uint8_t tag);
  373. };
  374. class StepperBumpSensitivityScreen : public BaseNumericAdjustmentScreen, public CachedScreen<STEPPER_BUMP_SENSITIVITY_SCREEN_CACHE> {
  375. public:
  376. static void onRedraw(draw_mode_t);
  377. static bool onTouchHeld(uint8_t tag);
  378. };
  379. #endif
  380. #if HAS_BED_PROBE
  381. class ZOffsetScreen : public BaseNumericAdjustmentScreen, public CachedScreen<ZOFFSET_SCREEN_CACHE> {
  382. public:
  383. static void onRedraw(draw_mode_t);
  384. static bool onTouchHeld(uint8_t tag);
  385. };
  386. #endif
  387. #if HOTENDS > 1
  388. class NozzleOffsetScreen : public BaseNumericAdjustmentScreen, public CachedScreen<NOZZLE_OFFSET_SCREEN_CACHE> {
  389. public:
  390. static void onEntry();
  391. static void onRedraw(draw_mode_t);
  392. static bool onTouchHeld(uint8_t tag);
  393. };
  394. #endif
  395. #if ENABLED(BABYSTEPPING)
  396. class NudgeNozzleScreen : public BaseNumericAdjustmentScreen, public CachedScreen<ADJUST_OFFSETS_SCREEN_CACHE> {
  397. public:
  398. static void onEntry();
  399. static void onRedraw(draw_mode_t);
  400. static bool onTouchEnd(uint8_t tag);
  401. static bool onTouchHeld(uint8_t tag);
  402. static void onIdle();
  403. };
  404. #endif
  405. #if ENABLED(BACKLASH_GCODE)
  406. class BacklashCompensationScreen : public BaseNumericAdjustmentScreen, public CachedScreen<BACKLASH_COMPENSATION_SCREEN_CACHE> {
  407. public:
  408. static void onRedraw(draw_mode_t);
  409. static bool onTouchHeld(uint8_t tag);
  410. };
  411. #endif
  412. class FeedratePercentScreen : public BaseNumericAdjustmentScreen, public CachedScreen<MAX_FEEDRATE_SCREEN_CACHE> {
  413. public:
  414. static void onRedraw(draw_mode_t);
  415. static bool onTouchHeld(uint8_t tag);
  416. };
  417. class MaxVelocityScreen : public BaseNumericAdjustmentScreen, public CachedScreen<MAX_VELOCITY_SCREEN_CACHE> {
  418. public:
  419. static void onRedraw(draw_mode_t);
  420. static bool onTouchHeld(uint8_t tag);
  421. };
  422. class MaxAccelerationScreen : public BaseNumericAdjustmentScreen, public CachedScreen<MAX_ACCELERATION_SCREEN_CACHE> {
  423. public:
  424. static void onRedraw(draw_mode_t);
  425. static bool onTouchHeld(uint8_t tag);
  426. };
  427. class DefaultAccelerationScreen : public BaseNumericAdjustmentScreen, public CachedScreen<DEFAULT_ACCELERATION_SCREEN_CACHE> {
  428. public:
  429. static void onRedraw(draw_mode_t);
  430. static bool onTouchHeld(uint8_t tag);
  431. };
  432. #if DISABLED(CLASSIC_JERK)
  433. class JunctionDeviationScreen : public BaseNumericAdjustmentScreen, public CachedScreen<JUNC_DEV_SCREEN_CACHE> {
  434. public:
  435. static void onRedraw(draw_mode_t);
  436. static bool onTouchHeld(uint8_t tag);
  437. };
  438. #else
  439. class JerkScreen : public BaseNumericAdjustmentScreen, public CachedScreen<JERK_SCREEN_CACHE> {
  440. public:
  441. static void onRedraw(draw_mode_t);
  442. static bool onTouchHeld(uint8_t tag);
  443. };
  444. #endif
  445. #if EITHER(LIN_ADVANCE, FILAMENT_RUNOUT_SENSOR)
  446. class FilamentMenu : public BaseNumericAdjustmentScreen, public CachedScreen<FILAMENT_MENU_CACHE> {
  447. public:
  448. static void onRedraw(draw_mode_t);
  449. static bool onTouchEnd(uint8_t tag);
  450. };
  451. #endif
  452. #if ENABLED(FILAMENT_RUNOUT_SENSOR)
  453. class FilamentRunoutScreen : public BaseNumericAdjustmentScreen, public CachedScreen<FILAMENT_RUNOUT_SCREEN_CACHE> {
  454. public:
  455. static void onRedraw(draw_mode_t);
  456. static bool onTouchHeld(uint8_t tag);
  457. };
  458. #endif
  459. #if ENABLED(LIN_ADVANCE)
  460. class LinearAdvanceScreen : public BaseNumericAdjustmentScreen, public CachedScreen<LINEAR_ADVANCE_SCREEN_CACHE> {
  461. public:
  462. static void onRedraw(draw_mode_t);
  463. static bool onTouchHeld(uint8_t tag);
  464. };
  465. #endif
  466. class TemperatureScreen : public BaseNumericAdjustmentScreen, public CachedScreen<TEMPERATURE_SCREEN_CACHE> {
  467. public:
  468. static void onRedraw(draw_mode_t);
  469. static bool onTouchHeld(uint8_t tag);
  470. };
  471. class InterfaceSoundsScreen : public BaseScreen, public CachedScreen<INTERFACE_SOUNDS_SCREEN_CACHE> {
  472. public:
  473. enum event_t {
  474. PRINTING_STARTED = 0,
  475. PRINTING_FINISHED = 1,
  476. PRINTING_FAILED = 2,
  477. NUM_EVENTS
  478. };
  479. private:
  480. friend class InterfaceSettingsScreen;
  481. static uint8_t event_sounds[NUM_EVENTS];
  482. static const char* getSoundSelection(event_t);
  483. static void toggleSoundSelection(event_t);
  484. static void setSoundSelection(event_t, const FTDI::SoundPlayer::sound_t*);
  485. public:
  486. static void playEventSound(event_t, FTDI::play_mode_t = FTDI::PLAY_ASYNCHRONOUS);
  487. static void defaultSettings();
  488. static void onEntry();
  489. static void onRedraw(draw_mode_t);
  490. static bool onTouchStart(uint8_t tag);
  491. static bool onTouchEnd(uint8_t tag);
  492. static void onIdle();
  493. };
  494. class InterfaceSettingsScreen : public BaseScreen, public CachedScreen<INTERFACE_SETTINGS_SCREEN_CACHE> {
  495. private:
  496. struct persistent_data_t {
  497. uint32_t touch_transform_a;
  498. uint32_t touch_transform_b;
  499. uint32_t touch_transform_c;
  500. uint32_t touch_transform_d;
  501. uint32_t touch_transform_e;
  502. uint32_t touch_transform_f;
  503. uint16_t passcode;
  504. uint8_t display_brightness;
  505. int8_t display_h_offset_adj;
  506. int8_t display_v_offset_adj;
  507. uint8_t sound_volume;
  508. uint8_t bit_flags;
  509. uint8_t event_sounds[InterfaceSoundsScreen::NUM_EVENTS];
  510. };
  511. public:
  512. #ifdef LULZBOT_EEPROM_BACKUP_SIZE
  513. static bool backupEEPROM();
  514. #endif
  515. static void saveSettings(char *);
  516. static void loadSettings(const char *);
  517. static void defaultSettings();
  518. static void failSafeSettings();
  519. static void onStartup();
  520. static void onEntry();
  521. static void onRedraw(draw_mode_t);
  522. static bool onTouchStart(uint8_t tag);
  523. static bool onTouchEnd(uint8_t tag);
  524. static void onIdle();
  525. };
  526. class LockScreen : public BaseScreen, public CachedScreen<LOCK_SCREEN_CACHE> {
  527. private:
  528. friend InterfaceSettingsScreen;
  529. static uint16_t passcode;
  530. static char & message_style();
  531. static uint16_t compute_checksum();
  532. static void onPasscodeEntered();
  533. public:
  534. static bool is_enabled();
  535. static void check_passcode();
  536. static void enable();
  537. static void disable();
  538. static void set_hash(uint16_t pass) {passcode = pass;};
  539. static uint16_t get_hash() {return passcode;};
  540. static void onEntry();
  541. static void onRedraw(draw_mode_t);
  542. static bool onTouchEnd(uint8_t tag);
  543. };
  544. class FilesScreen : public BaseScreen, public CachedScreen<FILES_SCREEN_CACHE, FILE_SCREEN_DL_SIZE> {
  545. private:
  546. #ifdef TOUCH_UI_PORTRAIT
  547. static constexpr uint8_t header_h = 2;
  548. static constexpr uint8_t footer_h = 2;
  549. static constexpr uint8_t files_per_page = 11;
  550. #else
  551. static constexpr uint8_t header_h = 1;
  552. static constexpr uint8_t footer_h = 1;
  553. static constexpr uint8_t files_per_page = 6;
  554. #endif
  555. static uint8_t getTagForLine(uint8_t line) {return line + 2;}
  556. static uint8_t getLineForTag(uint8_t tag) {return tag - 2;}
  557. static uint16_t getFileForTag(uint8_t tag);
  558. static uint16_t getSelectedFileIndex();
  559. inline static const char *getSelectedShortFilename() {return getSelectedFilename(false);}
  560. inline static const char *getSelectedLongFilename() {return getSelectedFilename(true);}
  561. static const char *getSelectedFilename(bool longName);
  562. static void drawFileButton(const char* filename, uint8_t tag, bool is_dir, bool is_highlighted);
  563. static void drawFileList();
  564. static void drawHeader();
  565. static void drawFooter();
  566. static void drawSelectedFile();
  567. static void gotoPage(uint8_t);
  568. public:
  569. static void onEntry();
  570. static void onRedraw(draw_mode_t);
  571. static bool onTouchEnd(uint8_t tag);
  572. static void onIdle();
  573. };
  574. class EndstopStatesScreen : public BaseScreen, public UncachedScreen {
  575. public:
  576. static void onEntry();
  577. static void onExit();
  578. static void onRedraw(draw_mode_t);
  579. static bool onTouchEnd(uint8_t tag);
  580. static void onIdle();
  581. };
  582. class DisplayTuningScreen : public BaseNumericAdjustmentScreen, public CachedScreen<DISPLAY_TIMINGS_SCREEN_CACHE> {
  583. public:
  584. static void onRedraw(draw_mode_t);
  585. static bool onTouchHeld(uint8_t tag);
  586. };
  587. #if ENABLED(DEVELOPER_SCREENS)
  588. class DeveloperMenu : public BaseScreen, public UncachedScreen {
  589. public:
  590. static void onRedraw(draw_mode_t);
  591. static bool onTouchEnd(uint8_t tag);
  592. };
  593. class ConfirmEraseFlashDialogBox : public DialogBoxBaseClass, public UncachedScreen {
  594. public:
  595. static void onRedraw(draw_mode_t);
  596. static bool onTouchEnd(uint8_t tag);
  597. };
  598. class WidgetsScreen : public BaseScreen, public UncachedScreen {
  599. public:
  600. static void onEntry();
  601. static void onRedraw(draw_mode_t);
  602. static bool onTouchStart(uint8_t tag);
  603. static void onIdle();
  604. };
  605. class StressTestScreen : public BaseScreen, public UncachedScreen {
  606. private:
  607. static void drawDots(uint16_t x, uint16_t y, uint16_t h, uint16_t v);
  608. static bool watchDogTestNow();
  609. static void recursiveLockup();
  610. static void iterativeLockup();
  611. static void runTestOnBootup(bool enable);
  612. public:
  613. static void startupCheck();
  614. static void onEntry();
  615. static void onRedraw(draw_mode_t);
  616. static bool onTouchEnd(uint8_t tag);
  617. static void onIdle();
  618. };
  619. #endif
  620. class MediaPlayerScreen : public BaseScreen, public UncachedScreen {
  621. private:
  622. typedef int16_t media_streamer_func_t(void *obj, void *buff, size_t bytes);
  623. public:
  624. static bool playCardMedia();
  625. static bool playBootMedia();
  626. static void onEntry();
  627. static void onRedraw(draw_mode_t);
  628. static void playStream(void *obj, media_streamer_func_t*);
  629. };
  630. #if NUM_LANGUAGES > 1
  631. class LanguageMenu : public BaseScreen, public UncachedScreen {
  632. public:
  633. static void onRedraw(draw_mode_t);
  634. static bool onTouchEnd(uint8_t tag);
  635. };
  636. #endif