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.

touch_calibration_screen.cpp 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /********************************
  2. * touch_calibration_screen.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: <https://www.gnu.org/licenses/>. *
  20. ****************************************************************************/
  21. #include "../config.h"
  22. #if ENABLED(TOUCH_UI_FTDI_EVE)
  23. #include "screens.h"
  24. using namespace FTDI;
  25. using namespace Theme;
  26. #define GRID_COLS 4
  27. #define GRID_ROWS 16
  28. #define TEXT_POS BTN_POS(1,1), BTN_SIZE(4,12)
  29. void TouchCalibrationScreen::onEntry() {
  30. CommandProcessor cmd;
  31. BaseScreen::onEntry();
  32. if (CLCD::is_touching()) {
  33. // Ask the user to release the touch before starting,
  34. // as otherwise the first calibration point could
  35. // be misinterpreted.
  36. cmd.cmd(CMD_DLSTART)
  37. .cmd(CLEAR_COLOR_RGB(bg_color))
  38. .cmd(CLEAR(true,true,true))
  39. .cmd(COLOR_RGB(bg_text_enabled));
  40. draw_text_box(cmd, TEXT_POS, GET_TEXT_F(MSG_TOUCH_CALIBRATION_START), OPT_CENTER, font_large);
  41. cmd.cmd(DL::DL_DISPLAY)
  42. .cmd(CMD_SWAP)
  43. .execute();
  44. while (CLCD::is_touching()) {
  45. #if ENABLED(TOUCH_UI_DEBUG)
  46. SERIAL_ECHO_MSG("Waiting for touch release");
  47. #endif
  48. }
  49. }
  50. // Force a refresh
  51. cmd.cmd(CMD_DLSTART);
  52. onRedraw(FOREGROUND);
  53. cmd.cmd(DL::DL_DISPLAY);
  54. cmd.execute();
  55. }
  56. void TouchCalibrationScreen::onRefresh() {
  57. // Don't do the regular refresh, as this would
  58. // cause the calibration be restarted on every
  59. // touch.
  60. }
  61. void TouchCalibrationScreen::onRedraw(draw_mode_t) {
  62. CommandProcessor cmd;
  63. cmd.cmd(CLEAR_COLOR_RGB(bg_color))
  64. .cmd(CLEAR(true,true,true))
  65. .cmd(COLOR_RGB(bg_text_enabled));
  66. draw_text_box(cmd, TEXT_POS, GET_TEXT_F(MSG_TOUCH_CALIBRATION_PROMPT), OPT_CENTER, font_large);
  67. cmd.cmd(CMD_CALIBRATE);
  68. }
  69. void TouchCalibrationScreen::onIdle() {
  70. if (!CLCD::is_touching() && !CommandProcessor::is_processing()) {
  71. GOTO_PREVIOUS();
  72. }
  73. }
  74. #endif // TOUCH_UI_FTDI_EVE