Improve Malyan M200 integration (#15462)
This commit is contained in:
		
							parent
							
								
									a1ad01e4ab
								
							
						
					
					
						commit
						fc6a0937b8
					
				| @ -117,17 +117,27 @@ void write_to_lcd(const char * const message) { | ||||
|  * the command portion begins after the : | ||||
|  */ | ||||
| void process_lcd_c_command(const char* command) { | ||||
|   const int target_val = command[1] ? atoi(command + 1) : -1; | ||||
|   if (target_val < 0) { | ||||
|     DEBUG_ECHOLNPAIR("UNKNOWN C COMMAND ", command); | ||||
|     return; | ||||
|   } | ||||
|   switch (command[0]) { | ||||
|     case 'C': // Cope with both V1 early rev and later LCDs.
 | ||||
|     case 'S': | ||||
|       feedrate_percentage = atoi(command + 1) * 10; | ||||
|       feedrate_percentage = target_val * 10; | ||||
|       LIMIT(feedrate_percentage, 10, 999); | ||||
|       break; | ||||
| 
 | ||||
|     case 'T': ExtUI::setTargetTemp_celsius(atoi(command + 1), ExtUI::extruder_t::E0); break; | ||||
|     case 'T': | ||||
|       // Sometimes the LCD will send commands to turn off both extruder and bed, though
 | ||||
|       // this should not happen since the printing screen is up. Better safe than sorry.
 | ||||
|       if (!print_job_timer.isRunning() || target_val > 0) | ||||
|         ExtUI::setTargetTemp_celsius(target_val, ExtUI::extruder_t::E0); | ||||
|       break; | ||||
| 
 | ||||
|     #if HAS_HEATED_BED | ||||
|       case 'P': ExtUI::setTargetTemp_celsius(atoi(command + 1), ExtUI::heater_t::BED); break; | ||||
|       case 'P': ExtUI::setTargetTemp_celsius(target_val, ExtUI::heater_t::BED); break; | ||||
|     #endif | ||||
| 
 | ||||
|     default: DEBUG_ECHOLNPAIR("UNKNOWN C COMMAND ", command); | ||||
| @ -143,6 +153,7 @@ void process_lcd_c_command(const char* command) { | ||||
|  */ | ||||
| void process_lcd_eb_command(const char* command) { | ||||
|   char elapsed_buffer[10]; | ||||
|   static uint8_t iteration = 0; | ||||
|   duration_t elapsed; | ||||
|   switch (command[0]) { | ||||
|     case '0': { | ||||
| @ -150,6 +161,13 @@ void process_lcd_eb_command(const char* command) { | ||||
|       sprintf_P(elapsed_buffer, PSTR("%02u%02u%02u"), uint16_t(elapsed.hour()), uint16_t(elapsed.minute()) % 60, uint16_t(elapsed.second()) % 60); | ||||
| 
 | ||||
|       char message_buffer[MAX_CURLY_COMMAND]; | ||||
|       uint8_t done_pct = print_job_timer.isRunning() ? (iteration * 10) : 100; | ||||
|       iteration = (iteration + 1) % 10; // Provide progress animation
 | ||||
|       #if ENABLED(SDSUPPORT) | ||||
|         if (ExtUI::isPrintingFromMedia() || ExtUI::isPrintingFromMediaPaused()) | ||||
|           done_pct = card.percentDone(); | ||||
|       #endif | ||||
| 
 | ||||
|       sprintf_P(message_buffer, | ||||
|         PSTR("{T0:%03i/%03i}{T1:000/000}{TP:%03i/%03i}{TQ:%03i}{TT:%s}"), | ||||
|         int(thermalManager.degHotend(0)), thermalManager.degTargetHotend(0), | ||||
| @ -159,7 +177,7 @@ void process_lcd_eb_command(const char* command) { | ||||
|           0, 0, | ||||
|         #endif | ||||
|         #if ENABLED(SDSUPPORT) | ||||
|           card.percentDone(), | ||||
|           done_pct, | ||||
|         #else | ||||
|           0, | ||||
|         #endif | ||||
| @ -186,7 +204,7 @@ void process_lcd_j_command(const char* command) { | ||||
|   auto move_axis = [command](const auto axis) { | ||||
|     const float dist = atof(command + 1) / 10.0; | ||||
|     ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(axis) + dist, axis); | ||||
|   } | ||||
|   }; | ||||
| 
 | ||||
|   switch (command[0]) { | ||||
|     case 'E': break; | ||||
| @ -330,7 +348,6 @@ void process_lcd_s_command(const char* command) { | ||||
| void process_lcd_command(const char* command) { | ||||
|   const char *current = command; | ||||
| 
 | ||||
|   current++; // skip the leading {. The trailing one is already gone.
 | ||||
|   byte command_code = *current++; | ||||
|   if (*current == ':') { | ||||
| 
 | ||||
| @ -350,6 +367,31 @@ void process_lcd_command(const char* command) { | ||||
|     DEBUG_ECHOLNPAIR("UNKNOWN COMMAND FORMAT ", command); | ||||
| } | ||||
| 
 | ||||
| // Parse LCD commands mixed with G-Code
 | ||||
| void parse_lcd_byte(byte b) { | ||||
|   static bool parsing_lcd_cmd = false; | ||||
|   static char inbound_buffer[MAX_CURLY_COMMAND]; | ||||
| 
 | ||||
|   if (!parsing_lcd_cmd) { | ||||
|     if (b == '{' || b == '\n' || b == '\r') {   // A line-ending or opening brace
 | ||||
|       parsing_lcd_cmd = b == '{';               // Brace opens an LCD command
 | ||||
|       if (inbound_count) {                      // Looks like a G-code is in the buffer
 | ||||
|         inbound_buffer[inbound_count] = '\0';   // Reset before processing
 | ||||
|         inbound_count = 0; | ||||
|         queue.enqueue_one_now(inbound_buffer);  // Handle the G-code command
 | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   else if (b == '}') {                          // Closing brace on an LCD command
 | ||||
|     parsing_lcd_cmd = false;                    // Unflag and...
 | ||||
|     inbound_buffer[inbound_count] = '\0';       // reset before processing
 | ||||
|     inbound_count = 0; | ||||
|     process_lcd_command(inbound_buffer);        // Handle the LCD command
 | ||||
|   } | ||||
|   else if (inbound_count < MAX_CURLY_COMMAND - 2) | ||||
|     inbound_buffer[inbound_count++] = b;        // Buffer only if space remains
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  * UC means connected. | ||||
|  * UD means disconnected | ||||
| @ -360,8 +402,8 @@ void update_usb_status(const bool forceUpdate) { | ||||
|   // This is mildly different than stock, which
 | ||||
|   // appears to use the usb discovery status.
 | ||||
|   // This is more logical.
 | ||||
|   if (last_usb_connected_status != Serial || forceUpdate) { | ||||
|     last_usb_connected_status = Serial; | ||||
|   if (last_usb_connected_status != SerialUSB || forceUpdate) { | ||||
|     last_usb_connected_status = SerialUSB; | ||||
|     write_to_lcd_P(last_usb_connected_status ? PSTR("{R:UC}\r\n") : PSTR("{R:UD}\r\n")); | ||||
|   } | ||||
| } | ||||
| @ -391,24 +433,14 @@ namespace ExtUI { | ||||
|     /**
 | ||||
|      * - from printer on startup: | ||||
|      * {SYS:STARTED}{VER:29}{SYS:STARTED}{R:UD} | ||||
|      * The optimize attribute fixes a register Compile | ||||
|      * error for amtel. | ||||
|      */ | ||||
|     static char inbound_buffer[MAX_CURLY_COMMAND]; | ||||
| 
 | ||||
|     // First report USB status.
 | ||||
|     update_usb_status(false); | ||||
| 
 | ||||
|     // now drain commands...
 | ||||
|     while (LCD_SERIAL.available()) { | ||||
|       const byte b = (byte)LCD_SERIAL.read() & 0x7F; | ||||
|       inbound_buffer[inbound_count++] = b; | ||||
|       if (b == '}' || inbound_count == sizeof(inbound_buffer) - 1) { | ||||
|         inbound_buffer[inbound_count - 1] = '\0'; | ||||
|         process_lcd_command(inbound_buffer); | ||||
|         inbound_count = 0; | ||||
|         inbound_buffer[0] = 0; | ||||
|       } | ||||
|       parse_lcd_byte((byte)LCD_SERIAL.read() & 0x7F); | ||||
|     } | ||||
| 
 | ||||
|     #if ENABLED(SDSUPPORT) | ||||
| @ -438,22 +470,23 @@ namespace ExtUI { | ||||
|     write_to_lcd_P("}"); | ||||
|   } | ||||
| 
 | ||||
|   void onPrintTimerStarted() { write_to_lcd_P(PSTR("{SYS:BUILD}")); } | ||||
|   void onPrintTimerPaused() {} | ||||
|   void onPrintTimerStopped() { write_to_lcd_P(PSTR("{TQ:100}")); } | ||||
| 
 | ||||
|   // Not needed for Malyan LCD
 | ||||
|   void onStatusChanged(const char * const msg) { UNUSED(msg); } | ||||
|   void onStatusChanged(const char * const) {} | ||||
|   void onMediaInserted() {}; | ||||
|   void onMediaError() {}; | ||||
|   void onMediaRemoved() {}; | ||||
|   void onPlayTone(const uint16_t frequency, const uint16_t duration) { UNUSED(frequency); UNUSED(duration); } | ||||
|   void onPrintTimerStarted() {} | ||||
|   void onPrintTimerPaused() {} | ||||
|   void onPrintTimerStopped() {} | ||||
|   void onPlayTone(const uint16_t, const uint16_t) {} | ||||
|   void onFilamentRunout(const extruder_t extruder) {} | ||||
|   void onUserConfirmRequired(const char * const msg) { UNUSED(msg); } | ||||
|   void onUserConfirmRequired(const char * const) {} | ||||
|   void onFactoryReset() {} | ||||
|   void onStoreSettings(char *buff) { UNUSED(buff); } | ||||
|   void onLoadSettings(const char *buff) { UNUSED(buff); } | ||||
|   void onConfigurationStoreWritten(bool success) { UNUSED(success); } | ||||
|   void onConfigurationStoreRead(bool success) { UNUSED(success); } | ||||
|   void onStoreSettings(char*) {} | ||||
|   void onLoadSettings(const char*) {} | ||||
|   void onConfigurationStoreWritten(bool) {} | ||||
|   void onConfigurationStoreRead(bool) {} | ||||
| } | ||||
| 
 | ||||
| #endif // MALYAN_LCD
 | ||||
|  | ||||
| @ -42,6 +42,8 @@ | ||||
| // On STM32F103:
 | ||||
| // PB3, PB6, PB7, and PB8 can be used with pwm, which rules out TIM2 and TIM4.
 | ||||
| // On STM32F070, 16 and 17 are in use, but 1 and 3 are available.
 | ||||
| #undef STEP_TIMER | ||||
| #undef TEMP_TIMER | ||||
| #define STEP_TIMER 1 | ||||
| #define TEMP_TIMER 3 | ||||
| 
 | ||||
| @ -84,15 +86,7 @@ | ||||
| #define HEATER_0_PIN       PB6   // HOTEND0 MOSFET
 | ||||
| #define HEATER_BED_PIN     PB7   // BED MOSFET
 | ||||
| 
 | ||||
| // FAN_PIN is commented out here because the M200 example
 | ||||
| // Configuration_adv.h does NOT override E0_AUTO_FAN_PIN.
 | ||||
| #ifndef FAN_PIN | ||||
|   //#define FAN_PIN        PB8   // FAN1 header on board - PRINT FAN
 | ||||
| #endif | ||||
| #define FAN1_PIN           PB3   // FAN2 header on board - CONTROLLER FAN
 | ||||
| #define FAN2_PIN           -1    // FAN3 header on board - EXTRUDER0 FAN
 | ||||
| #define MALYAN_FAN1_PIN    PB8   // FAN1 header on board - PRINT FAN
 | ||||
| #define MALYAN_FAN2_PIN    PB3   // FAN2 header on board - CONTROLLER FAN
 | ||||
| 
 | ||||
| // This board has only the controller fan and the extruder fan
 | ||||
| // If someone hacks to put a direct power fan on the controller, PB3 could
 | ||||
| // be used as a separate print cooling fan.
 | ||||
| #define ORIG_E0_AUTO_FAN_PIN PB8 | ||||
| #define FAN1_PIN           MALYAN_FAN2_PIN | ||||
|  | ||||
| @ -146,7 +146,7 @@ | ||||
| #define EXTRUDERS 1 | ||||
| 
 | ||||
| // Generally expected filament diameter (1.75, 2.85, 3.0, ...). Used for Volumetric, Filament Width Sensor, etc.
 | ||||
| #define DEFAULT_NOMINAL_FILAMENT_DIA 3.0 | ||||
| #define DEFAULT_NOMINAL_FILAMENT_DIA 1.75 | ||||
| 
 | ||||
| // For Cyclops or any "multi-extruder" that shares a single nozzle.
 | ||||
| //#define SINGLENOZZLE
 | ||||
| @ -474,9 +474,10 @@ | ||||
|   // If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
 | ||||
| 
 | ||||
|   // Ultimaker
 | ||||
|   #define DEFAULT_Kp 26.15 | ||||
|   #define DEFAULT_Ki 2.74 | ||||
|   #define DEFAULT_Kd 62.35 | ||||
|   //#define DEFAULT_Kp 26.15
 | ||||
|   //#define DEFAULT_Ki 2.74
 | ||||
|   //#define DEFAULT_Kd 62.35
 | ||||
| 
 | ||||
|   // MakerGear
 | ||||
|   //#define DEFAULT_Kp 7.0
 | ||||
|   //#define DEFAULT_Ki 0.1
 | ||||
| @ -487,6 +488,11 @@ | ||||
|   //#define DEFAULT_Ki 2.25
 | ||||
|   //#define DEFAULT_Kd 440
 | ||||
| 
 | ||||
|   // Malyan M200
 | ||||
|   #define DEFAULT_Kp 20.0 | ||||
|   #define DEFAULT_Ki 2.02 | ||||
|   #define DEFAULT_Kd 100.00 | ||||
| 
 | ||||
| #endif // PIDTEMP
 | ||||
| 
 | ||||
| //===========================================================================
 | ||||
| @ -506,7 +512,7 @@ | ||||
|  * heater. If your configuration is significantly different than this and you don't understand | ||||
|  * the issues involved, don't use bed PID until someone else verifies that your hardware works. | ||||
|  */ | ||||
| //#define PIDTEMPBED
 | ||||
| #define PIDTEMPBED | ||||
| 
 | ||||
| //#define BED_LIMIT_SWITCHING
 | ||||
| 
 | ||||
| @ -524,9 +530,9 @@ | ||||
| 
 | ||||
|   //120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
 | ||||
|   //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
 | ||||
|   #define DEFAULT_bedKp 231.09 | ||||
|   #define DEFAULT_bedKi 45.21 | ||||
|   #define DEFAULT_bedKd 295.34 | ||||
|   //#define DEFAULT_bedKp 231.09
 | ||||
|   //#define DEFAULT_bedKi 45.21
 | ||||
|   //#define DEFAULT_bedKd 295.34
 | ||||
| 
 | ||||
|   //120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
 | ||||
|   //from pidautotune
 | ||||
| @ -534,6 +540,11 @@ | ||||
|   //#define DEFAULT_bedKi 1.41
 | ||||
|   //#define DEFAULT_bedKd 1675.16
 | ||||
| 
 | ||||
|   // Malyan M200
 | ||||
|   #define DEFAULT_bedKp 14.00 | ||||
|   #define DEFAULT_bedKi 0.9 | ||||
|   #define DEFAULT_bedKd 120.4 | ||||
| 
 | ||||
|   // FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
 | ||||
| #endif // PIDTEMPBED
 | ||||
| 
 | ||||
| @ -1051,8 +1062,8 @@ | ||||
| // @section machine
 | ||||
| 
 | ||||
| // The size of the print bed
 | ||||
| #define X_BED_SIZE 200 | ||||
| #define Y_BED_SIZE 200 | ||||
| #define X_BED_SIZE 120 | ||||
| #define Y_BED_SIZE 120 | ||||
| 
 | ||||
| // Travel limits (mm) after homing, corresponding to endstop positions.
 | ||||
| #define X_MIN_POS 0 | ||||
| @ -1060,7 +1071,7 @@ | ||||
| #define Z_MIN_POS 0 | ||||
| #define X_MAX_POS X_BED_SIZE | ||||
| #define Y_MAX_POS Y_BED_SIZE | ||||
| #define Z_MAX_POS 200 | ||||
| #define Z_MAX_POS 120 | ||||
| 
 | ||||
| /**
 | ||||
|  * Software Endstops | ||||
| @ -1278,7 +1289,7 @@ | ||||
| #endif | ||||
| 
 | ||||
| // Add a menu item to move between bed corners for manual bed adjustment
 | ||||
| #define LEVEL_BED_CORNERS | ||||
| //#define LEVEL_BED_CORNERS
 | ||||
| 
 | ||||
| #if ENABLED(LEVEL_BED_CORNERS) | ||||
|   #define LEVEL_CORNERS_INSET 30    // (mm) An inset for corner leveling
 | ||||
| @ -1627,7 +1638,7 @@ | ||||
|  */ | ||||
| //#define SPI_SPEED SPI_HALF_SPEED
 | ||||
| //#define SPI_SPEED SPI_QUARTER_SPEED
 | ||||
| #define SPI_SPEED SPI_EIGHTH_SPEED | ||||
| //#define SPI_SPEED SPI_EIGHTH_SPEED
 | ||||
| 
 | ||||
| /**
 | ||||
|  * SD CARD: ENABLE CRC | ||||
|  | ||||
| @ -277,9 +277,9 @@ | ||||
|  * The fan will turn on automatically whenever any stepper is enabled | ||||
|  * and turn off after a set period after all steppers are turned off. | ||||
|  */ | ||||
| //#define USE_CONTROLLER_FAN
 | ||||
| #define USE_CONTROLLER_FAN // Malyan M200: uncomment if you use FAN2 to cool the board (original)
 | ||||
| #if ENABLED(USE_CONTROLLER_FAN) | ||||
|   //#define CONTROLLER_FAN_PIN -1           // Set a custom pin for the controller fan
 | ||||
|   #define CONTROLLER_FAN_PIN MALYAN_FAN2_PIN     // Set a custom pin for the controller fan
 | ||||
|   #define CONTROLLERFAN_SECS 60             // Duration in seconds for the fan to run after all motors are disabled
 | ||||
|   #define CONTROLLERFAN_SPEED 255           // 255 == full speed
 | ||||
|   //#define CONTROLLERFAN_SPEED_Z_ONLY 127  // Reduce noise on machines that keep Z enabled
 | ||||
| @ -346,7 +346,9 @@ | ||||
|  * Multiple extruders can be assigned to the same pin in which case | ||||
|  * the fan will turn on when any selected extruder is above the threshold. | ||||
|  */ | ||||
| //#define E0_AUTO_FAN_PIN -1
 | ||||
| //#define FAN_PIN MALYAN_FAN1_PIN // Malyan M200: uncomment if you use FAN1 to cool the part and FAN2 to cool the extruder
 | ||||
| //#define E0_AUTO_FAN_PIN MALYAN_FAN2_PIN // Malyan M200: uncomment if you use FAN1 to cool the part and FAN2 to cool the extruder
 | ||||
| #define E0_AUTO_FAN_PIN MALYAN_FAN1_PIN // Malyan M200: uncomment if you use FAN1 to cool the extruder and the part (original)
 | ||||
| #define E1_AUTO_FAN_PIN -1 | ||||
| #define E2_AUTO_FAN_PIN -1 | ||||
| #define E3_AUTO_FAN_PIN -1 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user