Commit 8df0f708 authored by MagoKimbra's avatar MagoKimbra

Add command M428

parent 0895f853
......@@ -60,7 +60,7 @@
* M109 - S[xxx] Wait for extruder current temp to reach target temp. Waits only when heating - R[xxx] Wait for extruder current temp to reach target temp. Waits when heating and cooling
* M111 - Debug Dryrun Repetier
* M112 - Emergency stop
* M114 - Output current position to serial port
* M114 - Output current position to serial port, (V)erbose for user
* M115 - Capabilities string
* M117 - display message
* M119 - Output Endstop status to serial port
......@@ -100,6 +100,8 @@
* M405 - Turn on Filament Sensor extrusion control. Optional D[delay in cm] to set delay in centimeters between sensor and extruder
* M406 - Turn off Filament Sensor extrusion control
* M407 - Displays measured filament diameter
* M410 - Quickstop. Abort all the planned moves
* M428 - Set the home_offset logically based on the current_position
* M500 - stores paramters in EEPROM
* M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
* M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
......
......@@ -196,6 +196,9 @@
#define HOMING_BUMP_DIVISOR {5, 5, 2} // Re-Bump Speed Divisor (Divides the Homing Feedrate)
//#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially.
// When G28 is called, this option will make Y home before X
// #define HOME_Y_BEFORE_X
#define AXIS_RELATIVE_MODES {false, false, false, false}
//By default pololu step drivers require an active high signal. However, some high power drivers require an active low signal as step.
......
......@@ -187,6 +187,7 @@
* M406 - Turn off Filament Sensor extrusion control
* M407 - Display measured filament diameter
* M410 - Quickstop. Abort all the planned moves
* M428 - Set the home_offset logically based on the current_position
* M500 - Store parameters in EEPROM
* M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily).
* M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
......@@ -2407,37 +2408,6 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
}
#endif //Z_PROBE_SLED
inline void lcd_beep(int number_beep = 3) {
#ifdef LCD_USE_I2C_BUZZER
#if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS)
for(int8_t i = 0; i < 3; i++) {
lcd_buzz(1000/6,100);
}
#else
for(int8_t i = 0; i < number_beep; i++) {
lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS,LCD_FEEDBACK_FREQUENCY_HZ);
}
#endif
#elif defined(BEEPER) && BEEPER > -1
SET_OUTPUT(BEEPER);
#if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS)
for(int8_t i = 0; i < number_beep; i++) {
WRITE(BEEPER,HIGH);
delay(100);
WRITE(BEEPER,LOW);
delay(100);
}
#else
for(int8_t i=0;i<number_beep;i++) {
WRITE(BEEPER,HIGH);
delay(1000000 / LCD_FEEDBACK_FREQUENCY_HZ / 2);
WRITE(BEEPER,LOW);
delay(1000000 / LCD_FEEDBACK_FREQUENCY_HZ / 2);
}
#endif
#endif
}
inline void wait_heater() {
setWatch();
......@@ -4862,19 +4832,19 @@ inline void gcode_M226() {
}
#endif // NUM_SERVOS > 0
#if BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)
#if HAS_LCD_BUZZ
/**
* M300: Play beep sound S<frequency Hz> P<duration ms>
*/
inline void gcode_M300() {
uint16_t beepS = code_seen('S') ? code_value_short() : 110;
uint16_t beepS = code_seen('S') ? code_value_short() : 100;
uint32_t beepP = code_seen('P') ? code_value_long() : 1000;
if (beepP > 5000) beepP = 5000; // limit to 5 seconds
lcd_buzz(beepP, beepS);
}
#endif // BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER
#endif // HAS_LCD_BUZZ
#ifdef PIDTEMP
......@@ -5170,6 +5140,58 @@ inline void gcode_M400() { st_synchronize(); }
*/
inline void gcode_M410() { quickStop(); }
/**
* M428: Set home_offset based on the distance between the
* current_position and the nearest "reference point."
* If an axis is past center its endstop position
* is the reference-point. Otherwise it uses 0. This allows
* the Z offset to be set near the bed when using a max endstop.
*
* M428 can't be used more than 2cm away from 0 or an endstop.
*
* Use M206 to set these values directly.
*/
inline void gcode_M428() {
bool err = false;
float new_offs[3], new_pos[3];
memcpy(new_pos, current_position, sizeof(new_pos));
memcpy(new_offs, home_offset, sizeof(new_offs));
for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
if (axis_known_position[i]) {
#ifdef DELTA
float base = (new_pos[i] > (min_pos[i] + max_pos[i]) / 2) ? base_home_pos[i] : 0,
#else
float base = (new_pos[i] > (min_pos[i] + max_pos[i]) / 2) ? base_home_pos(i) : 0,
#endif
diff = new_pos[i] - base;
if (diff > -20 && diff < 20) {
new_offs[i] -= diff;
new_pos[i] = base;
}
else {
ECHO_LM(ER, MSG_ERR_M428_TOO_FAR);
LCD_ALERTMESSAGEPGM("Err: Too far!");
#if HAS_LCD_BUZZ
enqueuecommands_P(PSTR("M300 S40 P200"));
#endif
err = true;
break;
}
}
}
if (!err) {
memcpy(current_position, new_pos, sizeof(new_pos));
memcpy(home_offset, new_offs, sizeof(new_offs));
sync_plan_position();
ECHO_LM(DB, "Offset applied.");
LCD_ALERTMESSAGEPGM("Offset applied.");
#if HAS_LCD_BUZZ
enqueuecommands_P(PSTR("M300 S659 P200\nM300 S698 P200"));
#endif
}
}
/**
* M500: Store settings in EEPROM
*/
......@@ -5299,7 +5321,9 @@ inline void gcode_M503() {
}
if (beep) {
last_set = millis();
lcd_beep(3);
for(int8_t i = 0; i < 3; i++) {
lcd_buzz(100, 1000);
}
beep = false;
cnt += 1;
}
......@@ -6076,10 +6100,10 @@ void process_commands() {
gcode_M280(); break;
#endif // NUM_SERVOS > 0
#if BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)
#if HAS_LCD_BUZZ
case 300: // M300 - Play beep tone
gcode_M300(); break;
#endif // LARGE_FLASH && (BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER)
#endif // HAS_LCD_BUZZ
#ifdef PIDTEMP
case 301: // M301
......@@ -6147,6 +6171,9 @@ void process_commands() {
case 410: // M410 quickstop - Abort all the planned moves.
gcode_M410(); break;
case 428: // M428 Apply current_position to home_offset
gcode_M428(); break;
case 500: // M500 Store settings in EEPROM
gcode_M500(); break;
case 501: // M501 Read settings from EEPROM
......
......@@ -204,6 +204,11 @@
#endif
#endif
/**
* LCD BUZZ
*/
#define HAS_LCD_BUZZ (defined(ULTRALCD) || (defined(BEEPER) && BEEPER >= 0) || defined(LCD_USE_I2C_BUZZER))
#else // CONFIGURATION_LCD
#define CONDITIONALS_H
......
......@@ -136,14 +136,15 @@
#define MSG_Z_MAX "z_max: "
#define MSG_Z2_MAX "z2_max: "
#define MSG_Z_PROBE "z_probe: "
#define MSG_ERR_MATERIAL_INDEX "M145 S<index> out of range (0-2)"
#define MSG_E_MIN "e_min: "
#define MSG_FILAMENT_RUNOUT_PIN "filament_runout_pin: "
#define MSG_M119_REPORT "Reporting endstop status"
#define MSG_ENDSTOP_HIT "TRIGGERED"
#define MSG_ENDSTOP_OPEN "NOT TRIGGERED"
#define MSG_HOTEND_OFFSET "Hotend offsets:"
#define MSG_EMPTY_PLANE "Autolevel can only be execute on an actual plane, make sure width and height are not 0!"
#define MSG_ERR_MATERIAL_INDEX "M145 S<index> out of range (0-2)"
#define MSG_FILAMENT_RUNOUT_PIN "filament_runout_pin: "
#define MSG_ERR_M428_TOO_FAR "Too far from reference point"
#define MSG_SD_CANT_OPEN_SUBDIR "Cannot open subdir"
#define MSG_SD_INIT_FAIL "SD init fail"
......
......@@ -32,6 +32,7 @@ Adding commands to facilitate purging of hotend.
Step per unit varied for each extruder as well as the feedrate.
The addition of a different feedrate for retraction.
Adding Debug Dryrun used by repetier.
Add total Power on time write in EEPROM
## Credits
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment