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.

base_screen.cpp 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*******************
  2. * base_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. void BaseScreen::onEntry() {
  27. CommandProcessor cmd;
  28. cmd.set_button_style_callback(buttonStyleCallback);
  29. reset_menu_timeout();
  30. UIScreen::onEntry();
  31. }
  32. bool BaseScreen::buttonIsPressed(uint8_t tag) {
  33. return tag != 0 && EventLoop::get_pressed_tag() == tag;
  34. }
  35. bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t &style, uint16_t &options, bool post) {
  36. if (post) {
  37. cmd.colors(normal_btn);
  38. return false;
  39. }
  40. #ifdef LCD_TIMEOUT_TO_STATUS
  41. if (EventLoop::get_pressed_tag() != 0) {
  42. reset_menu_timeout();
  43. }
  44. #endif
  45. if (buttonIsPressed(tag)) {
  46. options = OPT_FLAT;
  47. }
  48. if (style & cmd.STYLE_DISABLED) {
  49. cmd.tag(0);
  50. style &= ~cmd.STYLE_DISABLED;
  51. cmd.colors(disabled_btn);
  52. return true; // Call me again to reset the colors
  53. }
  54. return false;
  55. }
  56. void BaseScreen::onIdle() {
  57. #ifdef LCD_TIMEOUT_TO_STATUS
  58. if ((millis() - last_interaction) > LCD_TIMEOUT_TO_STATUS) {
  59. reset_menu_timeout();
  60. #if ENABLED(TOUCH_UI_DEBUG)
  61. SERIAL_ECHO_MSG("Returning to status due to menu timeout");
  62. #endif
  63. GOTO_SCREEN(StatusScreen);
  64. }
  65. #endif
  66. }
  67. void BaseScreen::reset_menu_timeout() {
  68. #ifdef LCD_TIMEOUT_TO_STATUS
  69. last_interaction = millis();
  70. #endif
  71. }
  72. #ifdef LCD_TIMEOUT_TO_STATUS
  73. uint32_t BaseScreen::last_interaction;
  74. #endif
  75. #endif // TOUCH_UI_FTDI_EVE