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 25KB

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