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.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 PRO UI
  24. * Author: Miguel A. Risco-Castillo (MRISCOC)
  25. * Version: 2.2.0
  26. * Date: 2022/04/11
  27. */
  28. #include "../../../inc/MarlinConfigPre.h"
  29. #if ENABLED(DWIN_LCD_PROUI)
  30. #include "../../../core/types.h"
  31. #include "dwin_lcd.h"
  32. #include "dwinui.h"
  33. #include "dwin.h"
  34. #include "lockscreen.h"
  35. LockScreenClass lockScreen;
  36. uint8_t LockScreenClass::lock_pos = 0;
  37. bool LockScreenClass::unlocked = false;
  38. uint8_t LockScreenClass::rprocess = 0;
  39. void LockScreenClass::init() {
  40. lock_pos = 0;
  41. unlocked = false;
  42. draw();
  43. }
  44. void LockScreenClass::draw() {
  45. Title.SetCaption(GET_TEXT_F(MSG_LOCKSCREEN));
  46. DWINUI::ClearMainArea();
  47. DWINUI::Draw_Icon(ICON_LOGO, 71, 120); // CREALITY logo
  48. DWINUI::Draw_CenteredString(Color_White, 180, GET_TEXT_F(MSG_LOCKSCREEN_LOCKED));
  49. DWINUI::Draw_CenteredString(Color_White, 200, GET_TEXT_F(MSG_LOCKSCREEN_UNLOCK));
  50. DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-"));
  51. DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
  52. DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
  53. DWIN_UpdateLCD();
  54. }
  55. void LockScreenClass::onEncoder(EncoderState encoder_diffState) {
  56. switch (encoder_diffState) {
  57. case ENCODER_DIFF_CW: lock_pos += 8; break;
  58. case ENCODER_DIFF_CCW: lock_pos -= 8; break;
  59. case ENCODER_DIFF_ENTER: unlocked = (lock_pos == 128); break;
  60. default: break;
  61. }
  62. DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
  63. DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
  64. DWIN_UpdateLCD();
  65. }
  66. #endif // DWIN_LCD_PROUI