Browse Source

Add files via upload

MRprusa3d 6 years ago
parent
commit
0b6644915a
9 changed files with 259 additions and 194 deletions
  1. 0 1
      Firmware/Marlin.h
  2. 181 118
      Firmware/Marlin_main.cpp
  3. 6 6
      Firmware/pins.h
  4. 5 0
      Firmware/pins_Rambo_1_3.h
  5. 10 10
      Firmware/sm4.c
  6. 3 4
      Firmware/stepper.cpp
  7. 39 50
      Firmware/ultralcd.cpp
  8. 11 1
      Firmware/ultralcd.h
  9. 4 4
      Firmware/xyzcal.cpp

+ 0 - 1
Firmware/Marlin.h

@@ -441,5 +441,4 @@ void gcode_M701();
 
 #define UVLO !(PINE & (1<<4))
 
-void extr_unload2();
 void proc_commands();

+ 181 - 118
Firmware/Marlin_main.cpp

@@ -232,6 +232,8 @@
 // M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
 // M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
 // M605 - Set dual x-carriage movement mode: S<mode> [ X<duplication x-offset> R<duplication temp offset> ]
+// M860 - Wait for PINDA thermistor to reach target temperature.
+// M861 - Set / Read PINDA temperature compensation offsets
 // M900 - Set LIN_ADVANCE options, if enabled. See Configuration_adv.h for details.
 // M907 - Set digital trimpot motor current using axis codes.
 // M908 - Control digital trimpot directly.
@@ -1268,14 +1270,14 @@ void setup()
 	if (eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA) == 255) {
 		//eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0);
 		eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1);
-		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 0,   8); //40C -  20um -   8usteps
-		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 1,  24); //45C -  60um -  24usteps
-		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 2,  48); //50C - 120um -  48usteps
-		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 3,  80); //55C - 200um -  80usteps
-		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 4, 120); //60C - 300um - 120usteps
+		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 0, 0); //40C
+		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 1, 0); //45C
+		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 2, 0); //50C
+		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 3, 0); //55C
+		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 4, 0); //60C
 
-		eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 1);
-		temp_cal_active = true;
+		eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0);
+		temp_cal_active = false;
 	}
 	if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 255) {
 		eeprom_write_byte((uint8_t*)EEPROM_UVLO, 0);
@@ -2505,6 +2507,52 @@ void gcode_M701()
 #endif
 
 }
+/**
+ * @brief Get serial number from 32U2 processor
+ *
+ * Typical format of S/N is:CZPX0917X003XC13518
+ *
+ * Command operates only in farm mode, if not in farm mode, "Not in farm mode." is written to MYSERIAL.
+ *
+ * Send command ;S to serial port 0 to retrieve serial number stored in 32U2 processor,
+ * reply is transmitted to serial port 1 character by character.
+ * Operation takes typically 23 ms. If the retransmit is not finished until 100 ms,
+ * it is interrupted, so less, or no characters are retransmitted, only newline character is send
+ * in any case.
+ */
+static void gcode_PRUSA_SN()
+{
+    if (farm_mode) {
+        selectedSerialPort = 0;
+        MSerial.write(";S");
+        int numbersRead = 0;
+        Timer timeout;
+        timeout.start();
+
+        while (numbersRead < 19) {
+            while (MSerial.available() > 0) {
+                uint8_t serial_char = MSerial.read();
+                selectedSerialPort = 1;
+                MSerial.write(serial_char);
+                numbersRead++;
+                selectedSerialPort = 0;
+            }
+            if (timeout.expired(100)) break;
+        }
+        selectedSerialPort = 1;
+        MSerial.write('\n');
+#if 0
+        for (int b = 0; b < 3; b++) {
+            tone(BEEPER, 110);
+            delay(50);
+            noTone(BEEPER);
+            delay(50);
+        }
+#endif
+    } else {
+        MYSERIAL.println("Not in farm mode.");
+    }
+}
 
 void process_commands()
 {
@@ -2544,7 +2592,7 @@ void process_commands()
 	  lcd_setstatus(strchr_pointer + 5);
   }
 
-//#ifdef TMC2130
+#ifdef TMC2130
 	else if (strncmp_P(CMDBUFFER_CURRENT_STRING, PSTR("CRASH_"), 6) == 0)
 	{
 	  if(code_seen("CRASH_DETECTED"))
@@ -2573,7 +2621,7 @@ void process_commands()
 			tmc2130_goto_step(E_AXIS, step & (4*res - 1), 2, 1000, res);
 		}
 	}
-//#endif //TMC2130
+#endif //TMC2130
 
   else if(code_seen("PRUSA")){
 		if (code_seen("Ping")) {  //PRUSA Ping
@@ -2624,33 +2672,7 @@ void process_commands()
         prusa_sd_card_upload = true;
         card.openFile(strchr_pointer+4,false);
 	} else if (code_seen("SN")) { 
-        if (farm_mode) { 
-            selectedSerialPort = 0; 
-            MSerial.write(";S"); 
-            // S/N is:CZPX0917X003XC13518 
-            int numbersRead = 0; 
- 
-            while (numbersRead < 19) { 
-                while (MSerial.available() > 0) { 
-                    uint8_t serial_char = MSerial.read(); 
-                    selectedSerialPort = 1; 
-                    MSerial.write(serial_char); 
-                    numbersRead++; 
-                    selectedSerialPort = 0; 
-                } 
-            } 
-            selectedSerialPort = 1; 
-            MSerial.write('\n'); 
-            /*for (int b = 0; b < 3; b++) { 
-                tone(BEEPER, 110); 
-                delay(50); 
-                noTone(BEEPER); 
-                delay(50); 
-            }*/ 
-        } else { 
-            MYSERIAL.println("Not in farm mode."); 
-        } 
-		
+        gcode_PRUSA_SN();
 	} else if(code_seen("Fir")){
 
       SERIAL_PROTOCOLLN(FW_VERSION);
@@ -3554,6 +3576,9 @@ void process_commands()
 			setTargetBed(0); //set bed target temperature back to 0
 //			setTargetHotend(0,0); //set hotend target temperature back to 0
 			lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CALIBRATION_DONE);
+			temp_cal_active = true;
+			eeprom_update_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE, 1);
+
 			lcd_update_enable(true);
 			lcd_update(2);
 			break;
@@ -3667,6 +3692,8 @@ void process_commands()
 			disable_e2();
 			setTargetBed(0); //set bed target temperature back to 0
 		lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CALIBRATION_DONE);
+		temp_cal_active = true;
+		eeprom_update_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE, 1);
 		lcd_update_enable(true);
 		lcd_update(2);		
 
@@ -5982,7 +6009,7 @@ Sigma_Exit:
             tmc2130_set_current_r(E_AXIS, tmc2130_current_r_bckp);
 #else
 			uint8_t silentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
-			if(silentMode) st_current_set(2, tmp_motor[2]); //set E back to normal operation currents
+			if(silentMode != SILENT_MODE_NORMAL) st_current_set(2, tmp_motor[2]); //set E back to normal operation currents
 			else st_current_set(2, tmp_motor_loud[2]);		
 #endif //TMC2130
 
@@ -6221,6 +6248,117 @@ Sigma_Exit:
 	}
 	break;
 
+#ifdef PINDA_THERMISTOR
+	case 860: // M860 - Wait for PINDA thermistor to reach target temperature.
+	{
+		int setTargetPinda = 0;
+
+		if (code_seen('S')) {
+			setTargetPinda = code_value();
+		}
+		else {
+			break;
+		}
+
+		LCD_MESSAGERPGM(MSG_PLEASE_WAIT);
+
+		SERIAL_PROTOCOLPGM("Wait for PINDA target temperature:");
+		SERIAL_PROTOCOL(setTargetPinda);
+		SERIAL_PROTOCOLLN("");
+
+		codenum = millis();
+		cancel_heatup = false;
+
+		KEEPALIVE_STATE(NOT_BUSY);
+
+		while ((!cancel_heatup) && current_temperature_pinda < setTargetPinda) {
+			if ((millis() - codenum) > 1000) //Print Temp Reading every 1 second while waiting.
+			{
+				SERIAL_PROTOCOLPGM("P:");
+				SERIAL_PROTOCOL_F(current_temperature_pinda, 1);
+				SERIAL_PROTOCOLPGM("/");
+				SERIAL_PROTOCOL(setTargetPinda);
+				SERIAL_PROTOCOLLN("");
+				codenum = millis();
+			}
+			manage_heater();
+			manage_inactivity();
+			lcd_update();
+		}
+		LCD_MESSAGERPGM(MSG_OK);
+
+		break;
+	}
+	case 861: // M861 - Set/Read PINDA temperature compensation offsets
+		if (code_seen('?')) { // ? - Print out current EEPRO offset values
+			uint8_t cal_status = calibration_status_pinda();
+			cal_status ? SERIAL_PROTOCOLLN("PINDA cal status: 1") : SERIAL_PROTOCOLLN("PINDA cal status: 0");
+			SERIAL_PROTOCOLLN("index, temp, ustep, um");
+			for (uint8_t i = 0; i < 6; i++)
+			{
+				uint16_t usteps = 0;
+				if (i > 0) usteps = eeprom_read_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + (i - 1));
+				float mm = ((float)usteps) / axis_steps_per_unit[Z_AXIS];
+				i == 0 ? SERIAL_PROTOCOLPGM("n/a") : SERIAL_PROTOCOL(i - 1);
+				SERIAL_PROTOCOLPGM(", ");
+				SERIAL_PROTOCOL(35 + (i * 5));
+				SERIAL_PROTOCOLPGM(", ");
+				SERIAL_PROTOCOL(usteps);
+				SERIAL_PROTOCOLPGM(", ");
+				SERIAL_PROTOCOL(mm * 1000);
+				SERIAL_PROTOCOLLN("");
+			}
+		}
+		else if (code_seen('!')) { // ! - Set factory default values
+			eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1);
+			eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 0, 8); //40C -  20um -   8usteps
+			eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 1, 24); //45C -  60um -  24usteps
+			eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 2, 48); //50C - 120um -  48usteps
+			eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 3, 80); //55C - 200um -  80usteps
+			eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 4, 120); //60C - 300um - 120usteps
+			SERIAL_PROTOCOLLN("factory restored");
+		}
+		else if (code_seen('Z')) { // Z - Set all values to 0 (effectively disabling PINDA temperature compensation)
+			eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1);
+			eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 0, 0);
+			eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 1, 0);
+			eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 2, 0);
+			eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 3, 0);
+			eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 4, 0);
+			SERIAL_PROTOCOLLN("zerorized");
+		}
+		else if (code_seen('S')) { // Sxxx Iyyy - Set compensation ustep value S for compensation table index I
+			uint16_t usteps = code_value();
+			if (code_seen('I')) {
+				byte index = code_value();
+				if ((index >= 0) && (index < 5)) {
+					eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + index, usteps);
+					SERIAL_PROTOCOLLN("OK");
+					SERIAL_PROTOCOLLN("index, temp, ustep, um");
+					for (uint8_t i = 0; i < 6; i++)
+					{
+						uint16_t usteps = 0;
+						if (i > 0) usteps = eeprom_read_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + (i - 1));
+						float mm = ((float)usteps) / axis_steps_per_unit[Z_AXIS];
+						i == 0 ? SERIAL_PROTOCOLPGM("n/a") : SERIAL_PROTOCOL(i - 1);
+						SERIAL_PROTOCOLPGM(", ");
+						SERIAL_PROTOCOL(35 + (i * 5));
+						SERIAL_PROTOCOLPGM(", ");
+						SERIAL_PROTOCOL(usteps);
+						SERIAL_PROTOCOLPGM(", ");
+						SERIAL_PROTOCOL(mm * 1000);
+						SERIAL_PROTOCOLLN("");
+					}
+				}
+			}
+		}
+		else {
+			SERIAL_PROTOCOLPGM("no valid command");
+		}
+		break;
+
+#endif //PINDA_THERMISTOR
+
 #ifdef LIN_ADVANCE
     case 900: // M900: Set LIN_ADVANCE options.
         gcode_M900();
@@ -6510,7 +6648,6 @@ Sigma_Exit:
 
 		  pinMode(E_MUX0_PIN, OUTPUT);
 		  pinMode(E_MUX1_PIN, OUTPUT);
-		  pinMode(E_MUX2_PIN, OUTPUT);
 
 		  delay(100);
 		  SERIAL_ECHO_START;
@@ -6520,25 +6657,21 @@ Sigma_Exit:
 		  case 1:
 			  WRITE(E_MUX0_PIN, HIGH);
 			  WRITE(E_MUX1_PIN, LOW);
-			  WRITE(E_MUX2_PIN, LOW);
 
 			  break;
 		  case 2:
 			  WRITE(E_MUX0_PIN, LOW);
 			  WRITE(E_MUX1_PIN, HIGH);
-			  WRITE(E_MUX2_PIN, LOW);
 
 			  break;
 		  case 3:
 			  WRITE(E_MUX0_PIN, HIGH);
 			  WRITE(E_MUX1_PIN, HIGH);
-			  WRITE(E_MUX2_PIN, LOW);
 
 			  break;
 		  default:
 			  WRITE(E_MUX0_PIN, LOW);
 			  WRITE(E_MUX1_PIN, LOW);
-			  WRITE(E_MUX2_PIN, LOW);
 
 			  break;
 		  }
@@ -6666,7 +6799,7 @@ void ClearToSend()
         SERIAL_PROTOCOLLNRPGM(MSG_OK);
 }
 
-#if MOTHERBOARD == 200 || MOTHERBOARD == 203
+#if MOTHERBOARD == BOARD_RAMBO_MINI_1_0 || MOTHERBOARD == BOARD_RAMBO_MINI_1_3
 void update_currents() {
 	float current_high[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD;
 	float current_low[3] = DEFAULT_PWM_MOTOR_CURRENT;
@@ -6703,7 +6836,7 @@ void update_currents() {
 		}
 	}
 }
-#endif //MOTHERBOARD == 200 || MOTHERBOARD == 203
+#endif //MOTHERBOARD == BOARD_RAMBO_MINI_1_0 || MOTHERBOARD == BOARD_RAMBO_MINI_1_3
 
 void get_coordinates()
 {
@@ -6726,9 +6859,9 @@ void get_coordinates()
       if (relative)
         destination[i] += current_position[i];
       seen[i]=true;
-#if MOTHERBOARD == 200 || MOTHERBOARD == 203
-	  if (i == Z_AXIS && SilentModeMenu == 2) update_currents();
-#endif //MOTHERBOARD == 200 || MOTHERBOARD == 203
+#if MOTHERBOARD == BOARD_RAMBO_MINI_1_0 || MOTHERBOARD == BOARD_RAMBO_MINI_1_3
+	  if (i == Z_AXIS && SilentModeMenu == SILENT_MODE_AUTO) update_currents();
+#endif //MOTHERBOARD == BOARD_RAMBO_MINI_1_0 || MOTHERBOARD == BOARD_RAMBO_MINI_1_3
     }
     else destination[i] = current_position[i]; //Are these else lines really needed?
   }
@@ -6964,7 +7097,7 @@ static void handleSafetyTimer()
     {
         safetyTimer.start();
     }
-    else if (safetyTimer.expired(15*60*1000))
+    else if (safetyTimer.expired(900000ul))
     {
         setTargetBed(0);
         setTargetHotend(0, 0);
@@ -8433,73 +8566,3 @@ void print_mesh_bed_leveling_table()
 
 
 #define FIL_LOAD_LENGTH 60
-
-void extr_unload2() { //unloads filament
-//	float tmp_motor[3] = DEFAULT_PWM_MOTOR_CURRENT;
-//	float tmp_motor_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD;
-//	int8_t SilentMode;
-	uint8_t snmm_extruder = 0;
-	if (degHotend0() > EXTRUDE_MINTEMP) {
-		lcd_implementation_clear();
-		lcd_display_message_fullscreen_P(PSTR(""));
-		max_feedrate[E_AXIS] = 50;
-		lcd.setCursor(0, 0); lcd_printPGM(MSG_UNLOADING_FILAMENT);
-//		lcd.print(" ");
-//		lcd.print(snmm_extruder + 1);
-		lcd.setCursor(0, 2); lcd_printPGM(MSG_PLEASE_WAIT);
-		if (current_position[Z_AXIS] < 15) {
-			current_position[Z_AXIS] += 15; //lifting in Z direction to make space for extrusion
-			plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 25, active_extruder);
-		}
-		
-		current_position[E_AXIS] += 10; //extrusion
-		plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 10, active_extruder);
-//		st_current_set(2, E_MOTOR_HIGH_CURRENT);
-		if (current_temperature[0] < 230) { //PLA & all other filaments
-			current_position[E_AXIS] += 5.4;
-			plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2800 / 60, active_extruder);
-			current_position[E_AXIS] += 3.2;
-			plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
-			current_position[E_AXIS] += 3;
-			plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3400 / 60, active_extruder);
-		}
-		else { //ABS
-			current_position[E_AXIS] += 3.1;
-			plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2000 / 60, active_extruder);
-			current_position[E_AXIS] += 3.1;
-			plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
-			current_position[E_AXIS] += 4;
-			plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
-			/*current_position[X_AXIS] += 23; //delay
-			plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay
-			current_position[X_AXIS] -= 23; //delay
-			plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay*/
-			delay_keep_alive(4700);
-		}
-	
-		max_feedrate[E_AXIS] = 80;
-		current_position[E_AXIS] -= (bowden_length[snmm_extruder] + 60 + FIL_LOAD_LENGTH) / 2;
-		plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
-		current_position[E_AXIS] -= (bowden_length[snmm_extruder] + 60 + FIL_LOAD_LENGTH) / 2;
-		plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
-		st_synchronize();
-		//st_current_init();
-//		if (SilentMode == 1) st_current_set(2, tmp_motor[2]); //set back to normal operation currents
-//		else st_current_set(2, tmp_motor_loud[2]);
-		lcd_update_enable(true);
-//		lcd_return_to_status();
-		max_feedrate[E_AXIS] = 50;
-	}
-	else {
-
-		lcd_implementation_clear();
-		lcd.setCursor(0, 0);
-		lcd_printPGM(MSG_ERROR);
-		lcd.setCursor(0, 2);
-		lcd_printPGM(MSG_PREHEAT_NOZZLE);
-
-		delay(2000);
-		lcd_implementation_clear();
-	}
-//	lcd_return_to_status();
-}

+ 6 - 6
Firmware/pins.h

@@ -23,17 +23,17 @@
 * Rambo Pin Assignments 1.3
 ******************************************************************/
 
-#if MOTHERBOARD == 200 //200 - orig 102
+#if MOTHERBOARD == BOARD_RAMBO_MINI_1_0 //200 - orig 102
 #include "pins_Rambo_1_0.h"
-#endif //MOTHERBOARD == 200
+#endif //MOTHERBOARD == BOARD_RAMBO_MINI_1_0
 
-#if MOTHERBOARD == 203 //203 - orig 302
+#if MOTHERBOARD == BOARD_RAMBO_MINI_1_3 //203 - orig 302
 #include "pins_Rambo_1_3.h"
-#endif //MOTHERBOARD == 203
+#endif //MOTHERBOARD == BOARD_RAMBO_MINI_1_3
 
-#if MOTHERBOARD == 310 //310 - new
+#if MOTHERBOARD == BOARD_EINSY_1_0a //310 - new
 #include "pins_Einsy_1_0.h"
-#endif //MOTHERBOARD == 310
+#endif //MOTHERBOARD == BOARD_EINSY_1_0a
 
 #ifndef KNOWN_BOARD
 #error Unknown MOTHERBOARD value in configuration.h

+ 5 - 0
Firmware/pins_Rambo_1_3.h

@@ -69,6 +69,11 @@
 #define E0_MS1_PIN             65
 #define E0_MS2_PIN             66
 
+#ifdef SNMM 
+  #define E_MUX0_PIN 17
+  #define E_MUX1_PIN 16
+#endif
+
 
 #define MOTOR_CURRENT_PWM_XY_PIN 46
 #define MOTOR_CURRENT_PWM_Z_PIN  45

+ 10 - 10
Firmware/sm4.c

@@ -48,12 +48,12 @@ uint8_t sm4_get_dir(uint8_t axis)
 {
 	switch (axis)
 	{
-#if ((MOTHERBOARD == 200) || (MOTHERBOARD == 203))
+#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
 	case 0: return (PORTL & 2)?0:1;
 	case 1: return (PORTL & 1)?0:1;
 	case 2: return (PORTL & 4)?0:1;
 	case 3: return (PORTL & 64)?1:0;
-#else if ((MOTHERBOARD == 310))
+#else if ((MOTHERBOARD == BOARD_EINSY_1_0a))
 	case 0: return (PORTL & 1)?1:0;
 	case 1: return (PORTL & 2)?0:1;
 	case 2: return (PORTL & 4)?1:0;
@@ -67,12 +67,12 @@ void sm4_set_dir(uint8_t axis, uint8_t dir)
 {
 	switch (axis)
 	{
-#if ((MOTHERBOARD == 200) || (MOTHERBOARD == 203))
+#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
 	case 0: if (!dir) PORTL |= 2; else PORTL &= ~2; break;
 	case 1: if (!dir) PORTL |= 1; else PORTL &= ~1; break;
 	case 2: if (!dir) PORTL |= 4; else PORTL &= ~4; break;
 	case 3: if (dir) PORTL |= 64; else PORTL &= ~64; break;
-#else if ((MOTHERBOARD == 310))
+#else if ((MOTHERBOARD == BOARD_EINSY_1_0a))
 	case 0: if (dir) PORTL |= 1; else PORTL &= ~1; break;
 	case 1: if (!dir) PORTL |= 2; else PORTL &= ~2; break;
 	case 2: if (dir) PORTL |= 4; else PORTL &= ~4; break;
@@ -87,13 +87,13 @@ uint8_t sm4_get_dir_bits(void)
 	uint8_t register dir_bits = 0;
 	uint8_t register portL = PORTL;
 	//TODO -optimize in asm
-#if ((MOTHERBOARD == 200) || (MOTHERBOARD == 203))
+#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
 	if (portL & 2) dir_bits |= 1;
 	if (portL & 1) dir_bits |= 2;
 	if (portL & 4) dir_bits |= 4;
 	if (portL & 64) dir_bits |= 8;
 	dir_bits ^= 0x07; //invert XYZ, do not invert E
-#else if ((MOTHERBOARD == 310))
+#else if ((MOTHERBOARD == BOARD_EINSY_1_0a))
 	if (portL & 1) dir_bits |= 1;
 	if (portL & 2) dir_bits |= 2;
 	if (portL & 4) dir_bits |= 4;
@@ -108,13 +108,13 @@ void sm4_set_dir_bits(uint8_t dir_bits)
 	uint8_t register portL = PORTL;
 	portL &= 0xb8; //set direction bits to zero
 	//TODO -optimize in asm
-#if ((MOTHERBOARD == 200) || (MOTHERBOARD == 203))
+#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
 	dir_bits ^= 0x07; //invert XYZ, do not invert E
 	if (dir_bits & 1) portL |= 2;  //set X direction bit
 	if (dir_bits & 2) portL |= 1;  //set Y direction bit
 	if (dir_bits & 4) portL |= 4;  //set Z direction bit
 	if (dir_bits & 8) portL |= 64; //set E direction bit
-#else if ((MOTHERBOARD == 310))
+#else if ((MOTHERBOARD == BOARD_EINSY_1_0a))
 	dir_bits ^= 0x0a; //invert YE, do not invert XZ
 	if (dir_bits & 1) portL |= 1;  //set X direction bit
 	if (dir_bits & 2) portL |= 2;  //set Y direction bit
@@ -127,13 +127,13 @@ void sm4_set_dir_bits(uint8_t dir_bits)
 
 void sm4_do_step(uint8_t axes_mask)
 {
-#if ((MOTHERBOARD == 200) || (MOTHERBOARD == 203) || (MOTHERBOARD == 310))
+#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3) || (MOTHERBOARD == BOARD_EINSY_1_0a))
 	uint8_t register portC = PORTC & 0xf0;
 	PORTC = portC | (axes_mask & 0x0f); //set step signals by mask
 	asm("nop");
 	PORTC = portC; //set step signals to zero
 	asm("nop");
-#endif //((MOTHERBOARD == 200) || (MOTHERBOARD == 203) || (MOTHERBOARD == 310))
+#endif //((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3) || (MOTHERBOARD == BOARD_EINSY_1_0a))
 }
 
 uint16_t sm4_line_xyze_ui(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de)

+ 3 - 4
Firmware/stepper.cpp

@@ -101,8 +101,6 @@ static bool check_endstops = true;
 static bool check_z_endstop = false;
 static bool z_endstop_invert = false;
 
-int8_t SilentMode = 0;
-
 volatile long count_position[NUM_AXIS] = { 0, 0, 0, 0};
 volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1};
 
@@ -1459,6 +1457,7 @@ void digitalPotWrite(int address, int value) // From Arduino DigitalPotControl e
   #endif
 }
 
+//*** MaR::180416_03
 void EEPROM_read_st(int pos, uint8_t* value, uint8_t size)
 {
     do
@@ -1472,13 +1471,13 @@ void EEPROM_read_st(int pos, uint8_t* value, uint8_t size)
 
 void st_current_init() //Initialize Digipot Motor Current
 {  
-  EEPROM_read_st(EEPROM_SILENT,(uint8_t*)&SilentMode,sizeof(SilentMode));
+uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
   SilentModeMenu = SilentMode;
   #ifdef MOTOR_CURRENT_PWM_XY_PIN
     pinMode(MOTOR_CURRENT_PWM_XY_PIN, OUTPUT);
     pinMode(MOTOR_CURRENT_PWM_Z_PIN, OUTPUT);
     pinMode(MOTOR_CURRENT_PWM_E_PIN, OUTPUT);
-    if((SilentMode == 0) || (farm_mode) ){
+    if((SilentMode == SILENT_MODE_OFF) || (farm_mode) ){
 
      motor_current_setting[0] = motor_current_setting_loud[0];
      motor_current_setting[1] = motor_current_setting_loud[1];

+ 39 - 50
Firmware/ultralcd.cpp

@@ -123,7 +123,7 @@ int8_t ReInitLCD = 0;
 
 int8_t SDscrool = 0;
 
-int8_t SilentModeMenu = 0;
+int8_t SilentModeMenu = SILENT_MODE_OFF;
 
 int8_t FSensorStateMenu = 1;
 
@@ -3466,10 +3466,7 @@ static void lcd_crash_mode_info()
 		tim = millis();
 	}
 	if (lcd_clicked())
-	{
-		if (IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL)) lcd_goto_menu(lcd_tune_menu, 18);
-		else lcd_goto_menu(lcd_settings_menu, 16, true, true);
-	}
+          menu_action_back();
 }
 
 static void lcd_crash_mode_info2()
@@ -3482,13 +3479,7 @@ static void lcd_crash_mode_info2()
 		tim = millis();
 	}
 	if (lcd_clicked())
-	{
-//-//		if (IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL)) lcd_goto_menu(lcd_tune_menu, 16);
-		if (IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL)) menu_action_back();
-//-//		else lcd_goto_menu(lcd_settings_menu, 14, true, true);
-//-//		else lcd_goto_menu(lcd_settings_menu, 7, true, true);
-		else menu_action_back();
-	}
+          menu_action_back();
 }
 #endif //TMC2130
 
@@ -3507,14 +3498,16 @@ static void lcd_fsensor_fail()
 
 static void lcd_silent_mode_set() {
 	switch (SilentModeMenu) {
-	case 0: SilentModeMenu = 1; break;
 #ifdef TMC2130
-	case 1: SilentModeMenu = 0; break;
+	case SILENT_MODE_NORMAL: SilentModeMenu = SILENT_MODE_STEALTH; break;
+	case SILENT_MODE_STEALTH: SilentModeMenu = SILENT_MODE_NORMAL; break;
+	default: SilentModeMenu = SILENT_MODE_NORMAL; break; // (probably) not needed
 #else
-	case 1: SilentModeMenu = 2; break;
-	case 2: SilentModeMenu = 0; break;
+	case SILENT_MODE_POWER: SilentModeMenu = SILENT_MODE_SILENT; break;
+	case SILENT_MODE_SILENT: SilentModeMenu = SILENT_MODE_AUTO; break;
+	case SILENT_MODE_AUTO: SilentModeMenu = SILENT_MODE_POWER; break;
+	default: SilentModeMenu = SILENT_MODE_POWER; break; // (probably) not needed
 #endif //TMC2130
-	default: SilentModeMenu = 0; break;
 	}
   eeprom_update_byte((unsigned char *)EEPROM_SILENT, SilentModeMenu);
 #ifdef TMC2130
@@ -3526,7 +3519,7 @@ static void lcd_silent_mode_set() {
 //  else
 //	  MYSERIAL.print("standstill NG!");
   cli();
-	tmc2130_mode = SilentModeMenu?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL;
+	tmc2130_mode = (SilentModeMenu != SILENT_MODE_NORMAL)?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL;
 	tmc2130_init();
   // We may have missed a stepper timer interrupt due to the time spent in tmc2130_init.
   // Be safe than sorry, reset the stepper timer before re-enabling interrupts.
@@ -3535,8 +3528,7 @@ static void lcd_silent_mode_set() {
 #endif //TMC2130
   st_current_init();
 #ifdef TMC2130
-  if (CrashDetectMenu && SilentModeMenu)
-//-//	  lcd_goto_menu(lcd_crash_mode_info2);
+  if (CrashDetectMenu && (SilentModeMenu != SILENT_MODE_NORMAL))
 	  menu_action_submenu(lcd_crash_mode_info2);
 #endif //TMC2130
 }
@@ -4000,10 +3992,10 @@ static void lcd_settings_menu()
 #ifndef TMC2130
   if (!farm_mode) { //dont show in menu if we are in farm mode
 	  switch (SilentModeMenu) {
-	  case 0: MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); break;
-	  case 1: MENU_ITEM(function, MSG_SILENT_MODE_ON, lcd_silent_mode_set); break;
-	  case 2: MENU_ITEM(function, MSG_AUTO_MODE_ON, lcd_silent_mode_set); break;
-	  default: MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); break;
+	  case SILENT_MODE_POWER: MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); break;
+	  case SILENT_MODE_SILENT: MENU_ITEM(function, MSG_SILENT_MODE_ON, lcd_silent_mode_set); break;
+	  case SILENT_MODE_AUTO: MENU_ITEM(function, MSG_AUTO_MODE_ON, lcd_silent_mode_set); break;
+	  default: MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); break; // (probably) not needed
 	  }
   }
 #endif //TMC2130
@@ -4044,9 +4036,10 @@ static void lcd_settings_menu()
   }
 
 #ifdef TMC2130
-  if (SilentModeMenu == 0) MENU_ITEM(function, MSG_STEALTH_MODE_OFF, lcd_silent_mode_set);
+//*** MaR::180416_01a
+  if (SilentModeMenu == SILENT_MODE_NORMAL) MENU_ITEM(function, MSG_STEALTH_MODE_OFF, lcd_silent_mode_set);
   else MENU_ITEM(function, MSG_STEALTH_MODE_ON, lcd_silent_mode_set);
-  if (SilentModeMenu == 0)
+  if (SilentModeMenu == SILENT_MODE_NORMAL)
   {
     if (CrashDetectMenu == 0) MENU_ITEM(function, MSG_CRASHDETECT_OFF, lcd_crash_mode_set);
     else MENU_ITEM(function, MSG_CRASHDETECT_ON, lcd_crash_mode_set);
@@ -4947,37 +4940,30 @@ void change_extr(int extr) { //switches multiplexer for extruders
 	disable_e1();
 	disable_e2();
 
-#ifdef SNMM
 	snmm_extruder = extr;
-#endif
 
 	pinMode(E_MUX0_PIN, OUTPUT);
 	pinMode(E_MUX1_PIN, OUTPUT);
-	pinMode(E_MUX2_PIN, OUTPUT);
 
 	switch (extr) {
 	case 1:
 		WRITE(E_MUX0_PIN, HIGH);
 		WRITE(E_MUX1_PIN, LOW);
-		WRITE(E_MUX2_PIN, LOW);
 		
 		break;
 	case 2:
 		WRITE(E_MUX0_PIN, LOW);
 		WRITE(E_MUX1_PIN, HIGH);
-		WRITE(E_MUX2_PIN, LOW);
 		
 		break;
 	case 3:
 		WRITE(E_MUX0_PIN, HIGH);
 		WRITE(E_MUX1_PIN, HIGH);
-		WRITE(E_MUX2_PIN, LOW);
 		
 		break;
 	default:
 		WRITE(E_MUX0_PIN, LOW);
 		WRITE(E_MUX1_PIN, LOW);
-		WRITE(E_MUX2_PIN, LOW);
 		
 		break;
 	}
@@ -4985,7 +4971,7 @@ void change_extr(int extr) { //switches multiplexer for extruders
 }
 
 static int get_ext_nr() { //reads multiplexer input pins and return current extruder number (counted from 0)
-	return(4 * READ(E_MUX2_PIN) + 2 * READ(E_MUX1_PIN) + READ(E_MUX0_PIN));
+	return(2 * READ(E_MUX1_PIN) + READ(E_MUX0_PIN));
 }
 
 
@@ -4998,7 +4984,7 @@ void display_loading() {
 	}
 }
 
-static void extr_adj(int extruder) //loading filament for SNMM
+void extr_adj(int extruder) //loading filament for SNMM
 {
 	bool correct;
 	max_feedrate[E_AXIS] =80;
@@ -5042,7 +5028,7 @@ static void extr_adj(int extruder) //loading filament for SNMM
 void extr_unload() { //unloads filament
 	float tmp_motor[3] = DEFAULT_PWM_MOTOR_CURRENT;
 	float tmp_motor_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD;
-	int8_t SilentMode;
+	uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
 
 	if (degHotend0() > EXTRUDE_MINTEMP) {
 		lcd_implementation_clear();
@@ -5089,7 +5075,7 @@ void extr_unload() { //unloads filament
 		plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
 		st_synchronize();
 		//st_current_init();
-		if (SilentMode == 1) st_current_set(2, tmp_motor[2]); //set back to normal operation currents
+		if (SilentMode != SILENT_MODE_OFF) st_current_set(2, tmp_motor[2]); //set back to normal operation currents
 		else st_current_set(2, tmp_motor_loud[2]);
 		lcd_update_enable(true);
 		lcd_return_to_status();
@@ -5708,18 +5694,19 @@ static void lcd_autostart_sd()
 
 static void lcd_silent_mode_set_tune() {
   switch (SilentModeMenu) {
-  case 0: SilentModeMenu = 1; break;
 #ifdef TMC2130
-  case 1: SilentModeMenu = 0; break;
+	case SILENT_MODE_NORMAL: SilentModeMenu = SILENT_MODE_STEALTH; break;
+	case SILENT_MODE_STEALTH: SilentModeMenu = SILENT_MODE_NORMAL; break;
+	default: SilentModeMenu = SILENT_MODE_NORMAL; break; // (probably) not needed
 #else
-  case 1: SilentModeMenu = 2; break;
-  case 2: SilentModeMenu = 0; break;
+	case SILENT_MODE_POWER: SilentModeMenu = SILENT_MODE_SILENT; break;
+	case SILENT_MODE_SILENT: SilentModeMenu = SILENT_MODE_AUTO; break;
+	case SILENT_MODE_AUTO: SilentModeMenu = SILENT_MODE_POWER; break;
+	default: SilentModeMenu = SILENT_MODE_POWER; break; // (probably) not needed
 #endif //TMC2130
-  default: SilentModeMenu = 0; break;
   }
   eeprom_update_byte((unsigned char *)EEPROM_SILENT, SilentModeMenu);
   st_current_init();
-//-//  lcd_goto_menu(lcd_tune_menu, 9);
   menu_action_back();
 }
 
@@ -5775,10 +5762,11 @@ static void lcd_tune_menu()
 #endif //DEBUG_DISABLE_FSENSORCHECK
 
 #ifdef TMC2130
-	if (SilentModeMenu == 0) MENU_ITEM(function, MSG_STEALTH_MODE_OFF, lcd_silent_mode_set);
+//*** MaR::180416_01b
+	if (SilentModeMenu == SILENT_MODE_NORMAL) MENU_ITEM(function, MSG_STEALTH_MODE_OFF, lcd_silent_mode_set);
 	else MENU_ITEM(function, MSG_STEALTH_MODE_ON, lcd_silent_mode_set);
 
-	if (SilentModeMenu == 0)
+	if (SilentModeMenu == SILENT_MODE_NORMAL)
 	{
 		if (CrashDetectMenu == 0) MENU_ITEM(function, MSG_CRASHDETECT_OFF, lcd_crash_mode_set);
 		else MENU_ITEM(function, MSG_CRASHDETECT_ON, lcd_crash_mode_set);
@@ -5787,10 +5775,10 @@ static void lcd_tune_menu()
 #else //TMC2130
 	if (!farm_mode) { //dont show in menu if we are in farm mode
 		switch (SilentModeMenu) {
-		case 0: MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); break;
-		case 1: MENU_ITEM(function, MSG_SILENT_MODE_ON, lcd_silent_mode_set); break;
-		case 2: MENU_ITEM(function, MSG_AUTO_MODE_ON, lcd_silent_mode_set); break;
-		default: MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); break;
+		case SILENT_MODE_POWER: MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); break;
+		case SILENT_MODE_SILENT: MENU_ITEM(function, MSG_SILENT_MODE_ON, lcd_silent_mode_set); break;
+		case SILENT_MODE_AUTO: MENU_ITEM(function, MSG_AUTO_MODE_ON, lcd_silent_mode_set); break;
+		default: MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); break; // (probably) not needed
 		}
 	}
 #endif //TMC2130
@@ -6580,7 +6568,8 @@ static bool lcd_selfcheck_pulleys(int axis)
 		st_current_set(0, 850); //set motor current higher
 		plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], 200, active_extruder);
 		st_synchronize();
-		if (SilentModeMenu == 1) st_current_set(0, tmp_motor[0]); //set back to normal operation currents
+//*** MaR::180416_02
+          if (SilentModeMenu != SILENT_MODE_OFF) st_current_set(0, tmp_motor[0]); //set back to normal operation currents
 		else st_current_set(0, tmp_motor_loud[0]); //set motor current back			
 		current_position[axis] = current_position[axis] - move;
 		plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], 50, active_extruder);

+ 11 - 1
Firmware/ultralcd.h

@@ -120,6 +120,16 @@ void lcd_mylang();
   extern int farm_no;
   extern int farm_timer;
   extern int farm_status;
+  #ifdef TMC2130
+    #define SILENT_MODE_NORMAL 0
+    #define SILENT_MODE_STEALTH 1
+    #define SILENT_MODE_OFF SILENT_MODE_NORMAL
+  #else
+    #define SILENT_MODE_POWER 0
+    #define SILENT_MODE_SILENT 1
+    #define SILENT_MODE_AUTO 2
+    #define SILENT_MODE_OFF SILENT_MODE_POWER
+  #endif
   extern int8_t SilentModeMenu;
 
 #ifdef SNMM
@@ -229,7 +239,7 @@ extern void lcd_implementation_print_at(uint8_t x, uint8_t y, const char *str);
 void change_extr(int extr);
 static void lcd_colorprint_change();
 static int get_ext_nr();
-static void extr_adj(int extruder);
+void extr_adj(int extruder);
 static void extr_adj_0();
 static void extr_adj_1();
 static void extr_adj_2();

+ 4 - 4
Firmware/xyzcal.cpp

@@ -678,16 +678,16 @@ uint8_t xyzcal_xycoords2point(int16_t x, int16_t y)
 }
 
 //MK3
-#if ((MOTHERBOARD == 310))
+#if ((MOTHERBOARD == BOARD_EINSY_1_0a))
 const int16_t PROGMEM xyzcal_point_xcoords[4] = {1200, 22000, 22000, 1200};
 const int16_t PROGMEM xyzcal_point_ycoords[4] = {600, 600, 19800, 19800};
-#endif //((MOTHERBOARD == 310))
+#endif //((MOTHERBOARD == BOARD_EINSY_1_0a))
 
 //MK2.5
-#if ((MOTHERBOARD == 200) || (MOTHERBOARD == 203))
+#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
 const int16_t PROGMEM xyzcal_point_xcoords[4] = {1200, 22000, 22000, 1200};
 const int16_t PROGMEM xyzcal_point_ycoords[4] = {700, 700, 19800, 19800};
-#endif //((MOTHERBOARD == 200) || (MOTHERBOARD == 203))
+#endif //((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
 
 const uint16_t PROGMEM xyzcal_point_pattern[12] = {0x000, 0x0f0, 0x1f8, 0x3fc, 0x7fe, 0x7fe, 0x7fe, 0x7fe, 0x3fc, 0x1f8, 0x0f0, 0x000};