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.

password.cpp 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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. #include "../../inc/MarlinConfigPre.h"
  23. #if ENABLED(PASSWORD_FEATURE)
  24. #include "password.h"
  25. #include "../../gcode/gcode.h"
  26. #include "../../core/serial.h"
  27. Password password;
  28. // public:
  29. bool Password::is_set, Password::is_locked, Password::did_first_run; // = false
  30. uint32_t Password::value, Password::value_entry;
  31. //
  32. // Authenticate user with password.
  33. // Called from Setup, after SD Prinitng Stops/Aborts, and M510
  34. //
  35. void Password::lock_machine() {
  36. is_locked = true;
  37. TERN_(HAS_MARLINUI_MENU, authenticate_user(ui.status_screen, screen_password_entry));
  38. }
  39. //
  40. // Authentication check
  41. //
  42. void Password::authentication_check() {
  43. if (value_entry == value) {
  44. is_locked = false;
  45. did_first_run = true;
  46. }
  47. else {
  48. is_locked = true;
  49. SERIAL_ECHOLNPGM(STR_WRONG_PASSWORD);
  50. }
  51. TERN_(HAS_MARLINUI_MENU, authentication_done());
  52. }
  53. #endif // PASSWORD_FEATURE