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

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