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.

lockscreen.cpp 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  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. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Lock screen implementation for DWIN UI Enhanced implementation
  24. * Author: Miguel A. Risco-Castillo (MRISCOC)
  25. * Version: 2.1
  26. * Date: 2021/11/09
  27. *
  28. * Based on the original code provided by Creality under GPL
  29. */
  30. #include "../../../inc/MarlinConfigPre.h"
  31. #if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
  32. #include "../../../core/types.h"
  33. #include "dwin_lcd.h"
  34. #include "dwinui.h"
  35. #include "dwin.h"
  36. #include "lockscreen.h"
  37. LockScreenClass lockScreen;
  38. uint8_t LockScreenClass::lock_pos = 0;
  39. bool LockScreenClass::unlocked = false;
  40. uint8_t LockScreenClass::rprocess = 0;
  41. void LockScreenClass::init() {
  42. lock_pos = 0;
  43. unlocked = false;
  44. draw();
  45. }
  46. void LockScreenClass::draw() {
  47. Title.SetCaption(PSTR("Lock Screen"));
  48. DWINUI::ClearMenuArea();
  49. DWINUI::Draw_Icon(ICON_LOGO, 71, 120); // CREALITY logo
  50. DWINUI::Draw_CenteredString(Color_White, 180, F("Printer is Locked,"));
  51. DWINUI::Draw_CenteredString(Color_White, 200, F("Scroll to unlock."));
  52. DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-"));
  53. DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
  54. DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
  55. DWIN_UpdateLCD();
  56. }
  57. void LockScreenClass::onEncoder(EncoderState encoder_diffState) {
  58. switch (encoder_diffState) {
  59. case ENCODER_DIFF_CW: lock_pos += 8; break;
  60. case ENCODER_DIFF_CCW: lock_pos -= 8; break;
  61. case ENCODER_DIFF_ENTER: unlocked = (lock_pos == 128); break;
  62. default: break;
  63. }
  64. DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
  65. DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
  66. DWIN_UpdateLCD();
  67. }
  68. #endif // DWIN_CREALITY_LCD_ENHANCED