Commit 93f4bbb8 authored by MagoKimbra's avatar MagoKimbra

Same Fix

parent fcf48a89
......@@ -42,7 +42,7 @@
#define START "start" //start for host
#define OK "ok " //ok answer for host
#define ER "Error:" //error for host
#define DB "echo: " //message for user
#define DB "echo: " //message for user
#define RS "Resend:" //resend for host
#define PAUSE "//action:pause" //command for host that support action
#define RESUME "//action:resume" //command for host that support action
......
......@@ -797,7 +797,7 @@ void Config_PrintSettings(bool forReplay) {
ECHO_LM(DB, "Filament settings: Disabled");
}
}
ConfigSD_PrintSettings(forReplay);
if (printer_usage_seconds > 0) ConfigSD_PrintSettings(forReplay);
}
void ConfigSD_PrintSettings(bool forReplay) {
......@@ -872,6 +872,7 @@ void ConfigSD_PrintSettings(bool forReplay) {
}
card.closeFile(false);
config_readed = true;
ConfigSD_PrintSettings(true);
}
int ConfigSD_KeyIndex(char *key) { //At the moment a binary search algorithm is used for simplicity, if it will be necessary (Eg. tons of key), an hash search algorithm will be implemented.
......
......@@ -459,6 +459,7 @@ unsigned long printer_usage_seconds;
//===========================================================================
//================================ Functions ================================
//===========================================================================
void get_arc_coordinates();
bool setTargetedHotend(int code);
......@@ -579,7 +580,6 @@ void setup_homepin(void) {
#endif
}
void setup_photpin() {
#if HAS_PHOTOGRAPH
OUT_WRITE(PHOTOGRAPH_PIN, LOW);
......@@ -698,7 +698,7 @@ void setup() {
// loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
Config_RetrieveSettings();
// loads custom configuration from SDCARD if available else uses defaults
#if defined(SDSUPPORT) && defined(SD_SETTINGS)
ConfigSD_ResetDefault(); //this reset variable to default value as we can't load in the setup for different reason. Will load the value in the loop()
......@@ -713,7 +713,7 @@ void setup() {
setup_photpin();
setup_laserbeampin(); // Initialize Laserbeam pin
servo_init();
lcd_init();
_delay_ms(1000); // wait 1sec to display the splash screen
......@@ -735,6 +735,7 @@ void setup() {
pinMode(STAT_LED_RED, OUTPUT);
digitalWrite(STAT_LED_RED, LOW); // turn it off
#endif
#ifdef STAT_LED_BLUE
pinMode(STAT_LED_BLUE, OUTPUT);
digitalWrite(STAT_LED_BLUE, LOW); // turn it off
......@@ -1257,8 +1258,8 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
st_synchronize();
endstops_hit_on_purpose(); // clear endstop hit flags
// Get the current stepper position after bumping an endstop
current_position[Z_AXIS] = st_get_position_mm(Z_AXIS);
// make sure the planner knows where we are as it may be a bit different than we last said to move to
sync_plan_position();
}
......@@ -2613,12 +2614,6 @@ inline void gcode_G4() {
* Y Home to the Y endstop
* Z Home to the Z endstop
*
* If numbers are included with XYZ set the position as with G92
* Currently adds the home_offset, which may be wrong and removed soon.
*
* Xn Home X, setting X to n + home_offset[X_AXIS]
* Yn Home Y, setting Y to n + home_offset[Y_AXIS]
* Zn Home Z, setting Z to n + home_offset[Z_AXIS]
*/
inline void gcode_G28(boolean home_x = false, boolean home_y = false) {
......@@ -3800,7 +3795,7 @@ inline void gcode_M42() {
* L = Number of legs of movement before probe
*
* This function assumes the bed has been homed. Specifically, that a G28 command
* as been issued prior to invoking the M48 Z-Probe repeatability measurement function.
* as been issued prior to invoking the M49 Z-Probe repeatability measurement function.
* Any information generated by a prior G29 Bed leveling command will be lost and need to be
* regenerated.
*/
......@@ -3817,6 +3812,9 @@ inline void gcode_M42() {
}
}
if (verbose_level > 0)
ECHO_LM(DB, "M49 Z-Probe Repeatability test");
if (code_seen('P') || code_seen('p')) {
n_samples = code_value_short();
if (n_samples < 4 || n_samples > 50) {
......@@ -3824,8 +3822,6 @@ inline void gcode_M42() {
return;
}
}
if (verbose_level > 0) ECHO_LM(DB, "M49 Z-Probe Repeatability test");
double X_probe_location, Y_probe_location,
X_current = X_probe_location = st_get_position_mm(X_AXIS),
......@@ -3926,8 +3922,8 @@ inline void gcode_M42() {
if (radius < 0.0) radius = -radius;
X_current = X_probe_location + cos(theta) * radius;
Y_current = Y_probe_location + sin(theta) * radius;
X_current = constrain(X_current, X_MIN_POS, X_MAX_POS);
Y_current = Y_probe_location + sin(theta) * radius;
Y_current = constrain(Y_current, Y_MIN_POS, Y_MAX_POS);
if (verbose_level > 3) {
......@@ -3983,6 +3979,8 @@ inline void gcode_M42() {
ECHO_E;
}
if (verbose_level > 0) ECHO_E;
plan_buffer_line(X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder, active_driver);
st_synchronize();
......@@ -4154,7 +4152,7 @@ inline void gcode_M104() {
inline void gcode_M105() {
if (setTargetedHotend(105)) return;
#if HAS_TEMP_0 || HAS_TEMP_BED
#if HAS_TEMP_0 || HAS_TEMP_BED || defined(HEATER_0_USES_MAX6675)
ECHO_S(OK);
#if HAS_TEMP_0
ECHO_MV(" T:", degHotend(target_extruder), 1);
......
......@@ -46,7 +46,7 @@ block_t *current_block; // A pointer to the block currently being traced
// Variables used by The Stepper Driver Interrupt
static unsigned char out_bits; // The next stepping-bits to be output
static unsigned int cleaning_buffer_counter;
static unsigned int cleaning_buffer_counter;
#ifdef Z_DUAL_ENDSTOPS
static bool performing_homing = false,
......@@ -291,8 +291,8 @@ void checkHitEndstops() {
}
#ifdef Z_PROBE_ENDSTOP
if (endstop_z_probe_hit) {
ECHO_MV(" Z_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZPS);
ECHO_MV(" Z_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZPS);
}
#endif
if(endstop_e_hit) {
......@@ -340,8 +340,8 @@ void checkHitEndstops() {
}
#ifdef Z_PROBE_ENDSTOP
if (endstop_z_probe_hit) {
ECHO_MV(MSG_ENDSTOP_ZPS, (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZPS);
ECHO_MV(MSG_ENDSTOP_ZPS, (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZPS);
}
#endif
ECHO_E;
......@@ -532,7 +532,7 @@ ISR(TIMER1_COMPA_vect) {
#ifdef DUAL_X_CARRIAGE
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1))
#endif
#endif
{
#if HAS_X_MIN
UPDATE_ENDSTOP(x, X, min, MIN);
......@@ -618,12 +618,14 @@ ISR(TIMER1_COMPA_vect) {
z_probe_endstop = (READ(Z_PROBE_PIN) != Z_PROBE_ENDSTOP_INVERTING);
if (z_probe_endstop && old_z_probe_endstop)
{
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
endstop_z_probe_hit = true;
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
endstop_z_probe_hit = true;
// if (z_probe_endstop && old_z_probe_endstop) ECHO_EV("z_probe_endstop = true");
}
old_z_probe_endstop = z_probe_endstop;
#endif
} // check_endstops
}
......@@ -653,6 +655,9 @@ ISR(TIMER1_COMPA_vect) {
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
endstop_z_hit = true;
// if (z_max_both) ECHO_EV("z_max_endstop = true");
// if (z2_max_both) ECHO_EV("z2_max_endstop = true");
if (!performing_homing || (performing_homing && z_max_both && z2_max_both)) //if not performing home or if both endstops were trigged during homing...
step_events_completed = current_block->step_event_count;
}
......@@ -790,6 +795,7 @@ ISR(TIMER1_COMPA_vect) {
#endif
}
else if (step_events_completed > (unsigned long)current_block->decelerate_after) {
MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
if (step_rate > acc_step_rate) { // Check step_rate stays positive
......@@ -916,7 +922,7 @@ void st_init() {
#ifdef HAVE_L6470DRIVER
L6470_init();
#endif
// Initialize Dir Pins
#if HAS_X_DIR
X_DIR_INIT;
......@@ -962,11 +968,11 @@ void st_init() {
#if HAS_Y_ENABLE
Y_ENABLE_INIT;
if (!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH);
#if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_ENABLE
Y2_ENABLE_INIT;
if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH);
#endif
#if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_ENABLE
Y2_ENABLE_INIT;
if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH);
#endif
#endif
#if HAS_Z_ENABLE
Z_ENABLE_INIT;
......@@ -1064,8 +1070,8 @@ void st_init() {
#ifdef ENDSTOPPULLUP_ZMAX
WRITE(Z2_MAX_PIN,HIGH);
#endif
#endif
#endif
#if (defined(Z_PROBE_PIN) && Z_PROBE_PIN >= 0) && defined(Z_PROBE_ENDSTOP) // Check for Z_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used.
SET_INPUT(Z_PROBE_PIN);
#ifdef ENDSTOPPULLUP_ZPROBE
......@@ -1243,7 +1249,7 @@ void quickStop() {
case Y_AXIS:
BABYSTEP_AXIS(y, Y, false);
break;
case Z_AXIS: {
#ifndef DELTA
......@@ -1280,7 +1286,7 @@ void quickStop() {
#endif
} break;
default: break;
}
}
......@@ -1353,7 +1359,7 @@ void microstep_init() {
#if HAS_MICROSTEPS
pinMode(X_MS1_PIN,OUTPUT);
pinMode(X_MS2_PIN,OUTPUT);
pinMode(X_MS2_PIN,OUTPUT);
pinMode(Y_MS1_PIN,OUTPUT);
pinMode(Y_MS2_PIN,OUTPUT);
pinMode(Z_MS1_PIN,OUTPUT);
......
......@@ -276,28 +276,28 @@ static void lcd_status_screen() {
#ifdef LCD_PROGRESS_BAR
millis_t ms = millis();
#ifndef PROGRESS_MSG_ONCE
if (ms > progressBarTick + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME) {
progressBarTick = ms;
if (ms > progress_bar_ms + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME) {
progress_bar_ms = ms;
}
#endif
#if PROGRESS_MSG_EXPIRE > 0
// Handle message expire
if (expireStatusMillis > 0) {
if (expire_status_ms > 0) {
if (card.isFileOpen()) {
// Expire the message when printing is active
if (IS_SD_PRINTING) {
// Expire the message when printing is active
if (ms >= expireStatusMillis) {
if (ms >= expire_status_ms) {
lcd_status_message[0] = '\0';
expireStatusMillis = 0;
expire_status_ms = 0;
}
}
else {
expireStatusMillis += LCD_UPDATE_INTERVAL;
expire_status_ms += LCD_UPDATE_INTERVAL;
}
}
else {
expireStatusMillis = 0;
expire_status_ms = 0;
}
}
#endif
......@@ -1557,9 +1557,9 @@ void lcd_ignore_click(bool b) {
void lcd_finishstatus(bool persist=false) {
#ifdef LCD_PROGRESS_BAR
progressBarTick = millis();
progress_bar_ms = millis();
#if PROGRESS_MSG_EXPIRE > 0
expireStatusMillis = persist ? 0 : progressBarTick + PROGRESS_MSG_EXPIRE;
expire_status_ms = persist ? 0 : progress_bar_ms + PROGRESS_MSG_EXPIRE;
#endif
#endif
lcdDrawUpdate = 2;
......@@ -1570,7 +1570,7 @@ void lcd_finishstatus(bool persist=false) {
}
#if defined(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
void dontExpireStatus() { expireStatusMillis = 0; }
void dontExpireStatus() { expire_status_ms = 0; }
#endif
void set_utf_strlen(char *s, uint8_t n) {
......@@ -1583,6 +1583,8 @@ void set_utf_strlen(char *s, uint8_t n) {
s[i] = 0;
}
bool lcd_hasstatus() { return (lcd_status_message[0] != '\0'); }
void lcd_setstatus(const char* message, bool persist) {
if (lcd_status_message_level > 0) return;
strncpy(lcd_status_message, message, 3*LCD_WIDTH);
......@@ -1712,8 +1714,9 @@ void lcd_buzz(long duration, uint16_t freq) {
#if BEEPER > 0
SET_OUTPUT(BEEPER);
tone(BEEPER, freq, duration);
delay(duration);
#elif defined(LCD_USE_I2C_BUZZER)
lcd.buzz(duration,freq);
lcd.buzz(duration, freq);
#else
delay(duration);
#endif
......
......@@ -8,6 +8,7 @@
int lcd_strlen_P(const char *s);
void lcd_update();
void lcd_init();
bool lcd_hasstatus();
void lcd_setstatus(const char* message, const bool persist=false);
void lcd_setstatuspgm(const char* message, const uint8_t level=0);
void lcd_setalertstatuspgm(const char* message);
......@@ -108,6 +109,7 @@
#else //no LCD
FORCE_INLINE void lcd_update() {}
FORCE_INLINE void lcd_init() {}
FORCE_INLINE bool lcd_hasstatus() { return false; }
FORCE_INLINE void lcd_setstatus(const char* message, const bool persist=false) {}
FORCE_INLINE void lcd_setstatuspgm(const char* message, const uint8_t level=0) {}
FORCE_INLINE void lcd_buttons_update() {}
......@@ -115,8 +117,8 @@
FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {}
FORCE_INLINE bool lcd_detected(void) { return true; }
#define LCD_MESSAGEPGM(x)
#define LCD_ALERTMESSAGEPGM(x)
#define LCD_MESSAGEPGM(x) do{}while(0)
#define LCD_ALERTMESSAGEPGM(x) do{}while(0)
#endif //ULTRA_LCD
......
......@@ -202,9 +202,9 @@
#include "utf_mapper.h"
#ifdef LCD_PROGRESS_BAR
static uint16_t progressBarTick = 0;
static millis_t progress_bar_ms = 0;
#if PROGRESS_MSG_EXPIRE > 0
static uint16_t expireStatusMillis = 0;
static millis_t expire_status_ms = 0;
#endif
#define LCD_STR_PROGRESS "\x03\x04\x05"
#endif
......@@ -634,8 +634,9 @@ static void lcd_implementation_status_screen() {
#ifdef LCD_PROGRESS_BAR
if (card.isFileOpen()) {
if (millis() >= progressBarTick + PROGRESS_BAR_MSG_TIME || !lcd_status_message[0]) {
// draw the progress bar
// Draw the progress bar if the message has shown long enough
// or if there is no message set.
if (millis() >= progress_bar_ms + PROGRESS_BAR_MSG_TIME || !lcd_status_message[0]) {
int tix = (int)(card.percentDone() * LCD_WIDTH * 3) / 100,
cel = tix / 3, rem = tix % 3, i = LCD_WIDTH;
char msg[LCD_WIDTH+1], b = ' ';
......
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