|
@@ -84,70 +84,78 @@ void host_action(const char * const pstr, const bool eol) {
|
84
|
84
|
if (eol) SERIAL_EOL();
|
85
|
85
|
}
|
86
|
86
|
|
87
|
|
- void host_action_prompt_plus(const char * const ptype, const char * const pstr, const bool eol=true) {
|
|
87
|
+ void host_action_prompt_plus(const char * const ptype, const char * const pstr, const char extra_char='\0') {
|
88
|
88
|
host_action_prompt(ptype, false);
|
89
|
89
|
SERIAL_CHAR(' ');
|
90
|
90
|
serialprintPGM(pstr);
|
91
|
|
- if (eol) SERIAL_EOL();
|
|
91
|
+ if (extra_char != '\0') SERIAL_CHAR(extra_char);
|
|
92
|
+ SERIAL_EOL();
|
|
93
|
+ }
|
|
94
|
+ void host_action_prompt_begin(const PromptReason reason, const char * const pstr, const char extra_char/*='\0'*/) {
|
|
95
|
+ host_action_prompt_end();
|
|
96
|
+ host_prompt_reason = reason;
|
|
97
|
+ host_action_prompt_plus(PSTR("begin"), pstr, extra_char);
|
92
|
98
|
}
|
93
|
|
- void host_action_prompt_begin(const char * const pstr, const bool eol/*=true*/) { host_action_prompt_plus(PSTR("begin"), pstr, eol); }
|
94
|
99
|
void host_action_prompt_button(const char * const pstr) { host_action_prompt_plus(PSTR("button"), pstr); }
|
95
|
100
|
void host_action_prompt_end() { host_action_prompt(PSTR("end")); }
|
96
|
101
|
void host_action_prompt_show() { host_action_prompt(PSTR("show")); }
|
97
|
|
- void host_prompt_do(const PromptReason reason, const char * const pstr, const char * const pbtn/*=nullptr*/) {
|
98
|
|
- host_prompt_reason = reason;
|
99
|
|
- host_action_prompt_end();
|
100
|
|
- host_action_prompt_begin(pstr);
|
101
|
|
- if (pbtn) host_action_prompt_button(pbtn);
|
|
102
|
+ void host_prompt_do(const PromptReason reason, const char * const pstr, const char * const btn1/*=nullptr*/, const char * const btn2/*=nullptr*/) {
|
|
103
|
+ host_action_prompt_begin(reason, pstr);
|
|
104
|
+ if (btn1) host_action_prompt_button(btn1);
|
|
105
|
+ if (btn2) host_action_prompt_button(btn2);
|
102
|
106
|
host_action_prompt_show();
|
103
|
107
|
}
|
104
|
108
|
|
105
|
|
- inline void say_m876_response(const char * const pstr) {
|
106
|
|
- SERIAL_ECHOPGM("M876 Responding PROMPT_");
|
107
|
|
- serialprintPGM(pstr);
|
108
|
|
- SERIAL_EOL();
|
|
109
|
+ void filament_load_host_prompt() {
|
|
110
|
+ const bool disable_to_continue = (false
|
|
111
|
+ #if HAS_FILAMENT_SENSOR
|
|
112
|
+ || runout.filament_ran_out
|
|
113
|
+ #endif
|
|
114
|
+ );
|
|
115
|
+ host_prompt_do(PROMPT_FILAMENT_RUNOUT, PSTR("Paused"), PSTR("PurgeMore"),
|
|
116
|
+ disable_to_continue ? PSTR("DisableRunout") : CONTINUE_STR
|
|
117
|
+ );
|
109
|
118
|
}
|
110
|
119
|
|
|
120
|
+ //
|
|
121
|
+ // Handle responses from the host, such as:
|
|
122
|
+ // - Filament runout responses: Purge More, Continue
|
|
123
|
+ // - General "Continue" response
|
|
124
|
+ // - Resume Print response
|
|
125
|
+ // - Dismissal of info
|
|
126
|
+ //
|
111
|
127
|
void host_response_handler(const uint8_t response) {
|
112
|
128
|
#ifdef DEBUG_HOST_ACTIONS
|
113
|
|
- SERIAL_ECHOLNPAIR("M876 Handle Reason: ", host_prompt_reason);
|
114
|
|
- SERIAL_ECHOLNPAIR("M876 Handle Response: ", response);
|
|
129
|
+ static const char m876_prefix[] PROGMEM = "M876 Handle Re";
|
|
130
|
+ serialprintPGM(m876_prefix); SERIAL_ECHOLNPAIR("ason: ", host_prompt_reason);
|
|
131
|
+ serialprintPGM(m876_prefix); SERIAL_ECHOLNPAIR("sponse: ", response);
|
115
|
132
|
#endif
|
116
|
133
|
const char *msg = PSTR("UNKNOWN STATE");
|
117
|
134
|
const PromptReason hpr = host_prompt_reason;
|
118
|
|
- host_prompt_reason = PROMPT_NOT_DEFINED;
|
|
135
|
+ host_prompt_reason = PROMPT_NOT_DEFINED; // Reset now ahead of logic
|
119
|
136
|
switch (hpr) {
|
120
|
137
|
case PROMPT_FILAMENT_RUNOUT:
|
121
|
138
|
msg = PSTR("FILAMENT_RUNOUT");
|
122
|
|
- if (response == 0) {
|
123
|
|
- #if ENABLED(ADVANCED_PAUSE_FEATURE)
|
124
|
|
- pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE;
|
125
|
|
- #endif
|
126
|
|
- host_action_prompt_end(); // Close current prompt
|
127
|
|
- host_action_prompt_begin(PSTR("Paused"));
|
128
|
|
- host_action_prompt_button(PSTR("Purge More"));
|
129
|
|
- if (false
|
|
139
|
+ switch (response) {
|
|
140
|
+
|
|
141
|
+ case 0: // "Purge More" button
|
|
142
|
+ #if HAS_LCD_MENU && ENABLED(ADVANCED_PAUSE_FEATURE)
|
|
143
|
+ pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; // Simulate menu selection (menu exits, doesn't extrude more)
|
|
144
|
+ #endif
|
|
145
|
+ filament_load_host_prompt(); // Initiate another host prompt. (NOTE: The loop in load_filament may also do this!)
|
|
146
|
+ break;
|
|
147
|
+
|
|
148
|
+ case 1: // "Continue" / "Disable Runout" button
|
|
149
|
+ #if HAS_LCD_MENU && ENABLED(ADVANCED_PAUSE_FEATURE)
|
|
150
|
+ pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; // Simulate menu selection
|
|
151
|
+ #endif
|
130
|
152
|
#if HAS_FILAMENT_SENSOR
|
131
|
|
- || runout.filament_ran_out
|
|
153
|
+ if (runout.filament_ran_out) { // Disable a triggered sensor
|
|
154
|
+ runout.enabled = false;
|
|
155
|
+ runout.reset();
|
|
156
|
+ }
|
132
|
157
|
#endif
|
133
|
|
- )
|
134
|
|
- host_action_prompt_button(PSTR("DisableRunout"));
|
135
|
|
- else {
|
136
|
|
- host_prompt_reason = PROMPT_FILAMENT_RUNOUT;
|
137
|
|
- host_action_prompt_button(CONTINUE_STR);
|
138
|
|
- }
|
139
|
|
- host_action_prompt_show();
|
140
|
|
- }
|
141
|
|
- else if (response == 1) {
|
142
|
|
- #if HAS_FILAMENT_SENSOR
|
143
|
|
- if (runout.filament_ran_out) {
|
144
|
|
- runout.enabled = false;
|
145
|
|
- runout.reset();
|
146
|
|
- }
|
147
|
|
- #endif
|
148
|
|
- #if ENABLED(ADVANCED_PAUSE_FEATURE)
|
149
|
|
- pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT;
|
150
|
|
- #endif
|
|
158
|
+ break;
|
151
|
159
|
}
|
152
|
160
|
break;
|
153
|
161
|
case PROMPT_USER_CONTINUE:
|
|
@@ -168,7 +176,9 @@ void host_action(const char * const pstr, const bool eol) {
|
168
|
176
|
break;
|
169
|
177
|
default: break;
|
170
|
178
|
}
|
171
|
|
- say_m876_response(msg);
|
|
179
|
+ SERIAL_ECHOPGM("M876 Responding PROMPT_");
|
|
180
|
+ serialprintPGM(msg);
|
|
181
|
+ SERIAL_EOL();
|
172
|
182
|
}
|
173
|
183
|
|
174
|
184
|
#endif // HOST_PROMPT_SUPPORT
|