Password via G-code and MarlinUI (#18399)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
sherwin-dc
2020-08-09 09:00:42 +08:00
committed by GitHub
parent 0a1b865987
commit 852e5ae042
19 changed files with 588 additions and 25 deletions

View File

@ -140,6 +140,10 @@
#define HAS_CASE_LIGHT_BRIGHTNESS 1
#endif
#if ENABLED(PASSWORD_FEATURE)
#include "../feature/password/password.h"
#endif
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
#include "../lcd/tft/touch.h"
#endif
@ -152,7 +156,7 @@ typedef struct { int16_t X, Y, Z, X2, Y2, Z2, Z3, Z4;
typedef struct { bool X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_stealth_enabled_t;
// Limit an index to an array size
#define ALIM(I,ARR) _MIN(I, signed(COUNT(ARR) - 1))
#define ALIM(I,ARR) _MIN(I, (signed)COUNT(ARR) - 1)
// Defaults for reset / fill in on load
static const uint32_t _DMA[] PROGMEM = DEFAULT_MAX_ACCELERATION;
@ -407,6 +411,14 @@ typedef struct SettingsDataStruct {
uint8_t caselight_brightness; // M355 P
#endif
//
// PASSWORD_FEATURE
//
#if ENABLED(PASSWORD_FEATURE)
bool password_is_set;
uint32_t password_value;
#endif
//
// TOUCH_SCREEN_CALIBRATION
//
@ -1345,6 +1357,14 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(caselight.brightness);
#endif
//
// Password feature
//
#if ENABLED(PASSWORD_FEATURE)
EEPROM_WRITE(password.is_set);
EEPROM_WRITE(password.value);
#endif
//
// TOUCH_SCREEN_CALIBRATION
//
@ -2185,6 +2205,15 @@ void MarlinSettings::postprocess() {
EEPROM_READ(caselight.brightness);
#endif
//
// Password feature
//
#if ENABLED(PASSWORD_FEATURE)
_FIELD_TEST(password_is_set);
EEPROM_READ(password.is_set);
EEPROM_READ(password.value);
#endif
//
// TOUCH_SCREEN_CALIBRATION
//
@ -2665,7 +2694,7 @@ void MarlinSettings::reset() {
#define PID_DEFAULT(N,E) DEFAULT_##N
#endif
HOTEND_LOOP() {
PID_PARAM(Kp, e) = float(PID_DEFAULT(Kp, ALIM(e, defKp)));
PID_PARAM(Kp, e) = float(PID_DEFAULT(Kp, ALIM(e, defKp)));
PID_PARAM(Ki, e) = scalePID_i(PID_DEFAULT(Ki, ALIM(e, defKi)));
PID_PARAM(Kd, e) = scalePID_d(PID_DEFAULT(Kd, ALIM(e, defKd)));
TERN_(PID_EXTRUSION_SCALING, PID_PARAM(Kc, e) = float(PID_DEFAULT(Kc, ALIM(e, defKc))));
@ -2783,6 +2812,15 @@ void MarlinSettings::reset() {
}
#endif
#if ENABLED(PASSWORD_FEATURE)
#ifdef PASSWORD_DEFAULT_VALUE
password.is_set = true;
password.value = PASSWORD_DEFAULT_VALUE;
#else
password.is_set = false;
#endif
#endif
postprocess();
DEBUG_ECHO_START();