Bladeren bron

MalyanLCD: Pause, resume, more ExtUI (#14852)

J.C. Nelson 4 jaren geleden
bovenliggende
commit
1bcc5c98a9

+ 51
- 86
Marlin/src/lcd/extui_malyan_lcd.cpp Bestand weergeven

@@ -45,6 +45,8 @@
45 45
 
46 46
 #if ENABLED(MALYAN_LCD)
47 47
 
48
+#define DEBUG_MALYAN_LCD
49
+
48 50
 #include "extensible_ui/ui_api.h"
49 51
 
50 52
 #include "ultralcd.h"
@@ -62,6 +64,9 @@
62 64
   #define LONG_FILENAME_LENGTH 0
63 65
 #endif
64 66
 
67
+#define DEBUG_OUT ENABLED(DEBUG_MALYAN_LCD)
68
+#include "../core/debug_out.h"
69
+
65 70
 // On the Malyan M200, this will be Serial1. On a RAMPS board,
66 71
 // it might not be.
67 72
 #define LCD_SERIAL Serial1
@@ -119,13 +124,13 @@ void process_lcd_c_command(const char* command) {
119 124
       LIMIT(feedrate_percentage, 10, 999);
120 125
       break;
121 126
 
122
-    case 'T': thermalManager.setTargetHotend(atoi(command + 1), 0); break;
127
+    case 'T': ExtUI::setTargetTemp_celsius(atoi(command + 1), ExtUI::extruder_t::E0); break;
123 128
 
124 129
     #if HAS_HEATED_BED
125
-      case 'P': thermalManager.setTargetBed(atoi(command + 1)); break;
130
+      case 'P': ExtUI::setTargetTemp_celsius(atoi(command + 1), ExtUI::heater_t::BED); break;
126 131
     #endif
127 132
 
128
-    default: SERIAL_ECHOLNPAIR("UNKNOWN C COMMAND", command);
133
+    default: DEBUG_ECHOLNPAIR("UNKNOWN C COMMAND ", command);
129 134
   }
130 135
 }
131 136
 
@@ -163,9 +168,7 @@ void process_lcd_eb_command(const char* command) {
163 168
       write_to_lcd(message_buffer);
164 169
     } break;
165 170
 
166
-    default:
167
-      SERIAL_ECHOLNPAIR("UNKNOWN E/B COMMAND", command);
168
-      return;
171
+    default: DEBUG_ECHOLNPAIR("UNKNOWN E/B COMMAND ", command);
169 172
   }
170 173
 }
171 174
 
@@ -180,32 +183,18 @@ void process_lcd_eb_command(const char* command) {
180 183
  * X, Y, Z, A (extruder)
181 184
  */
182 185
 void process_lcd_j_command(const char* command) {
183
-  static bool steppers_enabled = false;
184
-  char axis = command[0];
185
-
186
-  switch (axis) {
187
-    case 'E':
188
-      // enable or disable steppers
189
-      // switch to relative
190
-      queue.enqueue_now_P(PSTR("G91"));
191
-      queue.enqueue_now_P(steppers_enabled ? PSTR("M18") : PSTR("M17"));
192
-      steppers_enabled = !steppers_enabled;
193
-      break;
194
-    case 'A':
195
-      axis = 'E';
196
-      // fallthru
197
-    case 'Y':
198
-    case 'Z':
199
-    case 'X': {
200
-      // G0 <AXIS><distance>
201
-      // The M200 class UI seems to send movement in .1mm values.
202
-      char cmd[20], pos[6];
203
-      sprintf_P(cmd, PSTR("G1 %c%s"), axis, dtostrf(atof(command + 1) / 10.0, -5, 3, pos));
204
-      queue.enqueue_one_now(cmd);
205
-    } break;
206
-    default:
207
-      SERIAL_ECHOLNPAIR("UNKNOWN J COMMAND", command);
208
-      return;
186
+  auto move_axis = [](const auto axis) {
187
+    const float dist = atof(command + 1) / 10.0;
188
+    ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(axis) + dist, axis);
189
+  }
190
+
191
+  switch (command[0]) {
192
+    case 'E': break;
193
+    case 'A': move_axis(ExtUI::extruder_t::E0); break;
194
+    case 'Y': move_axis(ExtUI::axis_t::Y); break;
195
+    case 'Z': move_axis(ExtUI::axis_t::Z); break;
196
+    case 'X': move_axis(ExtUI::axis_t::X); break;
197
+    default: DEBUG_ECHOLNPAIR("UNKNOWN J COMMAND ", command);
209 198
   }
210 199
 }
211 200
 
@@ -234,29 +223,20 @@ void process_lcd_j_command(const char* command) {
234 223
 void process_lcd_p_command(const char* command) {
235 224
 
236 225
   switch (command[0]) {
226
+    case 'P':
227
+        ExtUI::pausePrint();
228
+        write_to_lcd_P(PSTR("{SYS:PAUSED}"));
229
+        break;
230
+    case 'R':
231
+        ExtUI::resumePrint();
232
+        write_to_lcd_P(PSTR("{SYS:RESUMED}"));
233
+        break;
237 234
     case 'X':
238
-      #if ENABLED(SDSUPPORT)
239
-        // cancel print
240 235
         write_to_lcd_P(PSTR("{SYS:CANCELING}"));
241
-        last_printing_status = false;
242
-        card.stopSDPrint(
243
-          #if SD_RESORT
244
-            true
245
-          #endif
246
-        );
247
-        queue.clear();
248
-        quickstop_stepper();
249
-        print_job_timer.stop();
250
-        thermalManager.disable_all_heaters();
251
-        thermalManager.zero_fan_speeds();
252
-        wait_for_heatup = false;
236
+        ExtUI::stopPrint();
253 237
         write_to_lcd_P(PSTR("{SYS:STARTED}"));
254
-      #endif
255
-      break;
256
-    case 'H':
257
-      // Home all axis
258
-      queue.enqueue_now_P(PSTR("G28"));
259
-      break;
238
+        break;
239
+    case 'H': queue.enqueue_now_P(PSTR("G28")); break; // Home all axes
260 240
     default: {
261 241
       #if ENABLED(SDSUPPORT)
262 242
         // Print file 000 - a three digit number indicating which
@@ -338,9 +318,7 @@ void process_lcd_s_command(const char* command) {
338 318
       #endif
339 319
     } break;
340 320
 
341
-    default:
342
-      SERIAL_ECHOLNPAIR("UNKNOWN S COMMAND", command);
343
-      return;
321
+    default: DEBUG_ECHOLNPAIR("UNKNOWN S COMMAND ", command);
344 322
   }
345 323
 }
346 324
 
@@ -354,34 +332,22 @@ void process_lcd_command(const char* command) {
354 332
 
355 333
   current++; // skip the leading {. The trailing one is already gone.
356 334
   byte command_code = *current++;
357
-  if (*current != ':') {
358
-    SERIAL_ECHOLNPAIR("UNKNOWN COMMAND FORMAT", command);
359
-    return;
360
-  }
361
-
362
-  current++; // skip the :
363
-
364
-  switch (command_code) {
365
-    case 'S':
366
-      process_lcd_s_command(current);
367
-      break;
368
-    case 'J':
369
-      process_lcd_j_command(current);
370
-      break;
371
-    case 'P':
372
-      process_lcd_p_command(current);
373
-      break;
374
-    case 'C':
375
-      process_lcd_c_command(current);
376
-      break;
377
-    case 'B':
378
-    case 'E':
379
-      process_lcd_eb_command(current);
380
-      break;
381
-    default:
382
-      SERIAL_ECHOLNPAIR("UNKNOWN COMMAND", command);
383
-      return;
335
+  if (*current == ':') {
336
+
337
+    current++; // skip the :
338
+
339
+    switch (command_code) {
340
+      case 'S': process_lcd_s_command(current); break;
341
+      case 'J': process_lcd_j_command(current); break;
342
+      case 'P': process_lcd_p_command(current); break;
343
+      case 'C': process_lcd_c_command(current); break;
344
+      case 'B':
345
+      case 'E': process_lcd_eb_command(current); break;
346
+      default: DEBUG_ECHOLNPAIR("UNKNOWN COMMAND ", command);
347
+    }
384 348
   }
349
+  else
350
+    DEBUG_ECHOLNPAIR("UNKNOWN COMMAND FORMAT ", command);
385 351
 }
386 352
 
387 353
 /**
@@ -405,8 +371,7 @@ namespace ExtUI {
405 371
     /**
406 372
      * The Malyan LCD actually runs as a separate MCU on Serial 1.
407 373
      * This code's job is to siphon the weird curly-brace commands from
408
-     * it and translate into gcode, which then gets injected into
409
-     * the command queue where possible.
374
+     * it and translate into ExtUI operations where possible.
410 375
      */
411 376
     inbound_count = 0;
412 377
     LCD_SERIAL.begin(500000);
@@ -455,13 +420,13 @@ namespace ExtUI {
455 420
       // If there was a print in progress, we need to emit the final
456 421
       // print status as {TQ:100}. Reset last percent done so a new print will
457 422
       // issue a percent of 0.
458
-      const uint8_t percent_done = IS_SD_PRINTING() ? card.percentDone() : last_printing_status ? 100 : 0;
423
+      const uint8_t percent_done = (ExtUI::isPrinting() || ExtUI::isPrintingFromMediaPaused()) ? ExtUI::getProgress_percent() : last_printing_status ? 100 : 0;
459 424
       if (percent_done != last_percent_done) {
460 425
         char message_buffer[16];
461 426
         sprintf_P(message_buffer, PSTR("{TQ:%03i}"), percent_done);
462 427
         write_to_lcd(message_buffer);
463 428
         last_percent_done = percent_done;
464
-        last_printing_status = IS_SD_PRINTING();
429
+        last_printing_status = ExtUI::isPrinting();
465 430
       }
466 431
     #endif
467 432
   }

+ 1
- 10
config/examples/Malyan/M200/Configuration.h Bestand weergeven

@@ -2030,7 +2030,7 @@
2030 2030
 //
2031 2031
 // Touch-screen LCD for Malyan M200 printers
2032 2032
 //
2033
-//#define MALYAN_LCD
2033
+#define MALYAN_LCD
2034 2034
 
2035 2035
 //
2036 2036
 // LulzBot Color Touch UI for FTDI EVE (FT800/FT810) displays
@@ -2058,15 +2058,6 @@
2058 2058
 //=============================================================================
2059 2059
 
2060 2060
 //
2061
-// CONTROLLER TYPE: Standalone / Serial
2062
-//
2063
-
2064
-//
2065
-// LCD for Malyan M200 printers.
2066
-//
2067
-#define MALYAN_LCD
2068
-
2069
-//
2070 2061
 // ADS7843/XPT2046 ADC Touchscreen such as ILI9341 2.8
2071 2062
 //
2072 2063
 //#define TOUCH_BUTTONS

+ 33
- 0
config/examples/Malyan/M200/README.md Bestand weergeven

@@ -0,0 +1,33 @@
1
+### Malyan M200 Build Instructions
2
+
3
+Malyan M200 series firmware currently builds using the Arduino IDE. These instructions should 
4
+guide you through the configuration and compilation.
5
+
6
+1. Install the Arduino IDE from your favorite source (arduino.cc, windows store, app store)
7
+2. Launch the IDE to add the ST boards manager:
8
+   - Open the **Preferences** dialog.
9
+   - Add this link in the "*Additional Boards Managers URLs*" field:
10
+      https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json
11
+   - Select "**Show verbose ouptut during: compilation**."
12
+3. Select **Tools** > **Board** > **Boards Manager**.
13
+4. Type "Malyan" into the Search field.
14
+5. The only board listed will be "**STM32 Cores by STMicroelectronics**." Any version from 1.6.0 up is fine. Choose install. This will download many tools and packages, be patient.
15
+6. Open the **Tools** > **Board** submenu, scroll all the way down, and select **3D Printer Boards**.
16
+7. From the **Tools** menu, select a board part number:
17
+   - If you own a M200 V1 or early run (black V2), choose **Malyan M200 V1**.
18
+   - If you own a M200 V2 later run (white/black) or V3 (Pro), choose **Malyan M200 V2** (The V2 and V3 both share an STM32F070 MCU). Note that the V3 pinout is not complete (autolevel doesn't work as of this writing).
19
+8. From the **Tools** menu, choose **USB Support** > **CDC No Generic Serial**.
20
+9. Download the latest Marlin source (from the [bugfix-2.0.x](https://github.com/MarlinFirmware/Marlin/tree/bugfix-2.0.x) branch) and unzip it.
21
+10. Look in the `Marlin` subdirectory for the `Configuration.h` and `Configuration_adv.h` files. Replace these files with the configurations in the `config\examples\Malyan\M200` folder.
22
+11. If you have an early-run V2, the steps-per-mm are roughly half. Consult the [mpminipro.com wiki](https://mpminipro.com/) for the steps that apply to your unit. Modify `Configuration.h`.
23
+12. Inverting Axis. There's no pattern to axes will need to be inverted. The only way to know is to test your particular printer. If you *do* know, go ahead and invert the correct axes.
24
+13. Open the `Marlin/Marlin.ino` file in Arduino IDE.
25
+14. From the **Sketch** menu, select **File** > **Export Compiled Binary**.
26
+15. When compilation is done you've built the firmware. The next stage is to flash it to the board. To do this look for a line like this: `"path/to/bin/arm-none-eabi-objcopy" -O binary "/path/to/Marlin.ino.elf" "/path/to/Marlin.ino.bin"`
27
+  The file `Marlin.ino.bin` is your firmware binary. M200 (v1-3) and M300 printers require flashing via SD card. Use the SD card that came with the printer if possible. The bootloader is very picky about SD cards. Copy `Marlin.ino.bin` to your SD card under three names: `firmware.bin`, `update.bin`, and `fcupdate.flg`.
28
+16. Insert the SD card into your printer. Make sure the X and Y axes are centered in the middle of the bed. (When X and Y endstops are closed this signals a UI upgrade to the bootloader.)
29
+17. Power-cycle the printer. The first flash may take longer. Don't be surprised if the .99 version number doesn't show up until after the UI has launched the default screen.
30
+18. Remove the SD card and delete the `fcupdate.flg` file from the card to prevent an accidental re-flash. 
31
+19. Test the endstops and homing directions, run M303 PID autotune, and verify all features are working correctly.
32
+
33
+Welcome to Marlin 2.x...

Laden…
Annuleren
Opslaan