This commit is contained in:
Rob McKenzie 2018-11-21 17:21:27 +10:00
parent 27e860e945
commit 11f1a44d40
87 changed files with 27331 additions and 26605 deletions

View File

@ -54,11 +54,20 @@ void Config_StoreSettings();
bool Config_RetrieveSettings(); bool Config_RetrieveSettings();
#else #else
FORCE_INLINE void Config_StoreSettings() {} FORCE_INLINE void Config_StoreSettings() {}
FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); } FORCE_INLINE void Config_RetrieveSettings() {
Config_ResetDefault();
Config_PrintSettings();
}
#endif #endif
inline uint8_t calibration_status() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS); } inline uint8_t calibration_status() {
inline void calibration_status_store(uint8_t status) { eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS, status); } return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS);
inline bool calibration_status_pinda() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA); } }
inline void calibration_status_store(uint8_t status) {
eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS, status);
}
inline bool calibration_status_pinda() {
return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA);
}
#endif//CONFIG_STORE_H #endif//CONFIG_STORE_H

View File

@ -81,9 +81,15 @@ void print_mem(uint32_t address, uint16_t count, uint8_t type, uint8_t countperl
uint8_t data = 0; uint8_t data = 0;
switch (type) switch (type)
{ {
case 0: data = *((uint8_t*)address++); break; case 0:
case 1: data = eeprom_read_byte((uint8_t*)address++); break; data = *((uint8_t*)address++);
case 2: data = pgm_read_byte_far((uint8_t*)address++); break; break;
case 1:
data = eeprom_read_byte((uint8_t*)address++);
break;
case 2:
data = pgm_read_byte_far((uint8_t*)address++);
break;
} }
putchar(' '); putchar(' ');
print_hex_byte(data); print_hex_byte(data);
@ -412,13 +418,20 @@ const char* dcode_9_ADC_name(uint8_t i)
{ {
switch (i) switch (i)
{ {
case 0: return PSTR("TEMP_HEATER0"); case 0:
case 1: return PSTR("TEMP_HEATER1"); return PSTR("TEMP_HEATER0");
case 2: return PSTR("TEMP_BED"); case 1:
case 3: return PSTR("TEMP_PINDA"); return PSTR("TEMP_HEATER1");
case 4: return PSTR("VOLT_PWR"); case 2:
case 5: return PSTR("TEMP_AMBIENT"); return PSTR("TEMP_BED");
case 6: return PSTR("VOLT_BED"); case 3:
return PSTR("TEMP_PINDA");
case 4:
return PSTR("VOLT_PWR");
case 5:
return PSTR("TEMP_AMBIENT");
case 6:
return PSTR("VOLT_BED");
} }
return 0; return 0;
} }
@ -443,18 +456,25 @@ uint16_t dcode_9_ADC_val(uint8_t i)
{ {
switch (i) switch (i)
{ {
case 0: return current_temperature_raw[0]; case 0:
case 1: return 0; return current_temperature_raw[0];
case 2: return current_temperature_bed_raw; case 1:
case 3: return current_temperature_raw_pinda; return 0;
case 2:
return current_temperature_bed_raw;
case 3:
return current_temperature_raw_pinda;
#ifdef VOLT_PWR_PIN #ifdef VOLT_PWR_PIN
case 4: return current_voltage_raw_pwr; case 4:
return current_voltage_raw_pwr;
#endif //VOLT_PWR_PIN #endif //VOLT_PWR_PIN
#ifdef AMBIENT_THERMISTOR #ifdef AMBIENT_THERMISTOR
case 5: return current_temperature_raw_ambient; case 5:
return current_temperature_raw_ambient;
#endif //AMBIENT_THERMISTOR #endif //AMBIENT_THERMISTOR
#ifdef VOLT_BED_PIN #ifdef VOLT_BED_PIN
case 6: return current_voltage_raw_bed; case 6:
return current_voltage_raw_bed;
#endif //VOLT_BED_PIN #endif //VOLT_BED_PIN
} }
return 0; return 0;
@ -540,16 +560,28 @@ void dcode_2130()
uint8_t axis = 0xff; uint8_t axis = 0xff;
switch (strchr_pointer[1+4]) switch (strchr_pointer[1+4])
{ {
case 'X': axis = X_AXIS; break; case 'X':
case 'Y': axis = Y_AXIS; break; axis = X_AXIS;
case 'Z': axis = Z_AXIS; break; break;
case 'E': axis = E_AXIS; break; case 'Y':
axis = Y_AXIS;
break;
case 'Z':
axis = Z_AXIS;
break;
case 'E':
axis = E_AXIS;
break;
} }
if (axis != 0xff) if (axis != 0xff)
{ {
char ch_axis = strchr_pointer[1+4]; char ch_axis = strchr_pointer[1+4];
if (strchr_pointer[1+5] == '0') { tmc2130_set_pwr(axis, 0); } if (strchr_pointer[1+5] == '0') {
else if (strchr_pointer[1+5] == '1') { tmc2130_set_pwr(axis, 1); } tmc2130_set_pwr(axis, 0);
}
else if (strchr_pointer[1+5] == '1') {
tmc2130_set_pwr(axis, 1);
}
else if (strchr_pointer[1+5] == '+') else if (strchr_pointer[1+5] == '+')
{ {
if (strchr_pointer[1+6] == 0) if (strchr_pointer[1+6] == 0)

View File

@ -262,7 +262,9 @@ void refresh_cmd_timeout(void);
extern volatile unsigned long timer0_millis; extern volatile unsigned long timer0_millis;
// An unsynchronized equivalent to a standard Arduino millis() function. // An unsynchronized equivalent to a standard Arduino millis() function.
// To be used inside an interrupt routine. // To be used inside an interrupt routine.
FORCE_INLINE unsigned long millis_nc() { return timer0_millis; } FORCE_INLINE unsigned long millis_nc() {
return timer0_millis;
}
#ifdef FAST_PWM_FAN #ifdef FAST_PWM_FAN
void setPwmFrequency(uint8_t pin, int val); void setPwmFrequency(uint8_t pin, int val);

View File

@ -407,15 +407,26 @@ uint16_t gcode_in_progress = 0;
uint16_t mcode_in_progress = 0; uint16_t mcode_in_progress = 0;
void serial_echopair_P(const char *s_P, float v) void serial_echopair_P(const char *s_P, float v)
{ serialprintPGM(s_P); SERIAL_ECHO(v); } {
serialprintPGM(s_P);
SERIAL_ECHO(v);
}
void serial_echopair_P(const char *s_P, double v) void serial_echopair_P(const char *s_P, double v)
{ serialprintPGM(s_P); SERIAL_ECHO(v); } {
serialprintPGM(s_P);
SERIAL_ECHO(v);
}
void serial_echopair_P(const char *s_P, unsigned long v) void serial_echopair_P(const char *s_P, unsigned long v)
{ serialprintPGM(s_P); SERIAL_ECHO(v); } {
serialprintPGM(s_P);
SERIAL_ECHO(v);
}
#ifdef SDSUPPORT #ifdef SDSUPPORT
#include "SdFatUtil.h" #include "SdFatUtil.h"
int freeMemory() { return SdFatUtil::FreeRam(); } int freeMemory() {
return SdFatUtil::FreeRam();
}
#else #else
extern "C" { extern "C" {
extern unsigned int __bss_end; extern unsigned int __bss_end;
@ -818,10 +829,18 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
factory_reset(level); factory_reset(level);
switch (level) { switch (level) {
case 0: _delay_ms(0); break; case 0:
case 1: _delay_ms(0); break; _delay_ms(0);
case 2: _delay_ms(0); break; break;
case 3: _delay_ms(0); break; case 1:
_delay_ms(0);
break;
case 2:
_delay_ms(0);
break;
case 3:
_delay_ms(0);
break;
} }
} }
@ -832,8 +851,12 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
void show_fw_version_warnings() { void show_fw_version_warnings() {
if (FW_DEV_VERSION == FW_VERSION_GOLD || FW_DEV_VERSION == FW_VERSION_RC) return; if (FW_DEV_VERSION == FW_VERSION_GOLD || FW_DEV_VERSION == FW_VERSION_RC) return;
switch (FW_DEV_VERSION) { switch (FW_DEV_VERSION) {
case(FW_VERSION_ALPHA): lcd_show_fullscreen_message_and_wait_P(_i("You are using firmware alpha version. This is development version. Using this version is not recommended and may cause printer damage.")); break;////MSG_FW_VERSION_ALPHA c=20 r=8 case(FW_VERSION_ALPHA):
case(FW_VERSION_BETA): lcd_show_fullscreen_message_and_wait_P(_i("You are using firmware beta version. This is development version. Using this version is not recommended and may cause printer damage.")); break;////MSG_FW_VERSION_BETA c=20 r=8 lcd_show_fullscreen_message_and_wait_P(_i("You are using firmware alpha version. This is development version. Using this version is not recommended and may cause printer damage."));
break;////MSG_FW_VERSION_ALPHA c=20 r=8
case(FW_VERSION_BETA):
lcd_show_fullscreen_message_and_wait_P(_i("You are using firmware beta version. This is development version. Using this version is not recommended and may cause printer damage."));
break;////MSG_FW_VERSION_BETA c=20 r=8
case(FW_VERSION_DEVEL): case(FW_VERSION_DEVEL):
case(FW_VERSION_DEBUG): case(FW_VERSION_DEBUG):
lcd_update_enable(false); lcd_update_enable(false);
@ -844,7 +867,8 @@ void show_fw_version_warnings() {
lcd_puts_at_P(0, 0, PSTR("Debbugging build !!!")); lcd_puts_at_P(0, 0, PSTR("Debbugging build !!!"));
#endif #endif
lcd_puts_at_P(0, 1, PSTR("May destroy printer!")); lcd_puts_at_P(0, 1, PSTR("May destroy printer!"));
lcd_puts_at_P(0, 2, PSTR("ver ")); lcd_puts_P(PSTR(FW_VERSION_FULL)); lcd_puts_at_P(0, 2, PSTR("ver "));
lcd_puts_P(PSTR(FW_VERSION_FULL));
lcd_puts_at_P(0, 3, PSTR(FW_REPOSITORY)); lcd_puts_at_P(0, 3, PSTR(FW_REPOSITORY));
lcd_wait_for_click(); lcd_wait_for_click();
break; break;
@ -1481,7 +1505,8 @@ void setup()
eeprom_write_word((uint16_t*)EEPROM_PRINTER_TYPE, PRINTER_TYPE); eeprom_write_word((uint16_t*)EEPROM_PRINTER_TYPE, PRINTER_TYPE);
eeprom_write_word((uint16_t*)EEPROM_BOARD_TYPE, MOTHERBOARD); eeprom_write_word((uint16_t*)EEPROM_BOARD_TYPE, MOTHERBOARD);
break; break;
default: break; //no change, show no message default:
break; //no change, show no message
} }
if (!previous_settings_retrieved) { if (!previous_settings_retrieved) {
@ -1818,9 +1843,15 @@ void loop()
// crashdet_stop_and_save_print(); // crashdet_stop_and_save_print();
switch (crash) switch (crash)
{ {
case 1: enquecommand_P((PSTR("CRASH_DETECTEDX"))); break; case 1:
case 2: enquecommand_P((PSTR("CRASH_DETECTEDY"))); break; enquecommand_P((PSTR("CRASH_DETECTEDX")));
case 3: enquecommand_P((PSTR("CRASH_DETECTEDXY"))); break; break;
case 2:
enquecommand_P((PSTR("CRASH_DETECTEDY")));
break;
case 3:
enquecommand_P((PSTR("CRASH_DETECTEDXY")));
break;
} }
} }
#endif //TMC2130 #endif //TMC2130
@ -1856,8 +1887,12 @@ static void axis_is_at_home(int axis) {
} }
inline void set_current_to_destination() { memcpy(current_position, destination, sizeof(current_position)); } inline void set_current_to_destination() {
inline void set_destination_to_current() { memcpy(destination, current_position, sizeof(destination)); } memcpy(current_position, destination, sizeof(current_position));
}
inline void set_destination_to_current() {
memcpy(destination, current_position, sizeof(destination));
}
//! @return original feedmultiply //! @return original feedmultiply
static int setup_for_endstop_move(bool enable_endstops_now = true) { static int setup_for_endstop_move(bool enable_endstops_now = true) {
@ -2043,7 +2078,8 @@ inline void gcode_M900() {
SERIAL_ECHOLN(extruder_advance_k); SERIAL_ECHOLN(extruder_advance_k);
SERIAL_ECHOPGM(" E/D="); SERIAL_ECHOPGM(" E/D=");
const float ratio = advance_ed_ratio; const float ratio = advance_ed_ratio;
if (ratio) SERIAL_ECHOLN(ratio); else SERIAL_ECHOLNPGM("Auto"); if (ratio) SERIAL_ECHOLN(ratio);
else SERIAL_ECHOLNPGM("Auto");
} }
#endif // LIN_ADVANCE #endif // LIN_ADVANCE
@ -2412,8 +2448,10 @@ void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, long home_
st_synchronize(); st_synchronize();
#if 0 #if 0
SERIAL_ECHOPGM("G28, initial "); print_world_coordinates(); SERIAL_ECHOPGM("G28, initial ");
SERIAL_ECHOPGM("G28, initial "); print_physical_coordinates(); print_world_coordinates();
SERIAL_ECHOPGM("G28, initial ");
print_physical_coordinates();
#endif #endif
// Flag for the display update routine and to disable the print cancelation during homing. // Flag for the display update routine and to disable the print cancelation during homing.
@ -2480,12 +2518,14 @@ void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, long home_
// In the quick mode, if both x and y are to be homed, a diagonal move will be performed initially. // In the quick mode, if both x and y are to be homed, a diagonal move will be performed initially.
if(home_x && home_y) //first diagonal move if(home_x && home_y) //first diagonal move
{ {
current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0; current_position[X_AXIS] = 0;
current_position[Y_AXIS] = 0;
int x_axis_home_dir = home_dir(X_AXIS); int x_axis_home_dir = home_dir(X_AXIS);
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS); destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;
destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS);
feedrate = homing_feedrate[X_AXIS]; feedrate = homing_feedrate[X_AXIS];
if(homing_feedrate[Y_AXIS]<feedrate) if(homing_feedrate[Y_AXIS]<feedrate)
feedrate = homing_feedrate[Y_AXIS]; feedrate = homing_feedrate[Y_AXIS];
@ -2568,15 +2608,20 @@ void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, long home_
enable_endstops(false); enable_endstops(false);
#ifdef DEBUG_BUILD #ifdef DEBUG_BUILD
SERIAL_ECHOLNPGM("plan_set_position()"); SERIAL_ECHOLNPGM("plan_set_position()");
MYSERIAL.println(current_position[X_AXIS]);MYSERIAL.println(current_position[Y_AXIS]); MYSERIAL.println(current_position[X_AXIS]);
MYSERIAL.println(current_position[Z_AXIS]);MYSERIAL.println(current_position[E_AXIS]); MYSERIAL.println(current_position[Y_AXIS]);
MYSERIAL.println(current_position[Z_AXIS]);
MYSERIAL.println(current_position[E_AXIS]);
#endif #endif
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
#ifdef DEBUG_BUILD #ifdef DEBUG_BUILD
SERIAL_ECHOLNPGM("plan_buffer_line()"); SERIAL_ECHOLNPGM("plan_buffer_line()");
MYSERIAL.println(destination[X_AXIS]);MYSERIAL.println(destination[Y_AXIS]); MYSERIAL.println(destination[X_AXIS]);
MYSERIAL.println(destination[Z_AXIS]);MYSERIAL.println(destination[E_AXIS]); MYSERIAL.println(destination[Y_AXIS]);
MYSERIAL.println(feedrate);MYSERIAL.println(active_extruder); MYSERIAL.println(destination[Z_AXIS]);
MYSERIAL.println(destination[E_AXIS]);
MYSERIAL.println(feedrate);
MYSERIAL.println(active_extruder);
#endif #endif
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
st_synchronize(); st_synchronize();
@ -2683,13 +2728,18 @@ void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, long home_
} }
#endif #endif
if (farm_mode) { prusa_statistics(20); }; if (farm_mode) {
prusa_statistics(20);
};
homing_flag = false; homing_flag = false;
#if 0 #if 0
SERIAL_ECHOPGM("G28, final "); print_world_coordinates(); SERIAL_ECHOPGM("G28, final ");
SERIAL_ECHOPGM("G28, final "); print_physical_coordinates(); print_world_coordinates();
SERIAL_ECHOPGM("G28, final "); print_mesh_bed_leveling_table(); SERIAL_ECHOPGM("G28, final ");
print_physical_coordinates();
SERIAL_ECHOPGM("G28, final ");
print_mesh_bed_leveling_table();
#endif #endif
} }
@ -4100,7 +4150,8 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
printf_P(_N("\nZERO: %.3f\n"), current_position[Z_AXIS]); printf_P(_N("\nZERO: %.3f\n"), current_position[Z_AXIS]);
int i = -1; for (; i < 5; i++) int i = -1;
for (; i < 5; i++)
{ {
float temp = (40 + i * 5); float temp = (40 + i * 5);
printf_P(_N("\nStep: %d/6 (skipped)\nPINDA temperature: %d Z shift (mm):0\n"), i + 2, (40 + i*5)); printf_P(_N("\nStep: %d/6 (skipped)\nPINDA temperature: %d Z shift (mm):0\n"), i + 2, (40 + i*5));
@ -4272,14 +4323,27 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
if (code_seen('X')) dimension_x = code_value(); if (code_seen('X')) dimension_x = code_value();
if (code_seen('Y')) dimension_y = code_value(); if (code_seen('Y')) dimension_y = code_value();
if (code_seen("XP")) { strchr_pointer+=1; points_x = code_value(); } if (code_seen("XP")) {
if (code_seen("YP")) { strchr_pointer+=1; points_y = code_value(); } strchr_pointer+=1;
if (code_seen("XO")) { strchr_pointer+=1; offset_x = code_value(); } points_x = code_value();
if (code_seen("YO")) { strchr_pointer+=1; offset_y = code_value(); } }
if (code_seen("YP")) {
strchr_pointer+=1;
points_y = code_value();
}
if (code_seen("XO")) {
strchr_pointer+=1;
offset_x = code_value();
}
if (code_seen("YO")) {
strchr_pointer+=1;
offset_y = code_value();
}
bed_analysis(dimension_x,dimension_y,points_x,points_y,offset_x,offset_y); bed_analysis(dimension_x,dimension_y,points_x,points_y,offset_x,offset_y);
} break; }
break;
#endif #endif
@ -4293,7 +4357,8 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
} }
printf_P(_N("%d: %d\n"), i, fan_speed[1]); printf_P(_N("%d: %d\n"), i, fan_speed[1]);
} }
}break; }
break;
/** /**
* G80: Mesh-based Z probe, probes a grid and produces a * G80: Mesh-based Z probe, probes a grid and produces a
@ -4960,7 +5025,8 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
if(!call_procedure) if(!call_procedure)
starttime=millis(); //procedure calls count as normal print time. starttime=millis(); //procedure calls count as normal print time.
} }
} break; }
break;
case 928: //M928 - Start SD write case 928: //M928 - Start SD write
starpos = (strchr(strchr_pointer + 5,'*')); starpos = (strchr(strchr_pointer + 5,'*'));
if(starpos != NULL) { if(starpos != NULL) {
@ -5483,7 +5549,8 @@ Sigma_Exit:
SERIAL_PROTOCOL(cur_extruder); SERIAL_PROTOCOL(cur_extruder);
SERIAL_PROTOCOLPGM("->"); SERIAL_PROTOCOLPGM("->");
SERIAL_PROTOCOL_F(raw, 5); SERIAL_PROTOCOL_F(raw, 5);
}} }
}
#endif #endif
SERIAL_PROTOCOLLN(""); SERIAL_PROTOCOLLN("");
KEEPALIVE_STATE(NOT_BUSY); KEEPALIVE_STATE(NOT_BUSY);
@ -5498,7 +5565,9 @@ Sigma_Exit:
} }
LCD_MESSAGERPGM(_T(MSG_HEATING)); LCD_MESSAGERPGM(_T(MSG_HEATING));
heating_status = 1; heating_status = 1;
if (farm_mode) { prusa_statistics(1); }; if (farm_mode) {
prusa_statistics(1);
};
#ifdef AUTOTEMP #ifdef AUTOTEMP
autotemp_enabled=false; autotemp_enabled=false;
@ -5535,7 +5604,9 @@ Sigma_Exit:
LCD_MESSAGERPGM(_T(MSG_HEATING_COMPLETE)); LCD_MESSAGERPGM(_T(MSG_HEATING_COMPLETE));
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);
heating_status = 2; heating_status = 2;
if (farm_mode) { prusa_statistics(2); }; if (farm_mode) {
prusa_statistics(2);
};
//starttime=millis(); //starttime=millis();
previous_millis_cmd = millis(); previous_millis_cmd = millis();
@ -5545,7 +5616,9 @@ Sigma_Exit:
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
LCD_MESSAGERPGM(_T(MSG_BED_HEATING)); LCD_MESSAGERPGM(_T(MSG_BED_HEATING));
heating_status = 3; heating_status = 3;
if (farm_mode) { prusa_statistics(1); }; if (farm_mode) {
prusa_statistics(1);
};
if (code_seen('S')) if (code_seen('S'))
{ {
setTargetBed(code_value()); setTargetBed(code_value());
@ -6002,7 +6075,8 @@ Sigma_Exit:
{ {
cs.retract_zlift = code_value() ; cs.retract_zlift = code_value() ;
} }
}break; }
break;
case 208: // M208 - set retract recover length S[positive mm surplus to the M207 S*] F[feedrate mm/min] case 208: // M208 - set retract recover length S[positive mm surplus to the M207 S*] F[feedrate mm/min]
{ {
if(code_seen('S')) if(code_seen('S'))
@ -6013,7 +6087,8 @@ Sigma_Exit:
{ {
cs.retract_recover_feedrate = code_value()/60 ; cs.retract_recover_feedrate = code_value()/60 ;
} }
}break; }
break;
case 209: // M209 - S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction. case 209: // M209 - S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction.
{ {
if(code_seen('S')) if(code_seen('S'))
@ -6031,7 +6106,8 @@ Sigma_Exit:
#if EXTRUDERS > 2 #if EXTRUDERS > 2
retracted[2]=false; retracted[2]=false;
#endif #endif
}break; }
break;
case 1: case 1:
{ {
cs.autoretract_enabled=true; cs.autoretract_enabled=true;
@ -6042,7 +6118,8 @@ Sigma_Exit:
#if EXTRUDERS > 2 #if EXTRUDERS > 2
retracted[2]=false; retracted[2]=false;
#endif #endif
}break; }
break;
default: default:
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHORPGM(MSG_UNKNOWN_COMMAND); SERIAL_ECHORPGM(MSG_UNKNOWN_COMMAND);
@ -6051,7 +6128,8 @@ Sigma_Exit:
} }
} }
}break; }
break;
#endif // FWRETRACT #endif // FWRETRACT
#if EXTRUDERS > 1 #if EXTRUDERS > 1
case 218: // M218 - set hotend offset (in mm), T<extruder_number> X<offset_on_X> Y<offset_on_Y> case 218: // M218 - set hotend offset (in mm), T<extruder_number> X<offset_on_X> Y<offset_on_Y>
@ -6078,7 +6156,8 @@ Sigma_Exit:
SERIAL_ECHO(extruder_offset[Y_AXIS][extruder]); SERIAL_ECHO(extruder_offset[Y_AXIS][extruder]);
} }
SERIAL_ECHOLN(""); SERIAL_ECHOLN("");
}break; }
break;
#endif #endif
case 220: // M220 S<factor in percent>- set speed factor override percentage case 220: // M220 S<factor in percent>- set speed factor override percentage
{ {
@ -7016,49 +7095,63 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
{ {
#ifdef DEBUG_DCODES #ifdef DEBUG_DCODES
case -1: //! D-1 - Endless loop case -1: //! D-1 - Endless loop
dcode__1(); break; dcode__1();
break;
case 0: //! D0 - Reset case 0: //! D0 - Reset
dcode_0(); break; dcode_0();
break;
case 1: //! D1 - Clear EEPROM case 1: //! D1 - Clear EEPROM
dcode_1(); break; dcode_1();
break;
case 2: //! D2 - Read/Write RAM case 2: //! D2 - Read/Write RAM
dcode_2(); break; dcode_2();
break;
#endif //DEBUG_DCODES #endif //DEBUG_DCODES
#ifdef DEBUG_DCODE3 #ifdef DEBUG_DCODE3
case 3: //! D3 - Read/Write EEPROM case 3: //! D3 - Read/Write EEPROM
dcode_3(); break; dcode_3();
break;
#endif //DEBUG_DCODE3 #endif //DEBUG_DCODE3
#ifdef DEBUG_DCODES #ifdef DEBUG_DCODES
case 4: //! D4 - Read/Write PIN case 4: //! D4 - Read/Write PIN
dcode_4(); break; dcode_4();
break;
#endif //DEBUG_DCODES #endif //DEBUG_DCODES
#ifdef DEBUG_DCODE5 #ifdef DEBUG_DCODE5
case 5: // D5 - Read/Write FLASH case 5: // D5 - Read/Write FLASH
dcode_5(); break; dcode_5();
break;
break; break;
#endif //DEBUG_DCODE5 #endif //DEBUG_DCODE5
#ifdef DEBUG_DCODES #ifdef DEBUG_DCODES
case 6: // D6 - Read/Write external FLASH case 6: // D6 - Read/Write external FLASH
dcode_6(); break; dcode_6();
break;
case 7: //! D7 - Read/Write Bootloader case 7: //! D7 - Read/Write Bootloader
dcode_7(); break; dcode_7();
break;
case 8: //! D8 - Read/Write PINDA case 8: //! D8 - Read/Write PINDA
dcode_8(); break; dcode_8();
break;
case 9: //! D9 - Read/Write ADC case 9: //! D9 - Read/Write ADC
dcode_9(); break; dcode_9();
break;
case 10: //! D10 - XYZ calibration = OK case 10: //! D10 - XYZ calibration = OK
dcode_10(); break; dcode_10();
break;
#ifdef TMC2130 #ifdef TMC2130
case 2130: //! D2130 - TMC2130 case 2130: //! D2130 - TMC2130
dcode_2130(); break; dcode_2130();
break;
#endif //TMC2130 #endif //TMC2130
#ifdef FILAMENT_SENSOR #ifdef FILAMENT_SENSOR
case 9125: //! D9125 - FILAMENT_SENSOR case 9125: //! D9125 - FILAMENT_SENSOR
dcode_9125(); break; dcode_9125();
break;
#endif //FILAMENT_SENSOR #endif //FILAMENT_SENSOR
#endif //DEBUG_DCODES #endif //DEBUG_DCODES
@ -7592,7 +7685,9 @@ void Stop()
} }
} }
bool IsStopped() { return Stopped; }; bool IsStopped() {
return Stopped;
};
#ifdef FAST_PWM_FAN #ifdef FAST_PWM_FAN
void setPwmFrequency(uint8_t pin, int val) void setPwmFrequency(uint8_t pin, int val)
@ -8571,9 +8666,12 @@ void recover_machine_state_after_power_panic(bool bTiny)
// 6) Power up the motors, mark their positions as known. // 6) Power up the motors, mark their positions as known.
//FIXME Verfiy, whether the X and Y axes should be powered up here, as they will later be re-homed anyway. //FIXME Verfiy, whether the X and Y axes should be powered up here, as they will later be re-homed anyway.
axis_known_position[X_AXIS] = true; enable_x(); axis_known_position[X_AXIS] = true;
axis_known_position[Y_AXIS] = true; enable_y(); enable_x();
axis_known_position[Z_AXIS] = true; enable_z(); axis_known_position[Y_AXIS] = true;
enable_y();
axis_known_position[Z_AXIS] = true;
enable_z();
SERIAL_ECHOPGM("recover_machine_state_after_power_panic, initial "); SERIAL_ECHOPGM("recover_machine_state_after_power_panic, initial ");
print_physical_coordinates(); print_physical_coordinates();
@ -8635,12 +8733,15 @@ void restore_print_from_eeprom() {
// E axis relative mode. // E axis relative mode.
enquecommand_P(PSTR("M83")); enquecommand_P(PSTR("M83"));
// Move to the XY print position in logical coordinates, where the print has been killed. // Move to the XY print position in logical coordinates, where the print has been killed.
strcpy_P(cmd, PSTR("G1 X")); strcat(cmd, ftostr32(eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0)))); strcpy_P(cmd, PSTR("G1 X"));
strcat_P(cmd, PSTR(" Y")); strcat(cmd, ftostr32(eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4)))); strcat(cmd, ftostr32(eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0))));
strcat_P(cmd, PSTR(" Y"));
strcat(cmd, ftostr32(eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4))));
strcat_P(cmd, PSTR(" F2000")); strcat_P(cmd, PSTR(" F2000"));
enquecommand(cmd); enquecommand(cmd);
// Move the Z axis down to the print, in logical coordinates. // Move the Z axis down to the print, in logical coordinates.
strcpy_P(cmd, PSTR("G1 Z")); strcat(cmd, ftostr32(eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z)))); strcpy_P(cmd, PSTR("G1 Z"));
strcat(cmd, ftostr32(eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z))));
enquecommand(cmd); enquecommand(cmd);
// Unretract. // Unretract.
enquecommand_P(PSTR("G1 E" STRINGIFY(2*default_retraction)" F480")); enquecommand_P(PSTR("G1 E" STRINGIFY(2*default_retraction)" F480"));
@ -8710,12 +8811,18 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
} }
#if 0 #if 0
SERIAL_ECHOPGM("SDPOS_ATOMIC="); MYSERIAL.println(sdpos_atomic, DEC); SERIAL_ECHOPGM("SDPOS_ATOMIC=");
SERIAL_ECHOPGM("SDPOS="); MYSERIAL.println(card.get_sdpos(), DEC); MYSERIAL.println(sdpos_atomic, DEC);
SERIAL_ECHOPGM("SDLEN_PLAN="); MYSERIAL.println(sdlen_planner, DEC); SERIAL_ECHOPGM("SDPOS=");
SERIAL_ECHOPGM("SDLEN_CMDQ="); MYSERIAL.println(sdlen_cmdqueue, DEC); MYSERIAL.println(card.get_sdpos(), DEC);
SERIAL_ECHOPGM("PLANNERBLOCKS="); MYSERIAL.println(int(nplanner_blocks), DEC); SERIAL_ECHOPGM("SDLEN_PLAN=");
SERIAL_ECHOPGM("SDSAVED="); MYSERIAL.println(saved_sdpos, DEC); MYSERIAL.println(sdlen_planner, DEC);
SERIAL_ECHOPGM("SDLEN_CMDQ=");
MYSERIAL.println(sdlen_cmdqueue, DEC);
SERIAL_ECHOPGM("PLANNERBLOCKS=");
MYSERIAL.println(int(nplanner_blocks), DEC);
SERIAL_ECHOPGM("SDSAVED=");
MYSERIAL.println(saved_sdpos, DEC);
//SERIAL_ECHOPGM("SDFILELEN="); MYSERIAL.println(card.fileSize(), DEC); //SERIAL_ECHOPGM("SDFILELEN="); MYSERIAL.println(card.fileSize(), DEC);

View File

@ -170,13 +170,19 @@ class Sd2Card {
* Set SD error code. * Set SD error code.
* \param[in] code value for error code. * \param[in] code value for error code.
*/ */
void error(uint8_t code) {errorCode_ = code;} void error(uint8_t code) {
errorCode_ = code;
}
/** /**
* \return error code for last error. See Sd2Card.h for a list of error codes. * \return error code for last error. See Sd2Card.h for a list of error codes.
*/ */
int errorCode() const {return errorCode_;} int errorCode() const {
return errorCode_;
}
/** \return error data for last error. */ /** \return error data for last error. */
int errorData() const {return status_;} int errorData() const {
return status_;
}
/** /**
* Initialize an SD flash memory card with default clock rate and chip * Initialize an SD flash memory card with default clock rate and chip
* select pin. See sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin). * select pin. See sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin).
@ -216,7 +222,9 @@ class Sd2Card {
/** Return the card type: SD V1, SD V2 or SDHC /** Return the card type: SD V1, SD V2 or SDHC
* \return 0 - SD V1, 1 - SD V2, or 3 - SDHC. * \return 0 - SD V1, 1 - SD V2, or 3 - SDHC.
*/ */
int type() const {return type_;} int type() const {
return type_;
}
bool writeBlock(uint32_t blockNumber, const uint8_t* src); bool writeBlock(uint32_t blockNumber, const uint8_t* src);
bool writeData(const uint8_t* src); bool writeData(const uint8_t* src);
bool writeStart(uint32_t blockNumber, uint32_t eraseCount); bool writeStart(uint32_t blockNumber, uint32_t eraseCount);
@ -225,8 +233,12 @@ class Sd2Card {
// Toshiba FlashAir support // Toshiba FlashAir support
uint8_t readExtMemory(uint8_t mio, uint8_t func, uint32_t addr, uint16_t count, uint8_t* dst); uint8_t readExtMemory(uint8_t mio, uint8_t func, uint32_t addr, uint16_t count, uint8_t* dst);
void setFlashAirCompatible(bool flashAirCompatible) { flash_air_compatible_ = flashAirCompatible; } void setFlashAirCompatible(bool flashAirCompatible) {
bool getFlashAirCompatible() const { return flash_air_compatible_; } flash_air_compatible_ = flashAirCompatible;
}
bool getFlashAirCompatible() const {
return flash_air_compatible_;
}
private: private:
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -247,7 +259,9 @@ class Sd2Card {
bool readRegister(uint8_t cmd, void* buf); bool readRegister(uint8_t cmd, void* buf);
void chipSelectHigh(); void chipSelectHigh();
void chipSelectLow(); void chipSelectLow();
void type(uint8_t value) {type_ = value;} void type(uint8_t value) {
type_ = value;
}
bool waitNotBusy(uint16_t timeoutMillis); bool waitNotBusy(uint16_t timeoutMillis);
bool writeData(uint8_t token, const uint8_t* src); bool writeData(uint8_t token, const uint8_t* src);

View File

@ -184,7 +184,9 @@ class SdBaseFile {
/** Create an instance. */ /** Create an instance. */
SdBaseFile() : writeError(false), type_(FAT_FILE_TYPE_CLOSED) {} SdBaseFile() : writeError(false), type_(FAT_FILE_TYPE_CLOSED) {}
SdBaseFile(const char* path, uint8_t oflag); SdBaseFile(const char* path, uint8_t oflag);
~SdBaseFile() {if(isOpen()) close();} ~SdBaseFile() {
if(isOpen()) close();
}
/** /**
* writeError is set to true if an error occurs during a write(). * writeError is set to true if an error occurs during a write().
* Set writeError to false before calling print() and/or write() and check * Set writeError to false before calling print() and/or write() and check
@ -207,11 +209,17 @@ class SdBaseFile {
bool createContiguous(SdBaseFile* dirFile, bool createContiguous(SdBaseFile* dirFile,
const char* path, uint32_t size); const char* path, uint32_t size);
/** \return The current cluster number for a file or directory. */ /** \return The current cluster number for a file or directory. */
uint32_t curCluster() const {return curCluster_;} uint32_t curCluster() const {
return curCluster_;
}
/** \return The current position for a file or directory. */ /** \return The current position for a file or directory. */
uint32_t curPosition() const {return curPosition_;} uint32_t curPosition() const {
return curPosition_;
}
/** \return Current working directory */ /** \return Current working directory */
static SdBaseFile* cwd() {return cwd_;} static SdBaseFile* cwd() {
return cwd_;
}
/** Set the date/time callback function /** Set the date/time callback function
* *
* \param[in] dateTime The user's call back function. The callback * \param[in] dateTime The user's call back function. The callback
@ -244,24 +252,38 @@ class SdBaseFile {
dateTime_ = dateTime; dateTime_ = dateTime;
} }
/** Cancel the date/time callback function. */ /** Cancel the date/time callback function. */
static void dateTimeCallbackCancel() {dateTime_ = 0;} static void dateTimeCallbackCancel() {
dateTime_ = 0;
}
bool dirEntry(dir_t* dir); bool dirEntry(dir_t* dir);
static void dirName(const dir_t& dir, char* name); static void dirName(const dir_t& dir, char* name);
bool exists(const char* name); bool exists(const char* name);
int16_t fgets(char* str, int16_t num, char* delim = 0); int16_t fgets(char* str, int16_t num, char* delim = 0);
/** \return The total number of bytes in a file or directory. */ /** \return The total number of bytes in a file or directory. */
uint32_t fileSize() const {return fileSize_;} uint32_t fileSize() const {
return fileSize_;
}
/** \return The first cluster number for a file or directory. */ /** \return The first cluster number for a file or directory. */
uint32_t firstCluster() const {return firstCluster_;} uint32_t firstCluster() const {
return firstCluster_;
}
bool getFilename(char* name); bool getFilename(char* name);
/** \return True if this is a directory else false. */ /** \return True if this is a directory else false. */
bool isDir() const {return type_ >= FAT_FILE_TYPE_MIN_DIR;} bool isDir() const {
return type_ >= FAT_FILE_TYPE_MIN_DIR;
}
/** \return True if this is a normal file else false. */ /** \return True if this is a normal file else false. */
bool isFile() const {return type_ == FAT_FILE_TYPE_NORMAL;} bool isFile() const {
return type_ == FAT_FILE_TYPE_NORMAL;
}
/** \return True if this is an open file/directory else false. */ /** \return True if this is an open file/directory else false. */
bool isOpen() const {return type_ != FAT_FILE_TYPE_CLOSED;} bool isOpen() const {
return type_ != FAT_FILE_TYPE_CLOSED;
}
/** \return True if this is a subdirectory else false. */ /** \return True if this is a subdirectory else false. */
bool isSubDir() const {return type_ == FAT_FILE_TYPE_SUBDIR;} bool isSubDir() const {
return type_ == FAT_FILE_TYPE_SUBDIR;
}
/** \return True if this is the root directory. */ /** \return True if this is the root directory. */
bool isRoot() const { bool isRoot() const {
return type_ == FAT_FILE_TYPE_ROOT_FIXED || type_ == FAT_FILE_TYPE_ROOT32; return type_ == FAT_FILE_TYPE_ROOT_FIXED || type_ == FAT_FILE_TYPE_ROOT32;
@ -287,11 +309,15 @@ class SdBaseFile {
static bool remove(SdBaseFile* dirFile, const char* path); static bool remove(SdBaseFile* dirFile, const char* path);
bool remove(); bool remove();
/** Set the file's current position to zero. */ /** Set the file's current position to zero. */
void rewind() {seekSet(0);} void rewind() {
seekSet(0);
}
bool rename(SdBaseFile* dirFile, const char* newPath); bool rename(SdBaseFile* dirFile, const char* newPath);
bool rmdir(); bool rmdir();
// for backward compatibility // for backward compatibility
bool rmDir() {return rmdir();} bool rmDir() {
return rmdir();
}
bool rmRfStar(); bool rmRfStar();
/** Set the files position to current position + \a pos. See seekSet(). /** Set the files position to current position + \a pos. See seekSet().
* \param[in] offset The new position in bytes from the current position. * \param[in] offset The new position in bytes from the current position.
@ -304,7 +330,9 @@ class SdBaseFile {
* \param[in] offset The new position in bytes from end-of-file. * \param[in] offset The new position in bytes from end-of-file.
* \return true for success or false for failure. * \return true for success or false for failure.
*/ */
bool seekEnd(int32_t offset = 0) {return seekSet(fileSize_ + offset);} bool seekEnd(int32_t offset = 0) {
return seekSet(fileSize_ + offset);
}
bool seekSet(uint32_t pos); bool seekSet(uint32_t pos);
bool sync(); bool sync();
bool timestamp(SdBaseFile* file); bool timestamp(SdBaseFile* file);
@ -315,10 +343,14 @@ class SdBaseFile {
* *
* \return The file or directory type. * \return The file or directory type.
*/ */
uint8_t type() const {return type_;} uint8_t type() const {
return type_;
}
bool truncate(uint32_t size); bool truncate(uint32_t size);
/** \return SdVolume that contains this file. */ /** \return SdVolume that contains this file. */
SdVolume* volume() const {return vol_;} SdVolume* volume() const {
return vol_;
}
int16_t write(const void* buf, uint16_t nbyte); int16_t write(const void* buf, uint16_t nbyte);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
private: private:
@ -401,7 +433,9 @@ class SdBaseFile {
* \param[out] dir Location for return of the file's directory entry. * \param[out] dir Location for return of the file's directory entry.
* \return true for success or false for failure. * \return true for success or false for failure.
*/ */
bool dirEntry(dir_t& dir) {return dirEntry(&dir);} // NOLINT bool dirEntry(dir_t& dir) {
return dirEntry(&dir); // NOLINT
}
/** \deprecated Use: /** \deprecated Use:
* bool mkdir(SdBaseFile* dir, const char* path); * bool mkdir(SdBaseFile* dir, const char* path);
* \param[in] dir An open SdFat instance for the directory that will contain * \param[in] dir An open SdFat instance for the directory that will contain
@ -450,12 +484,16 @@ class SdBaseFile {
* \param[in] vol The FAT volume containing the root directory to be opened. * \param[in] vol The FAT volume containing the root directory to be opened.
* \return true for success or false for failure. * \return true for success or false for failure.
*/ */
bool openRoot(SdVolume& vol) {return openRoot(&vol);} // NOLINT bool openRoot(SdVolume& vol) {
return openRoot(&vol); // NOLINT
}
/** \deprecated Use: int8_t readDir(dir_t* dir); /** \deprecated Use: int8_t readDir(dir_t* dir);
* \param[out] dir The dir_t struct that will receive the data. * \param[out] dir The dir_t struct that will receive the data.
* \return bytes read for success zero for eof or -1 for failure. * \return bytes read for success zero for eof or -1 for failure.
*/ */
int8_t readDir(dir_t& dir, char* longFilename) {return readDir(&dir, longFilename);} // NOLINT int8_t readDir(dir_t& dir, char* longFilename) {
return readDir(&dir, longFilename); // NOLINT
}
/** \deprecated Use: /** \deprecated Use:
* static uint8_t remove(SdBaseFile* dirFile, const char* path); * static uint8_t remove(SdBaseFile* dirFile, const char* path);
* \param[in] dirFile The directory that contains the file. * \param[in] dirFile The directory that contains the file.

View File

@ -33,7 +33,7 @@
* \class SdFile * \class SdFile
* \brief SdBaseFile with Print. * \brief SdBaseFile with Print.
*/ */
class SdFile : public SdBaseFile/*, public Print*/ { class SdFile : public SdBaseFile { /*, public Print*/
public: public:
SdFile() {} SdFile() {}
SdFile(const char* name, uint8_t oflag); SdFile(const char* name, uint8_t oflag);

View File

@ -80,43 +80,69 @@ class SdVolume {
* failure include not finding a valid partition, not finding a valid * failure include not finding a valid partition, not finding a valid
* FAT file system or an I/O error. * FAT file system or an I/O error.
*/ */
bool init(Sd2Card* dev) { return init(dev, 1) ? true : init(dev, 0);} bool init(Sd2Card* dev) {
return init(dev, 1) ? true : init(dev, 0);
}
bool init(Sd2Card* dev, uint8_t part); bool init(Sd2Card* dev, uint8_t part);
// inline functions that return volume info // inline functions that return volume info
/** \return The volume's cluster size in blocks. */ /** \return The volume's cluster size in blocks. */
uint8_t blocksPerCluster() const {return blocksPerCluster_;} uint8_t blocksPerCluster() const {
return blocksPerCluster_;
}
/** \return The number of blocks in one FAT. */ /** \return The number of blocks in one FAT. */
uint32_t blocksPerFat() const {return blocksPerFat_;} uint32_t blocksPerFat() const {
return blocksPerFat_;
}
/** \return The total number of clusters in the volume. */ /** \return The total number of clusters in the volume. */
uint32_t clusterCount() const {return clusterCount_;} uint32_t clusterCount() const {
return clusterCount_;
}
/** \return The shift count required to multiply by blocksPerCluster. */ /** \return The shift count required to multiply by blocksPerCluster. */
uint8_t clusterSizeShift() const {return clusterSizeShift_;} uint8_t clusterSizeShift() const {
return clusterSizeShift_;
}
/** \return The logical block number for the start of file data. */ /** \return The logical block number for the start of file data. */
uint32_t dataStartBlock() const {return dataStartBlock_;} uint32_t dataStartBlock() const {
return dataStartBlock_;
}
/** \return The number of FAT structures on the volume. */ /** \return The number of FAT structures on the volume. */
uint8_t fatCount() const {return fatCount_;} uint8_t fatCount() const {
return fatCount_;
}
/** \return The logical block number for the start of the first FAT. */ /** \return The logical block number for the start of the first FAT. */
uint32_t fatStartBlock() const {return fatStartBlock_;} uint32_t fatStartBlock() const {
return fatStartBlock_;
}
/** \return The FAT type of the volume. Values are 12, 16 or 32. */ /** \return The FAT type of the volume. Values are 12, 16 or 32. */
uint8_t fatType() const {return fatType_;} uint8_t fatType() const {
return fatType_;
}
int32_t freeClusterCount(); int32_t freeClusterCount();
/** \return The number of entries in the root directory for FAT16 volumes. */ /** \return The number of entries in the root directory for FAT16 volumes. */
uint32_t rootDirEntryCount() const {return rootDirEntryCount_;} uint32_t rootDirEntryCount() const {
return rootDirEntryCount_;
}
/** \return The logical block number for the start of the root directory /** \return The logical block number for the start of the root directory
on FAT16 volumes or the first cluster number on FAT32 volumes. */ on FAT16 volumes or the first cluster number on FAT32 volumes. */
uint32_t rootDirStart() const {return rootDirStart_;} uint32_t rootDirStart() const {
return rootDirStart_;
}
/** Sd2Card object for this volume /** Sd2Card object for this volume
* \return pointer to Sd2Card object. * \return pointer to Sd2Card object.
*/ */
Sd2Card* sdCard() {return sdCard_;} Sd2Card* sdCard() {
return sdCard_;
}
/** Debug access to FAT table /** Debug access to FAT table
* *
* \param[in] n cluster number. * \param[in] n cluster number.
* \param[out] v value of entry * \param[out] v value of entry
* \return true for success or false for failure * \return true for success or false for failure
*/ */
bool dbgFat(uint32_t n, uint32_t* v) {return fatGet(n, v);} bool dbgFat(uint32_t n, uint32_t* v) {
return fatGet(n, v);
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
private: private:
// Allow SdBaseFile access to SdVolume private data. // Allow SdBaseFile access to SdVolume private data.
@ -154,13 +180,20 @@ class SdVolume {
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool allocContiguous(uint32_t count, uint32_t* curCluster); bool allocContiguous(uint32_t count, uint32_t* curCluster);
uint8_t blockOfCluster(uint32_t position) const { uint8_t blockOfCluster(uint32_t position) const {
return (position >> 9) & (blocksPerCluster_ - 1);} return (position >> 9) & (blocksPerCluster_ - 1);
}
uint32_t clusterStartBlock(uint32_t cluster) const { uint32_t clusterStartBlock(uint32_t cluster) const {
return dataStartBlock_ + ((cluster - 2) << clusterSizeShift_);} return dataStartBlock_ + ((cluster - 2) << clusterSizeShift_);
}
uint32_t blockNumber(uint32_t cluster, uint32_t position) const { uint32_t blockNumber(uint32_t cluster, uint32_t position) const {
return clusterStartBlock(cluster) + blockOfCluster(position);} return clusterStartBlock(cluster) + blockOfCluster(position);
cache_t *cache() {return &cacheBuffer_;} }
uint32_t cacheBlockNumber() {return cacheBlockNumber_;} cache_t *cache() {
return &cacheBuffer_;
}
uint32_t cacheBlockNumber() {
return cacheBlockNumber_;
}
#if USE_MULTIPLE_CARDS #if USE_MULTIPLE_CARDS
bool cacheFlush(); bool cacheFlush();
bool cacheRawBlock(uint32_t blockNumber, bool dirty); bool cacheRawBlock(uint32_t blockNumber, bool dirty);
@ -173,7 +206,9 @@ class SdVolume {
cacheDirty_ = dirty; cacheDirty_ = dirty;
cacheBlockNumber_ = blockNumber; cacheBlockNumber_ = blockNumber;
} }
void cacheSetDirty() {cacheDirty_ |= CACHE_FOR_WRITE;} void cacheSetDirty() {
cacheDirty_ |= CACHE_FOR_WRITE;
}
bool chainSize(uint32_t beginCluster, uint32_t* size); bool chainSize(uint32_t beginCluster, uint32_t* size);
bool fatGet(uint32_t cluster, uint32_t* value); bool fatGet(uint32_t cluster, uint32_t* value);
bool fatPut(uint32_t cluster, uint32_t value); bool fatPut(uint32_t cluster, uint32_t value);
@ -187,7 +222,8 @@ class SdVolume {
return cluster >= FAT32EOC_MIN; return cluster >= FAT32EOC_MIN;
} }
bool readBlock(uint32_t block, uint8_t* dst) { bool readBlock(uint32_t block, uint8_t* dst) {
return sdCard_->readBlock(block, dst);} return sdCard_->readBlock(block, dst);
}
bool writeBlock(uint32_t block, const uint8_t* dst) { bool writeBlock(uint32_t block, const uint8_t* dst) {
return sdCard_->writeBlock(block, dst); return sdCard_->writeBlock(block, dst);
} }
@ -199,7 +235,9 @@ class SdVolume {
* \param[in] dev The SD card where the volume is located. * \param[in] dev The SD card where the volume is located.
* \return true for success or false for failure. * \return true for success or false for failure.
*/ */
bool init(Sd2Card& dev) {return init(&dev);} // NOLINT bool init(Sd2Card& dev) {
return init(&dev); // NOLINT
}
/** \deprecated Use: bool SdVolume::init(Sd2Card* dev, uint8_t vol); /** \deprecated Use: bool SdVolume::init(Sd2Card* dev, uint8_t vol);
* \param[in] dev The SD card where the volume is located. * \param[in] dev The SD card where the volume is located.
* \param[in] part The partition to be used. * \param[in] part The partition to be used.

View File

@ -263,7 +263,8 @@ uint8_t Servo::attach(int pin, int min, int max)
{ {
if(this->servoIndex < MAX_SERVOS ) { if(this->servoIndex < MAX_SERVOS ) {
#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0) #if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
if (pin > 0) this->pin = pin; else pin = this->pin; if (pin > 0) this->pin = pin;
else pin = this->pin;
#endif #endif
pinMode( pin, OUTPUT) ; // set servo pin to output pinMode( pin, OUTPUT) ; // set servo pin to output
servos[this->servoIndex].Pin.nbr = pin; servos[this->servoIndex].Pin.nbr = pin;

View File

@ -19,11 +19,17 @@ class Timer
public: public:
Timer(); Timer();
void start(); void start();
void stop(){m_isRunning = false;} void stop() {
bool running(){return m_isRunning;} m_isRunning = false;
}
bool running() {
return m_isRunning;
}
bool expired(T msPeriod); bool expired(T msPeriod);
protected: protected:
T started(){return m_started;} T started() {
return m_started;
}
private: private:
bool m_isRunning; bool m_isRunning;
T m_started; T m_started;

View File

@ -38,7 +38,8 @@ void adc_reset(void)
{ {
adc_state = 0; adc_state = 0;
adc_count = 0; adc_count = 0;
uint8_t i; for (i = 0; i < ADC_CHAN_CNT; i++) uint8_t i;
for (i = 0; i < ADC_CHAN_CNT; i++)
if ((adc_sim_mask & (1 << i)) == 0) if ((adc_sim_mask & (1 << i)) == 0)
adc_values[i] = 0; adc_values[i] = 0;
} }

View File

@ -276,12 +276,17 @@ uint16_t CardReader::getWorkDirDepth() {
void CardReader::getAbsFilename(char *t) void CardReader::getAbsFilename(char *t)
{ {
uint8_t cnt=0; uint8_t cnt=0;
*t='/';t++;cnt++; *t='/';
t++;
cnt++;
for(uint8_t i=0; i<workDirDepth; i++) for(uint8_t i=0; i<workDirDepth; i++)
{ {
workDirParents[i].getFilename(t); //SDBaseFile.getfilename! workDirParents[i].getFilename(t); //SDBaseFile.getfilename!
while(*t!=0 && cnt< MAXPATHNAMELENGTH) while(*t!=0 && cnt< MAXPATHNAMELENGTH)
{t++;cnt++;} //crawl counter forward. {
t++; //crawl counter forward.
cnt++;
}
} }
if(cnt<MAXPATHNAMELENGTH-13) if(cnt<MAXPATHNAMELENGTH-13)
file.getFilename(t); file.getFilename(t);

View File

@ -52,22 +52,52 @@ public:
#endif //SDSORT_QUICKSORT #endif //SDSORT_QUICKSORT
void getfilename_sorted(const uint16_t nr); void getfilename_sorted(const uint16_t nr);
#if SDSORT_GCODE #if SDSORT_GCODE
FORCE_INLINE void setSortOn(bool b) { sort_alpha = b; presort(); } FORCE_INLINE void setSortOn(bool b) {
FORCE_INLINE void setSortFolders(int i) { sort_folders = i; presort(); } sort_alpha = b;
presort();
}
FORCE_INLINE void setSortFolders(int i) {
sort_folders = i;
presort();
}
//FORCE_INLINE void setSortReverse(bool b) { sort_reverse = b; } //FORCE_INLINE void setSortReverse(bool b) { sort_reverse = b; }
#endif #endif
#endif #endif
FORCE_INLINE bool isFileOpen() { return file.isOpen(); } FORCE_INLINE bool isFileOpen() {
FORCE_INLINE bool eof() { return sdpos>=filesize ;}; return file.isOpen();
FORCE_INLINE int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();}; }
FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);}; FORCE_INLINE bool eof() {
FORCE_INLINE uint8_t percentDone(){if(!isFileOpen()) return 0; if(filesize) return sdpos/((filesize+99)/100); else return 0;}; return sdpos>=filesize ;
FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;}; };
FORCE_INLINE uint32_t get_sdpos() { if (!isFileOpen()) return 0; else return(sdpos); }; FORCE_INLINE int16_t get() {
sdpos = file.curPosition();
return (int16_t)file.read();
};
FORCE_INLINE void setIndex(long index) {
sdpos = index;
file.seekSet(index);
};
FORCE_INLINE uint8_t percentDone() {
if(!isFileOpen()) return 0;
if(filesize) return sdpos/((filesize+99)/100);
else return 0;
};
FORCE_INLINE char* getWorkDirName() {
workDir.getFilename(filename);
return filename;
};
FORCE_INLINE uint32_t get_sdpos() {
if (!isFileOpen()) return 0;
else return(sdpos);
};
bool ToshibaFlashAir_isEnabled() const { return card.getFlashAirCompatible(); } bool ToshibaFlashAir_isEnabled() const {
void ToshibaFlashAir_enable(bool enable) { card.setFlashAirCompatible(enable); } return card.getFlashAirCompatible();
}
void ToshibaFlashAir_enable(bool enable) {
card.setFlashAirCompatible(enable);
}
bool ToshibaFlashAir_GetIP(uint8_t *ip); bool ToshibaFlashAir_GetIP(uint8_t *ip);
public: public:

View File

@ -71,12 +71,24 @@ extern void get_command();
extern uint16_t cmdqueue_calc_sd_length(); extern uint16_t cmdqueue_calc_sd_length();
// Return True if a character was found // Return True if a character was found
static inline bool code_seen(char code) { return (strchr_pointer = strchr(CMDBUFFER_CURRENT_STRING, code)) != NULL; } static inline bool code_seen(char code) {
static inline bool code_seen(const char *code) { return (strchr_pointer = strstr(CMDBUFFER_CURRENT_STRING, code)) != NULL; } return (strchr_pointer = strchr(CMDBUFFER_CURRENT_STRING, code)) != NULL;
static inline float code_value() { return strtod(strchr_pointer+1, NULL);} }
static inline long code_value_long() { return strtol(strchr_pointer+1, NULL, 10); } static inline bool code_seen(const char *code) {
static inline int16_t code_value_short() { return int16_t(strtol(strchr_pointer+1, NULL, 10)); }; return (strchr_pointer = strstr(CMDBUFFER_CURRENT_STRING, code)) != NULL;
static inline uint8_t code_value_uint8() { return uint8_t(strtol(strchr_pointer+1, NULL, 10)); }; }
static inline float code_value() {
return strtod(strchr_pointer+1, NULL);
}
static inline long code_value_long() {
return strtol(strchr_pointer+1, NULL, 10);
}
static inline int16_t code_value_short() {
return int16_t(strtol(strchr_pointer+1, NULL, 10));
};
static inline uint8_t code_value_uint8() {
return uint8_t(strtol(strchr_pointer+1, NULL, 10));
};
static inline float code_value_float() static inline float code_value_float()
{ {

View File

@ -469,8 +469,12 @@ void fsensor_st_block_begin(block_t* bl)
((fsensor_st_cnt < 0) && !(bl->direction_bits & 0x8))) ((fsensor_st_cnt < 0) && !(bl->direction_bits & 0x8)))
{ {
// !!! bit toggling (PINxn <- 1) (for PinChangeInterrupt) does not work for some MCU pins // !!! bit toggling (PINxn <- 1) (for PinChangeInterrupt) does not work for some MCU pins
if (PIN_GET(FSENSOR_INT_PIN)) {PIN_VAL(FSENSOR_INT_PIN, LOW);} if (PIN_GET(FSENSOR_INT_PIN)) {
else {PIN_VAL(FSENSOR_INT_PIN, HIGH);} PIN_VAL(FSENSOR_INT_PIN, LOW);
}
else {
PIN_VAL(FSENSOR_INT_PIN, HIGH);
}
} }
} }
@ -481,8 +485,12 @@ void fsensor_st_block_chunk(block_t* bl, int cnt)
if ((fsensor_st_cnt >= fsensor_chunk_len) || (fsensor_st_cnt <= -fsensor_chunk_len)) if ((fsensor_st_cnt >= fsensor_chunk_len) || (fsensor_st_cnt <= -fsensor_chunk_len))
{ {
// !!! bit toggling (PINxn <- 1) (for PinChangeInterrupt) does not work for some MCU pins // !!! bit toggling (PINxn <- 1) (for PinChangeInterrupt) does not work for some MCU pins
if (PIN_GET(FSENSOR_INT_PIN)) {PIN_VAL(FSENSOR_INT_PIN, LOW);} if (PIN_GET(FSENSOR_INT_PIN)) {
else {PIN_VAL(FSENSOR_INT_PIN, HIGH);} PIN_VAL(FSENSOR_INT_PIN, LOW);
}
else {
PIN_VAL(FSENSOR_INT_PIN, HIGH);
}
} }
} }

View File

@ -17,12 +17,22 @@ uint8_t lang_selected = 0;
#if (LANG_MODE == 0) //primary language only #if (LANG_MODE == 0) //primary language only
uint8_t lang_select(uint8_t lang) { return 0; } uint8_t lang_select(uint8_t lang) {
uint8_t lang_get_count() { return 1; } return 0;
uint16_t lang_get_code(uint8_t lang) { return LANG_CODE_EN; } }
const char* lang_get_name_by_code(uint16_t code) { return _n("English"); } uint8_t lang_get_count() {
return 1;
}
uint16_t lang_get_code(uint8_t lang) {
return LANG_CODE_EN;
}
const char* lang_get_name_by_code(uint16_t code) {
return _n("English");
}
void lang_reset(void) { } void lang_reset(void) { }
uint8_t lang_is_selected(void) { return 1; } uint8_t lang_is_selected(void) {
return 1;
}
#else //(LANG_MODE == 0) //secondary languages in progmem or xflash #else //(LANG_MODE == 0) //secondary languages in progmem or xflash
@ -96,7 +106,8 @@ uint8_t lang_check(uint16_t addr)
uint16_t sum = 0; uint16_t sum = 0;
uint16_t size = pgm_read_word((uint16_t*)(addr + 4)); uint16_t size = pgm_read_word((uint16_t*)(addr + 4));
uint16_t lt_sum = pgm_read_word((uint16_t*)(addr + 8)); uint16_t lt_sum = pgm_read_word((uint16_t*)(addr + 8));
uint16_t i; for (i = 0; i < size; i++) uint16_t i;
for (i = 0; i < size; i++)
sum += (uint16_t)pgm_read_byte((uint8_t*)(addr + i)) << ((i & 1)?0:8); sum += (uint16_t)pgm_read_byte((uint8_t*)(addr + i)) << ((i & 1)?0:8);
sum -= lt_sum; //subtract checksum sum -= lt_sum; //subtract checksum
sum = (sum >> 8) | ((sum & 0xff) << 8); //swap bytes sum = (sum >> 8) | ((sum & 0xff) << 8); //swap bytes
@ -203,13 +214,20 @@ const char* lang_get_name_by_code(uint16_t code)
{ {
switch (code) switch (code)
{ {
case LANG_CODE_EN: return _n("English"); case LANG_CODE_EN:
case LANG_CODE_CZ: return _n("Cestina"); return _n("English");
case LANG_CODE_DE: return _n("Deutsch"); case LANG_CODE_CZ:
case LANG_CODE_ES: return _n("Espanol"); return _n("Cestina");
case LANG_CODE_FR: return _n("Francais"); case LANG_CODE_DE:
case LANG_CODE_IT: return _n("Italiano"); return _n("Deutsch");
case LANG_CODE_PL: return _n("Polski"); case LANG_CODE_ES:
return _n("Espanol");
case LANG_CODE_FR:
return _n("Francais");
case LANG_CODE_IT:
return _n("Italiano");
case LANG_CODE_PL:
return _n("Polski");
} }
return _n("??"); return _n("??");
} }

View File

@ -419,8 +419,10 @@ uint8_t lcd_escape_write(uint8_t chr)
case 2: case 2:
switch (chr) switch (chr)
{ {
case '2': return 1; // escape = "\x1b[2" case '2':
case '?': return 1; // escape = "\x1b[?" return 1; // escape = "\x1b[2"
case '?':
return 1; // escape = "\x1b[?"
default: default:
if (chr_is_num) return 1; // escape = "\x1b[%1d" if (chr_is_num) return 1; // escape = "\x1b[%1d"
} }
@ -433,7 +435,11 @@ uint8_t lcd_escape_write(uint8_t chr)
break; break;
case '2': case '2':
if (chr == 'J') // escape = "\x1b[2J" if (chr == 'J') // escape = "\x1b[2J"
{ lcd_clear(); lcd_currline = 0; break; } // EraseScreen {
lcd_clear(); // EraseScreen
lcd_currline = 0;
break;
}
default: default:
if (e_2_is_num && // escape = "\x1b[%1d" if (e_2_is_num && // escape = "\x1b[%1d"
((chr == ';') || // escape = "\x1b[%1d;" ((chr == ';') || // escape = "\x1b[%1d;"
@ -861,7 +867,8 @@ const uint8_t lcd_chardata_bedTemp[8] PROGMEM = {
B10101, B10101,
B11111, B11111,
B00000, B00000,
B00000}; //thanks Sonny Mounicou B00000
}; //thanks Sonny Mounicou
const uint8_t lcd_chardata_degree[8] PROGMEM = { const uint8_t lcd_chardata_degree[8] PROGMEM = {
B01100, B01100,
@ -871,7 +878,8 @@ const uint8_t lcd_chardata_degree[8] PROGMEM = {
B00000, B00000,
B00000, B00000,
B00000, B00000,
B00000}; B00000
};
const uint8_t lcd_chardata_thermometer[8] PROGMEM = { const uint8_t lcd_chardata_thermometer[8] PROGMEM = {
B00100, B00100,
@ -881,7 +889,8 @@ const uint8_t lcd_chardata_thermometer[8] PROGMEM = {
B01010, B01010,
B10001, B10001,
B10001, B10001,
B01110}; B01110
};
const uint8_t lcd_chardata_uplevel[8] PROGMEM = { const uint8_t lcd_chardata_uplevel[8] PROGMEM = {
B00100, B00100,
@ -891,7 +900,8 @@ const uint8_t lcd_chardata_uplevel[8] PROGMEM = {
B11100, B11100,
B00000, B00000,
B00000, B00000,
B00000}; //thanks joris B00000
}; //thanks joris
const uint8_t lcd_chardata_refresh[8] PROGMEM = { const uint8_t lcd_chardata_refresh[8] PROGMEM = {
B00000, B00000,
@ -901,7 +911,8 @@ const uint8_t lcd_chardata_refresh[8] PROGMEM = {
B00011, B00011,
B10011, B10011,
B01100, B01100,
B00000}; //thanks joris B00000
}; //thanks joris
const uint8_t lcd_chardata_folder[8] PROGMEM = { const uint8_t lcd_chardata_folder[8] PROGMEM = {
B00000, B00000,
@ -911,7 +922,8 @@ const uint8_t lcd_chardata_folder[8] PROGMEM = {
B10001, B10001,
B11111, B11111,
B00000, B00000,
B00000}; //thanks joris B00000
}; //thanks joris
/*const uint8_t lcd_chardata_feedrate[8] PROGMEM = { /*const uint8_t lcd_chardata_feedrate[8] PROGMEM = {
B11100, B11100,
@ -951,7 +963,8 @@ const uint8_t lcd_chardata_feedrate[8] PROGMEM = {
B10010, B10010,
B00100, B00100,
B00000, B00000,
B00000}; B00000
};
const uint8_t lcd_chardata_clock[8] PROGMEM = { const uint8_t lcd_chardata_clock[8] PROGMEM = {
B00000, B00000,
@ -961,7 +974,8 @@ const uint8_t lcd_chardata_clock[8] PROGMEM = {
B10001, B10001,
B01110, B01110,
B00000, B00000,
B00000}; //thanks Sonny Mounicou B00000
}; //thanks Sonny Mounicou
const uint8_t lcd_chardata_arrup[8] PROGMEM = { const uint8_t lcd_chardata_arrup[8] PROGMEM = {
B00100, B00100,
@ -971,7 +985,8 @@ const uint8_t lcd_chardata_arrup[8] PROGMEM = {
B00000, B00000,
B00000, B00000,
B00000, B00000,
B00000}; B00000
};
const uint8_t lcd_chardata_arrdown[8] PROGMEM = { const uint8_t lcd_chardata_arrdown[8] PROGMEM = {
B00000, B00000,
@ -981,7 +996,8 @@ const uint8_t lcd_chardata_arrdown[8] PROGMEM = {
B00000, B00000,
B10001, B10001,
B01010, B01010,
B00100}; B00100
};
@ -1012,7 +1028,8 @@ const uint8_t lcd_chardata_progress[8] PROGMEM = {
B11111, B11111,
B11111, B11111,
B11111, B11111,
B11111}; B11111
};
void lcd_set_custom_characters_progress(void) void lcd_set_custom_characters_progress(void)
{ {
@ -1027,7 +1044,8 @@ const uint8_t lcd_chardata_arr2down[8] PROGMEM = {
B00100, B00100,
B10001, B10001,
B01010, B01010,
B00100}; B00100
};
const uint8_t lcd_chardata_confirm[8] PROGMEM = { const uint8_t lcd_chardata_confirm[8] PROGMEM = {
B00000, B00000,
@ -1036,7 +1054,8 @@ const uint8_t lcd_chardata_confirm[8] PROGMEM = {
B10110, B10110,
B11100, B11100,
B01000, B01000,
B00000}; B00000
};
void lcd_set_custom_characters_nextpage(void) void lcd_set_custom_characters_nextpage(void)
{ {

View File

@ -129,7 +129,9 @@ const float bed_ref_points[] PROGMEM = {
#endif //not HEATBED_V2 #endif //not HEATBED_V2
static inline float sqr(float x) { return x * x; } static inline float sqr(float x) {
return x * x;
}
#ifdef HEATBED_V2 #ifdef HEATBED_V2
static inline bool point_on_1st_row(const uint8_t /*i*/) static inline bool point_on_1st_row(const uint8_t /*i*/)
@ -1158,7 +1160,8 @@ inline bool find_bed_induction_sensor_point_xy(int
goto endloop; goto endloop;
} }
} }
endloop:; endloop:
;
} }
#ifdef SUPPORT_VERBOSITY #ifdef SUPPORT_VERBOSITY
if (verbosity_level >= 20) { if (verbosity_level >= 20) {
@ -2565,9 +2568,14 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
found = improve_bed_induction_sensor_point3(verbosity_level); found = improve_bed_induction_sensor_point3(verbosity_level);
} else { } else {
switch (method) { switch (method) {
case 0: found = improve_bed_induction_sensor_point(); break; case 0:
case 1: found = improve_bed_induction_sensor_point2(mesh_point < 2, verbosity_level); break; found = improve_bed_induction_sensor_point();
default: break; break;
case 1:
found = improve_bed_induction_sensor_point2(mesh_point < 2, verbosity_level);
break;
default:
break;
} }
} }
if (found) { if (found) {

View File

@ -6,7 +6,9 @@
mesh_bed_leveling mbl; mesh_bed_leveling mbl;
mesh_bed_leveling::mesh_bed_leveling() { reset(); } mesh_bed_leveling::mesh_bed_leveling() {
reset();
}
void mesh_bed_leveling::reset() { void mesh_bed_leveling::reset() {
active = 0; active = 0;

View File

@ -21,15 +21,21 @@ public:
void upsample_3x3(); void upsample_3x3();
#endif #endif
static float get_x(int i) { return float(MESH_MIN_X) + float(MESH_X_DIST) * float(i); } static float get_x(int i) {
static float get_y(int i) { return float(MESH_MIN_Y) + float(MESH_Y_DIST) * float(i); } return float(MESH_MIN_X) + float(MESH_X_DIST) * float(i);
}
static float get_y(int i) {
return float(MESH_MIN_Y) + float(MESH_Y_DIST) * float(i);
}
// Measurement point for the Z probe. // Measurement point for the Z probe.
// If use_default=true, then the default positions for a correctly built printer are used. // If use_default=true, then the default positions for a correctly built printer are used.
// Otherwise a correction matrix is pulled from the EEPROM if available. // Otherwise a correction matrix is pulled from the EEPROM if available.
static void get_meas_xy(int ix, int iy, float &x, float &y, bool use_default); static void get_meas_xy(int ix, int iy, float &x, float &y, bool use_default);
void set_z(int ix, int iy, float z) { z_values[iy][ix] = z; } void set_z(int ix, int iy, float z) {
z_values[iy][ix] = z;
}
int select_x_index(float x) { int select_x_index(float x) {
int i = 1; int i = 1;

View File

@ -1268,7 +1268,8 @@ void lcd_mmu_load_to_nozzle(uint8_t filament_nr)
tmp_extruder = filament_nr; tmp_extruder = filament_nr;
lcd_update_enable(false); lcd_update_enable(false);
lcd_clear(); lcd_clear();
lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT)); lcd_set_cursor(0, 1);
lcd_puts_P(_T(MSG_LOADING_FILAMENT));
lcd_print(" "); lcd_print(" ");
lcd_print(tmp_extruder + 1); lcd_print(tmp_extruder + 1);
mmu_command(MMU_CMD_T0 + tmp_extruder); mmu_command(MMU_CMD_T0 + tmp_extruder);

View File

@ -41,8 +41,12 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
// CCW angle between position and target from circle center. Only one atan2() trig computation required. // CCW angle between position and target from circle center. Only one atan2() trig computation required.
float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1); float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1);
if (angular_travel < 0) { angular_travel += 2*M_PI; } if (angular_travel < 0) {
if (isclockwise) { angular_travel -= 2*M_PI; } angular_travel += 2*M_PI;
}
if (isclockwise) {
angular_travel -= 2*M_PI;
}
//20141002:full circle for G03 did not work, e.g. G03 X80 Y80 I20 J0 F2000 is giving an Angle of zero so head is not moving //20141002:full circle for G03 did not work, e.g. G03 X80 Y80 I20 J0 F2000 is giving an Angle of zero so head is not moving
//to compensate when start pos = target pos && angle is zero -> angle = 2Pi //to compensate when start pos = target pos && angle is zero -> angle = 2Pi
@ -53,7 +57,9 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
//end fix G03 //end fix G03
float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel)); float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel));
if (millimeters_of_travel < 0.001) { return; } if (millimeters_of_travel < 0.001) {
return;
}
uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT); uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT);
if(segments == 0) segments = 1; if(segments == 0) segments = 1;

View File

@ -84,7 +84,8 @@ static void verifySpace() {
} }
static void getNch(uint8_t count) { static void getNch(uint8_t count) {
do getch(); while (--count); do getch();
while (--count);
verifySpace(); verifySpace();
} }

View File

@ -872,22 +872,34 @@ block->steps_y.wide = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-p
enable_e0(); enable_e0();
g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE*2; g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE*2;
if(g_uc_extruder_last_move[1] == 0) {disable_e1();} if(g_uc_extruder_last_move[1] == 0) {
if(g_uc_extruder_last_move[2] == 0) {disable_e2();} disable_e1();
}
if(g_uc_extruder_last_move[2] == 0) {
disable_e2();
}
break; break;
case 1: case 1:
enable_e1(); enable_e1();
g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2; g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2;
if(g_uc_extruder_last_move[0] == 0) {disable_e0();} if(g_uc_extruder_last_move[0] == 0) {
if(g_uc_extruder_last_move[2] == 0) {disable_e2();} disable_e0();
}
if(g_uc_extruder_last_move[2] == 0) {
disable_e2();
}
break; break;
case 2: case 2:
enable_e2(); enable_e2();
g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2; g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2;
if(g_uc_extruder_last_move[0] == 0) {disable_e0();} if(g_uc_extruder_last_move[0] == 0) {
if(g_uc_extruder_last_move[1] == 0) {disable_e1();} disable_e0();
}
if(g_uc_extruder_last_move[1] == 0) {
disable_e1();
}
break; break;
} }
} }
@ -1002,13 +1014,25 @@ Having the real displacement of the head, we can calculate the total movement le
// Limit acceleration per axis // Limit acceleration per axis
//FIXME Vojtech: One shall rather limit a projection of the acceleration vector instead of using the limit. //FIXME Vojtech: One shall rather limit a projection of the acceleration vector instead of using the limit.
if(((float)block->acceleration_st * (float)block->steps_x.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[X_AXIS]) if(((float)block->acceleration_st * (float)block->steps_x.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[X_AXIS])
{ block->acceleration_st = axis_steps_per_sqr_second[X_AXIS]; maxlimit_status |= (X_AXIS_MASK << 4); } {
block->acceleration_st = axis_steps_per_sqr_second[X_AXIS];
maxlimit_status |= (X_AXIS_MASK << 4);
}
if(((float)block->acceleration_st * (float)block->steps_y.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[Y_AXIS]) if(((float)block->acceleration_st * (float)block->steps_y.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[Y_AXIS])
{ block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS]; maxlimit_status |= (Y_AXIS_MASK << 4); } {
block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS];
maxlimit_status |= (Y_AXIS_MASK << 4);
}
if(((float)block->acceleration_st * (float)block->steps_e.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[E_AXIS]) if(((float)block->acceleration_st * (float)block->steps_e.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[E_AXIS])
{ block->acceleration_st = axis_steps_per_sqr_second[E_AXIS]; maxlimit_status |= (Z_AXIS_MASK << 4); } {
block->acceleration_st = axis_steps_per_sqr_second[E_AXIS];
maxlimit_status |= (Z_AXIS_MASK << 4);
}
if(((float)block->acceleration_st * (float)block->steps_z.wide / (float)block->step_event_count.wide ) > axis_steps_per_sqr_second[Z_AXIS]) if(((float)block->acceleration_st * (float)block->steps_z.wide / (float)block->step_event_count.wide ) > axis_steps_per_sqr_second[Z_AXIS])
{ block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS]; maxlimit_status |= (E_AXIS_MASK << 4); } {
block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS];
maxlimit_status |= (E_AXIS_MASK << 4);
}
} }
// Acceleration of the segment, in mm/sec^2 // Acceleration of the segment, in mm/sec^2
block->acceleration = block->acceleration_st / steps_per_mm; block->acceleration = block->acceleration_st / steps_per_mm;

View File

@ -50,15 +50,23 @@ uint8_t sm4_get_dir(uint8_t axis)
switch (axis) switch (axis)
{ {
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3)) #if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
case 0: return (PORTL & 2)?0:1; case 0:
case 1: return (PORTL & 1)?0:1; return (PORTL & 2)?0:1;
case 2: return (PORTL & 4)?0:1; case 1:
case 3: return (PORTL & 64)?1:0; return (PORTL & 1)?0:1;
case 2:
return (PORTL & 4)?0:1;
case 3:
return (PORTL & 64)?1:0;
#elif ((MOTHERBOARD == BOARD_EINSY_1_0a)) #elif ((MOTHERBOARD == BOARD_EINSY_1_0a))
case 0: return (PORTL & 1)?1:0; case 0:
case 1: return (PORTL & 2)?0:1; return (PORTL & 1)?1:0;
case 2: return (PORTL & 4)?1:0; case 1:
case 3: return (PORTL & 64)?0:1; return (PORTL & 2)?0:1;
case 2:
return (PORTL & 4)?1:0;
case 3:
return (PORTL & 64)?0:1;
#endif #endif
} }
return 0; return 0;
@ -69,15 +77,39 @@ void sm4_set_dir(uint8_t axis, uint8_t dir)
switch (axis) switch (axis)
{ {
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3)) #if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
case 0: if (!dir) PORTL |= 2; else PORTL &= ~2; break; case 0:
case 1: if (!dir) PORTL |= 1; else PORTL &= ~1; break; if (!dir) PORTL |= 2;
case 2: if (!dir) PORTL |= 4; else PORTL &= ~4; break; else PORTL &= ~2;
case 3: if (dir) PORTL |= 64; else PORTL &= ~64; break; 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;
#elif ((MOTHERBOARD == BOARD_EINSY_1_0a)) #elif ((MOTHERBOARD == BOARD_EINSY_1_0a))
case 0: if (dir) PORTL |= 1; else PORTL &= ~1; break; case 0:
case 1: if (!dir) PORTL |= 2; else PORTL &= ~2; break; if (dir) PORTL |= 1;
case 2: if (dir) PORTL |= 4; else PORTL &= ~4; break; else PORTL &= ~1;
case 3: if (!dir) PORTL |= 64; else PORTL &= ~64; break; break;
case 1:
if (!dir) PORTL |= 2;
else PORTL &= ~2;
break;
case 2:
if (dir) PORTL |= 4;
else PORTL &= ~4;
break;
case 3:
if (!dir) PORTL |= 64;
else PORTL &= ~64;
break;
#endif #endif
} }
asm("nop"); asm("nop");

View File

@ -343,7 +343,11 @@ FORCE_INLINE unsigned short calc_timer(uint16_t step_rate) {
timer = (unsigned short)pgm_read_word_near(table_address); timer = (unsigned short)pgm_read_word_near(table_address);
timer -= (((unsigned short)pgm_read_word_near(table_address+2) * (unsigned char)(step_rate & 0x0007))>>3); timer -= (((unsigned short)pgm_read_word_near(table_address+2) * (unsigned char)(step_rate & 0x0007))>>3);
} }
if(timer < 100) { timer = 100; MYSERIAL.print(_N("Steprate too high: ")); MYSERIAL.println(step_rate); }//(20kHz this should never happen)////MSG_STEPPER_TOO_HIGH c=0 r=0 if(timer < 100) {
timer = 100; //(20kHz this should never happen)////MSG_STEPPER_TOO_HIGH c=0 r=0
MYSERIAL.print(_N("Steprate too high: "));
MYSERIAL.println(step_rate);
}
return timer; return timer;
} }
@ -1525,7 +1529,8 @@ void babystep(const uint8_t axis,const bool direction)
} }
break; break;
default: break; default:
break;
} }
} }
#endif //BABYSTEPPING #endif //BABYSTEPPING
@ -1623,22 +1628,42 @@ void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2)
{ {
if(ms1 > -1) switch(driver) if(ms1 > -1) switch(driver)
{ {
case 0: digitalWrite( X_MS1_PIN,ms1); break; case 0:
case 1: digitalWrite( Y_MS1_PIN,ms1); break; digitalWrite( X_MS1_PIN,ms1);
case 2: digitalWrite( Z_MS1_PIN,ms1); break; break;
case 3: digitalWrite(E0_MS1_PIN,ms1); break; case 1:
digitalWrite( Y_MS1_PIN,ms1);
break;
case 2:
digitalWrite( Z_MS1_PIN,ms1);
break;
case 3:
digitalWrite(E0_MS1_PIN,ms1);
break;
#if defined(E1_MS1_PIN) && E1_MS1_PIN > -1 #if defined(E1_MS1_PIN) && E1_MS1_PIN > -1
case 4: digitalWrite(E1_MS1_PIN,ms1); break; case 4:
digitalWrite(E1_MS1_PIN,ms1);
break;
#endif #endif
} }
if(ms2 > -1) switch(driver) if(ms2 > -1) switch(driver)
{ {
case 0: digitalWrite( X_MS2_PIN,ms2); break; case 0:
case 1: digitalWrite( Y_MS2_PIN,ms2); break; digitalWrite( X_MS2_PIN,ms2);
case 2: digitalWrite( Z_MS2_PIN,ms2); break; break;
case 3: digitalWrite(E0_MS2_PIN,ms2); break; case 1:
digitalWrite( Y_MS2_PIN,ms2);
break;
case 2:
digitalWrite( Z_MS2_PIN,ms2);
break;
case 3:
digitalWrite(E0_MS2_PIN,ms2);
break;
#if defined(E1_MS2_PIN) && E1_MS2_PIN > -1 #if defined(E1_MS2_PIN) && E1_MS2_PIN > -1
case 4: digitalWrite(E1_MS2_PIN,ms2); break; case 4:
digitalWrite(E1_MS2_PIN,ms2);
break;
#endif #endif
} }
} }
@ -1647,11 +1672,21 @@ void microstep_mode(uint8_t driver, uint8_t stepping_mode)
{ {
switch(stepping_mode) switch(stepping_mode)
{ {
case 1: microstep_ms(driver,MICROSTEP1); break; case 1:
case 2: microstep_ms(driver,MICROSTEP2); break; microstep_ms(driver,MICROSTEP1);
case 4: microstep_ms(driver,MICROSTEP4); break; break;
case 8: microstep_ms(driver,MICROSTEP8); break; case 2:
case 16: microstep_ms(driver,MICROSTEP16); break; microstep_ms(driver,MICROSTEP2);
break;
case 4:
microstep_ms(driver,MICROSTEP4);
break;
case 8:
microstep_ms(driver,MICROSTEP8);
break;
case 16:
microstep_ms(driver,MICROSTEP16);
break;
} }
} }

View File

@ -25,7 +25,8 @@ void swi2c_init(void)
PIN_OUT(SWI2C_SCL); PIN_OUT(SWI2C_SCL);
PIN_SET(SWI2C_SDA); PIN_SET(SWI2C_SDA);
PIN_SET(SWI2C_SCL); PIN_SET(SWI2C_SCL);
uint8_t i; for (i = 0; i < 100; i++) uint8_t i;
for (i = 0; i < 100; i++)
__delay(); __delay();
} }
@ -81,7 +82,8 @@ uint8_t swi2c_read(void)
__delay(); __delay();
PIN_INP(SWI2C_SDA); PIN_INP(SWI2C_SDA);
uint8_t data = 0; uint8_t data = 0;
int8_t bit; for (bit = 7; bit >= 0; bit--) int8_t bit;
for (bit = 7; bit >= 0; bit--)
{ {
PIN_SET(SWI2C_SCL); PIN_SET(SWI2C_SCL);
__delay(); __delay();
@ -95,7 +97,8 @@ uint8_t swi2c_read(void)
void swi2c_write(uint8_t data) void swi2c_write(uint8_t data)
{ {
int8_t bit; for (bit = 7; bit >= 0; bit--) int8_t bit;
for (bit = 7; bit >= 0; bit--)
{ {
if (data & (1 << bit)) PIN_SET(SWI2C_SDA); if (data & (1 << bit)) PIN_SET(SWI2C_SDA);
else PIN_CLR(SWI2C_SDA); else PIN_CLR(SWI2C_SDA);
@ -111,7 +114,10 @@ uint8_t swi2c_check(uint8_t dev_addr)
{ {
swi2c_start(); swi2c_start();
swi2c_write((dev_addr & SWI2C_DMSK) << SWI2C_ASHF); swi2c_write((dev_addr & SWI2C_DMSK) << SWI2C_ASHF);
if (!swi2c_wait_ack()) { swi2c_stop(); return 0; } if (!swi2c_wait_ack()) {
swi2c_stop();
return 0;
}
swi2c_stop(); swi2c_stop();
return 1; return 1;
} }
@ -122,7 +128,10 @@ uint8_t swi2c_readByte_A8(uint8_t dev_addr, uint8_t addr, uint8_t* pbyte)
{ {
swi2c_start(); swi2c_start();
swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF)); swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
if (!swi2c_wait_ack()) { swi2c_stop(); return 0; } if (!swi2c_wait_ack()) {
swi2c_stop();
return 0;
}
swi2c_write(addr & 0xff); swi2c_write(addr & 0xff);
if (!swi2c_wait_ack()) return 0; if (!swi2c_wait_ack()) return 0;
swi2c_stop(); swi2c_stop();
@ -139,7 +148,10 @@ uint8_t swi2c_writeByte_A8(uint8_t dev_addr, uint8_t addr, uint8_t* pbyte)
{ {
swi2c_start(); swi2c_start();
swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF)); swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
if (!swi2c_wait_ack()) { swi2c_stop(); return 0; } if (!swi2c_wait_ack()) {
swi2c_stop();
return 0;
}
swi2c_write(addr & 0xff); swi2c_write(addr & 0xff);
if (!swi2c_wait_ack()) return 0; if (!swi2c_wait_ack()) return 0;
swi2c_write(*pbyte); swi2c_write(*pbyte);
@ -156,7 +168,10 @@ uint8_t swi2c_readByte_A16(uint8_t dev_addr, unsigned short addr, uint8_t* pbyte
{ {
swi2c_start(); swi2c_start();
swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF)); swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
if (!swi2c_wait_ack()) { swi2c_stop(); return 0; } if (!swi2c_wait_ack()) {
swi2c_stop();
return 0;
}
swi2c_write(addr >> 8); swi2c_write(addr >> 8);
if (!swi2c_wait_ack()) return 0; if (!swi2c_wait_ack()) return 0;
swi2c_write(addr & 0xff); swi2c_write(addr & 0xff);
@ -175,7 +190,10 @@ uint8_t swi2c_writeByte_A16(uint8_t dev_addr, unsigned short addr, uint8_t* pbyt
{ {
swi2c_start(); swi2c_start();
swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF)); swi2c_write(SWI2C_WMSK | ((dev_addr & SWI2C_DMSK) << SWI2C_ASHF));
if (!swi2c_wait_ack()) { swi2c_stop(); return 0; } if (!swi2c_wait_ack()) {
swi2c_stop();
return 0;
}
swi2c_write(addr >> 8); swi2c_write(addr >> 8);
if (!swi2c_wait_ack()) return 0; if (!swi2c_wait_ack()) return 0;
swi2c_write(addr & 0xff); swi2c_write(addr & 0xff);

View File

@ -42,7 +42,8 @@ void swspi_tx(unsigned char tx)
{ {
int delay = 1 << (swspi_cfg & SWSPI_DEL)); int delay = 1 << (swspi_cfg & SWSPI_DEL));
if (swspi_miso == swspi_mosi) GPIO_OUT(swspi_mosi); if (swspi_miso == swspi_mosi) GPIO_OUT(swspi_mosi);
unsigned char i = 0; for (; i < 8; i++) unsigned char i = 0;
for (; i < 8; i++)
{ {
if (tx & 0x80) GPIO_SET(swspi_mosi); if (tx & 0x80) GPIO_SET(swspi_mosi);
else GPIO_CLR(swspi_mosi); else GPIO_CLR(swspi_mosi);
@ -59,7 +60,8 @@ unsigned char swspi_rx()
int delay = 1 << (swspi_cfg & SWSPI_DEL)); int delay = 1 << (swspi_cfg & SWSPI_DEL));
if (swspi_miso == swspi_mosi) GPIO_OUT(swspi_mosi); if (swspi_miso == swspi_mosi) GPIO_OUT(swspi_mosi);
unsigned char rx = 0; unsigned char rx = 0;
unsigned char i = 0; for (; i < 8; i++) unsigned char i = 0;
for (; i < 8; i++)
{ {
rx <<= 1; rx <<= 1;
DELAY(delay); DELAY(delay);
@ -75,7 +77,8 @@ unsigned char swspi_txrx(unsigned char tx)
{ {
int delay = 1 << (swspi_cfg & SWSPI_DEL)); int delay = 1 << (swspi_cfg & SWSPI_DEL));
unsigned char rx = 0; unsigned char rx = 0;
unsigned char i = 0; for (; i < 8; i++) unsigned char i = 0;
for (; i < 8; i++)
{ {
rx <<= 1; rx <<= 1;
if (tx & 0x80) GPIO_SET(swspi_mosi); if (tx & 0x80) GPIO_SET(swspi_mosi);

View File

@ -307,22 +307,31 @@ static void temp_runaway_stop(bool isPreheat, bool isBed);
if(bias > (extruder<0?(MAX_BED_POWER):(PID_MAX))/2) d = (extruder<0?(MAX_BED_POWER):(PID_MAX)) - 1 - bias; if(bias > (extruder<0?(MAX_BED_POWER):(PID_MAX))/2) d = (extruder<0?(MAX_BED_POWER):(PID_MAX)) - 1 - bias;
else d = bias; else d = bias;
SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias); SERIAL_PROTOCOLPGM(" bias: ");
SERIAL_PROTOCOLPGM(" d: "); SERIAL_PROTOCOL(d); SERIAL_PROTOCOL(bias);
SERIAL_PROTOCOLPGM(" min: "); SERIAL_PROTOCOL(min); SERIAL_PROTOCOLPGM(" d: ");
SERIAL_PROTOCOLPGM(" max: "); SERIAL_PROTOCOLLN(max); SERIAL_PROTOCOL(d);
SERIAL_PROTOCOLPGM(" min: ");
SERIAL_PROTOCOL(min);
SERIAL_PROTOCOLPGM(" max: ");
SERIAL_PROTOCOLLN(max);
if(pid_cycle > 2) { if(pid_cycle > 2) {
Ku = (4.0*d)/(3.14159*(max-min)/2.0); Ku = (4.0*d)/(3.14159*(max-min)/2.0);
Tu = ((float)(t_low + t_high)/1000.0); Tu = ((float)(t_low + t_high)/1000.0);
SERIAL_PROTOCOLPGM(" Ku: "); SERIAL_PROTOCOL(Ku); SERIAL_PROTOCOLPGM(" Ku: ");
SERIAL_PROTOCOLPGM(" Tu: "); SERIAL_PROTOCOLLN(Tu); SERIAL_PROTOCOL(Ku);
SERIAL_PROTOCOLPGM(" Tu: ");
SERIAL_PROTOCOLLN(Tu);
_Kp = 0.6*Ku; _Kp = 0.6*Ku;
_Ki = 2*_Kp/Tu; _Ki = 2*_Kp/Tu;
_Kd = _Kp*Tu/8; _Kd = _Kp*Tu/8;
SERIAL_PROTOCOLLNPGM(" Classic PID "); SERIAL_PROTOCOLLNPGM(" Classic PID ");
SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(_Kp); SERIAL_PROTOCOLPGM(" Kp: ");
SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(_Ki); SERIAL_PROTOCOLLN(_Kp);
SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(_Kd); SERIAL_PROTOCOLPGM(" Ki: ");
SERIAL_PROTOCOLLN(_Ki);
SERIAL_PROTOCOLPGM(" Kd: ");
SERIAL_PROTOCOLLN(_Kd);
/* /*
_Kp = 0.33*Ku; _Kp = 0.33*Ku;
_Ki = _Kp/Tu; _Ki = _Kp/Tu;
@ -1233,9 +1242,13 @@ void temp_runaway_check(int _heater_id, float _target_temperature, float _curren
if (__preheat_errors[_heater_id] > ((_isbed) ? 2 : 5)) if (__preheat_errors[_heater_id] > ((_isbed) ? 2 : 5))
{ {
if (farm_mode) { prusa_statistics(0); } if (farm_mode) {
prusa_statistics(0);
}
temp_runaway_stop(true, _isbed); temp_runaway_stop(true, _isbed);
if (farm_mode) { prusa_statistics(91); } if (farm_mode) {
prusa_statistics(91);
}
} }
__preheat_start[_heater_id] = _current_temperature; __preheat_start[_heater_id] = _current_temperature;
__preheat_counter[_heater_id] = 0; __preheat_counter[_heater_id] = 0;
@ -1269,9 +1282,13 @@ void temp_runaway_check(int _heater_id, float _target_temperature, float _curren
temp_runaway_error_counter[_heater_id]++; temp_runaway_error_counter[_heater_id]++;
if (temp_runaway_error_counter[_heater_id] * 2 > __timeout) if (temp_runaway_error_counter[_heater_id] * 2 > __timeout)
{ {
if (farm_mode) { prusa_statistics(0); } if (farm_mode) {
prusa_statistics(0);
}
temp_runaway_stop(false, _isbed); temp_runaway_stop(false, _isbed);
if (farm_mode) { prusa_statistics(90); } if (farm_mode) {
prusa_statistics(90);
}
} }
} }
} }
@ -1390,7 +1407,9 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode
WRITE(BEEPER, 1); WRITE(BEEPER, 1);
// fanSpeed will consumed by the check_axes_activity() routine. // fanSpeed will consumed by the check_axes_activity() routine.
fanSpeed=255; fanSpeed=255;
if (farm_mode) { prusa_statistics(93); } if (farm_mode) {
prusa_statistics(93);
}
} }
void min_temp_error(uint8_t e) { void min_temp_error(uint8_t e) {
@ -1408,7 +1427,9 @@ void min_temp_error(uint8_t e) {
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
Stop(); Stop();
#endif #endif
if (farm_mode) { prusa_statistics(92); } if (farm_mode) {
prusa_statistics(92);
}
} }
@ -1590,19 +1611,23 @@ ISR(TIMER0_COMPB_vect)
} else WRITE(HEATER_0_PIN,0); } else WRITE(HEATER_0_PIN,0);
#if EXTRUDERS > 1 #if EXTRUDERS > 1
soft_pwm_1 = soft_pwm[1]; soft_pwm_1 = soft_pwm[1];
if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1); else WRITE(HEATER_1_PIN,0); if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1);
else WRITE(HEATER_1_PIN,0);
#endif #endif
#if EXTRUDERS > 2 #if EXTRUDERS > 2
soft_pwm_2 = soft_pwm[2]; soft_pwm_2 = soft_pwm[2];
if(soft_pwm_2 > 0) WRITE(HEATER_2_PIN,1); else WRITE(HEATER_2_PIN,0); if(soft_pwm_2 > 0) WRITE(HEATER_2_PIN,1);
else WRITE(HEATER_2_PIN,0);
#endif #endif
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
soft_pwm_b = soft_pwm_bed; soft_pwm_b = soft_pwm_bed;
if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0); if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1);
else WRITE(HEATER_BED_PIN,0);
#endif #endif
#ifdef FAN_SOFT_PWM #ifdef FAN_SOFT_PWM
soft_pwm_fan = fanSpeedSoftPwm / 2; soft_pwm_fan = fanSpeedSoftPwm / 2;
if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0); if(soft_pwm_fan > 0) WRITE(FAN_PIN,1);
else WRITE(FAN_PIN,0);
#endif #endif
} }
if(soft_pwm_0 < pwm_count) if(soft_pwm_0 < pwm_count)
@ -1812,7 +1837,8 @@ ISR(TIMER0_COMPB_vect)
#ifdef FAN_SOFT_PWM #ifdef FAN_SOFT_PWM
if (pwm_count == 0) { if (pwm_count == 0) {
soft_pwm_fan = fanSpeedSoftPwm / 2; soft_pwm_fan = fanSpeedSoftPwm / 2;
if (soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0); if (soft_pwm_fan > 0) WRITE(FAN_PIN,1);
else WRITE(FAN_PIN,0);
} }
if (soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); if (soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0);
#endif #endif
@ -1864,8 +1890,7 @@ ISR(TIMER0_COMPB_vect)
babystepsTodo[axis]--; //less to do next time babystepsTodo[axis]--; //less to do next time
asm("sei"); asm("sei");
} }
else else if(curTodo<0)
if(curTodo<0)
{ {
asm("cli"); asm("cli");
babystep(axis,/*fwd*/false); babystep(axis,/*fwd*/false);

View File

@ -136,9 +136,12 @@ uint16_t __tcoolthrs(uint8_t axis)
{ {
switch (axis) switch (axis)
{ {
case X_AXIS: return TMC2130_TCOOLTHRS_X; case X_AXIS:
case Y_AXIS: return TMC2130_TCOOLTHRS_Y; return TMC2130_TCOOLTHRS_X;
case Z_AXIS: return TMC2130_TCOOLTHRS_Z; case Y_AXIS:
return TMC2130_TCOOLTHRS_Y;
case Z_AXIS:
return TMC2130_TCOOLTHRS_Z;
} }
return 0; return 0;
} }
@ -240,8 +243,7 @@ void tmc2130_st_isr()
{ {
uint8_t mask = (X_AXIS_MASK << axis); uint8_t mask = (X_AXIS_MASK << axis);
if (diag_mask & mask) tmc2130_sg_err[axis]++; if (diag_mask & mask) tmc2130_sg_err[axis]++;
else else if (tmc2130_sg_err[axis] > 0) tmc2130_sg_err[axis]--;
if (tmc2130_sg_err[axis] > 0) tmc2130_sg_err[axis]--;
if (tmc2130_sg_cnt[axis] < tmc2130_sg_err[axis]) if (tmc2130_sg_cnt[axis] < tmc2130_sg_err[axis])
{ {
tmc2130_sg_cnt[axis] = tmc2130_sg_err[axis]; tmc2130_sg_cnt[axis] = tmc2130_sg_err[axis];
@ -590,7 +592,8 @@ void tmc2130_wr_THIGH(uint8_t axis, uint32_t val32)
uint8_t tmc2130_usteps2mres(uint16_t usteps) uint8_t tmc2130_usteps2mres(uint16_t usteps)
{ {
uint8_t mres = 8; while (mres && (usteps >>= 1)) mres--; uint8_t mres = 8;
while (mres && (usteps >>= 1)) mres--;
return mres; return mres;
} }
@ -599,10 +602,18 @@ inline void tmc2130_cs_low(uint8_t axis)
{ {
switch (axis) switch (axis)
{ {
case X_AXIS: WRITE(X_TMC2130_CS, LOW); break; case X_AXIS:
case Y_AXIS: WRITE(Y_TMC2130_CS, LOW); break; WRITE(X_TMC2130_CS, LOW);
case Z_AXIS: WRITE(Z_TMC2130_CS, LOW); break; break;
case E_AXIS: WRITE(E0_TMC2130_CS, LOW); break; case Y_AXIS:
WRITE(Y_TMC2130_CS, LOW);
break;
case Z_AXIS:
WRITE(Z_TMC2130_CS, LOW);
break;
case E_AXIS:
WRITE(E0_TMC2130_CS, LOW);
break;
} }
} }
@ -610,10 +621,18 @@ inline void tmc2130_cs_high(uint8_t axis)
{ {
switch (axis) switch (axis)
{ {
case X_AXIS: WRITE(X_TMC2130_CS, HIGH); break; case X_AXIS:
case Y_AXIS: WRITE(Y_TMC2130_CS, HIGH); break; WRITE(X_TMC2130_CS, HIGH);
case Z_AXIS: WRITE(Z_TMC2130_CS, HIGH); break; break;
case E_AXIS: WRITE(E0_TMC2130_CS, HIGH); break; case Y_AXIS:
WRITE(Y_TMC2130_CS, HIGH);
break;
case Z_AXIS:
WRITE(Z_TMC2130_CS, HIGH);
break;
case E_AXIS:
WRITE(E0_TMC2130_CS, HIGH);
break;
} }
} }
@ -707,10 +726,14 @@ uint8_t tmc2130_get_pwr(uint8_t axis)
{ {
switch (axis) switch (axis)
{ {
case X_AXIS: return _GET_PWR_X; case X_AXIS:
case Y_AXIS: return _GET_PWR_Y; return _GET_PWR_X;
case Z_AXIS: return _GET_PWR_Z; case Y_AXIS:
case E_AXIS: return _GET_PWR_E; return _GET_PWR_Y;
case Z_AXIS:
return _GET_PWR_Z;
case E_AXIS:
return _GET_PWR_E;
} }
return 0; return 0;
} }
@ -719,10 +742,18 @@ void tmc2130_set_pwr(uint8_t axis, uint8_t pwr)
{ {
switch (axis) switch (axis)
{ {
case X_AXIS: _SET_PWR_X(pwr); break; case X_AXIS:
case Y_AXIS: _SET_PWR_Y(pwr); break; _SET_PWR_X(pwr);
case Z_AXIS: _SET_PWR_Z(pwr); break; break;
case E_AXIS: _SET_PWR_E(pwr); break; case Y_AXIS:
_SET_PWR_Y(pwr);
break;
case Z_AXIS:
_SET_PWR_Z(pwr);
break;
case E_AXIS:
_SET_PWR_E(pwr);
break;
} }
} }
@ -730,10 +761,14 @@ uint8_t tmc2130_get_inv(uint8_t axis)
{ {
switch (axis) switch (axis)
{ {
case X_AXIS: return INVERT_X_DIR; case X_AXIS:
case Y_AXIS: return INVERT_Y_DIR; return INVERT_X_DIR;
case Z_AXIS: return INVERT_Z_DIR; case Y_AXIS:
case E_AXIS: return INVERT_E0_DIR; return INVERT_Y_DIR;
case Z_AXIS:
return INVERT_Z_DIR;
case E_AXIS:
return INVERT_E0_DIR;
} }
return 0; return 0;
} }
@ -742,10 +777,14 @@ uint8_t tmc2130_get_dir(uint8_t axis)
{ {
switch (axis) switch (axis)
{ {
case X_AXIS: return _GET_DIR_X; case X_AXIS:
case Y_AXIS: return _GET_DIR_Y; return _GET_DIR_X;
case Z_AXIS: return _GET_DIR_Z; case Y_AXIS:
case E_AXIS: return _GET_DIR_E; return _GET_DIR_Y;
case Z_AXIS:
return _GET_DIR_Z;
case E_AXIS:
return _GET_DIR_E;
} }
return 0; return 0;
} }
@ -755,10 +794,18 @@ void tmc2130_set_dir(uint8_t axis, uint8_t dir)
{ {
switch (axis) switch (axis)
{ {
case X_AXIS: _SET_DIR_X(dir); break; case X_AXIS:
case Y_AXIS: _SET_DIR_Y(dir); break; _SET_DIR_X(dir);
case Z_AXIS: _SET_DIR_Z(dir); break; break;
case E_AXIS: _SET_DIR_E(dir); break; case Y_AXIS:
_SET_DIR_Y(dir);
break;
case Z_AXIS:
_SET_DIR_Z(dir);
break;
case E_AXIS:
_SET_DIR_E(dir);
break;
} }
} }
@ -766,10 +813,18 @@ void tmc2130_do_step(uint8_t axis)
{ {
switch (axis) switch (axis)
{ {
case X_AXIS: _DO_STEP_X; break; case X_AXIS:
case Y_AXIS: _DO_STEP_Y; break; _DO_STEP_X;
case Z_AXIS: _DO_STEP_Z; break; break;
case E_AXIS: _DO_STEP_E; break; case Y_AXIS:
_DO_STEP_Y;
break;
case Z_AXIS:
_DO_STEP_Z;
break;
case E_AXIS:
_DO_STEP_E;
break;
} }
} }
@ -787,7 +842,8 @@ void tmc2130_do_steps(uint8_t axis, uint16_t steps, uint8_t dir, uint16_t delay_
void tmc2130_goto_step(uint8_t axis, uint8_t step, uint8_t dir, uint16_t delay_us, uint16_t microstep_resolution) void tmc2130_goto_step(uint8_t axis, uint8_t step, uint8_t dir, uint16_t delay_us, uint16_t microstep_resolution)
{ {
printf_P(PSTR("tmc2130_goto_step %d %d %d %d \n"), axis, step, dir, delay_us, microstep_resolution); printf_P(PSTR("tmc2130_goto_step %d %d %d %d \n"), axis, step, dir, delay_us, microstep_resolution);
uint8_t shift; for (shift = 0; shift < 8; shift++) if (microstep_resolution == (256u >> shift)) break; uint8_t shift;
for (shift = 0; shift < 8; shift++) if (microstep_resolution == (256u >> shift)) break;
uint16_t cnt = 4 * (1 << (8 - shift)); uint16_t cnt = 4 * (1 << (8 - shift));
uint16_t mscnt = tmc2130_rd_MSCNT(axis); uint16_t mscnt = tmc2130_rd_MSCNT(axis);
if (dir == 2) if (dir == 2)
@ -888,12 +944,29 @@ void tmc2130_set_wave(uint8_t axis, uint8_t amp, uint8_t fac1000)
b = 0; b = 0;
switch (dA) switch (dA)
{ {
case -1: d0 = -1; d1 = 0; w[s+1] = 0; break; case -1:
case 0: d0 = 0; d1 = 1; w[s+1] = 1; break; d0 = -1;
case 1: d0 = 1; d1 = 2; w[s+1] = 2; break; d1 = 0;
default: b = -1; break; w[s+1] = 0;
break;
case 0:
d0 = 0;
d1 = 1;
w[s+1] = 1;
break;
case 1:
d0 = 1;
d1 = 2;
w[s+1] = 2;
break;
default:
b = -1;
break;
}
if (b >= 0) {
x[s] = i;
s++;
} }
if (b >= 0) { x[s] = i; s++; }
} }
else if (dA > d1) // delta > delta0 => switch wbit up else if (dA > d1) // delta > delta0 => switch wbit up
{ {
@ -901,12 +974,29 @@ void tmc2130_set_wave(uint8_t axis, uint8_t amp, uint8_t fac1000)
b = 1; b = 1;
switch (dA) switch (dA)
{ {
case 1: d0 = 0; d1 = 1; w[s+1] = 1; break; case 1:
case 2: d0 = 1; d1 = 2; w[s+1] = 2; break; d0 = 0;
case 3: d0 = 2; d1 = 3; w[s+1] = 3; break; d1 = 1;
default: b = -1; break; w[s+1] = 1;
break;
case 2:
d0 = 1;
d1 = 2;
w[s+1] = 2;
break;
case 3:
d0 = 2;
d1 = 3;
w[s+1] = 3;
break;
default:
b = -1;
break;
}
if (b >= 0) {
x[s] = i;
s++;
} }
if (b >= 0) { x[s] = i; s++; }
} }
} }
if (b < 0) break; // delta out of range (<-1 or >3) if (b < 0) break; // delta out of range (<-1 or >3)

View File

@ -1628,10 +1628,18 @@ void lcd_commands()
else else
switch(snmm_stop_print_menu()) switch(snmm_stop_print_menu())
{ {
case 0: enquecommand_P(PSTR("M702")); break;//all case 0:
case 1: enquecommand_P(PSTR("M702 U")); break; //used enquecommand_P(PSTR("M702"));
case 2: enquecommand_P(PSTR("M702 C")); break; //current break;//all
default: enquecommand_P(PSTR("M702")); break; case 1:
enquecommand_P(PSTR("M702 U"));
break; //used
case 2:
enquecommand_P(PSTR("M702 C"));
break; //current
default:
enquecommand_P(PSTR("M702"));
break;
} }
lcd_commands_step = 3; lcd_commands_step = 3;
} }
@ -1648,7 +1656,9 @@ void lcd_commands()
if (lcd_commands_type == LCD_COMMAND_FARM_MODE_CONFIRM) /// farm mode confirm if (lcd_commands_type == LCD_COMMAND_FARM_MODE_CONFIRM) /// farm mode confirm
{ {
if (lcd_commands_step == 0) { lcd_commands_step = 6; } if (lcd_commands_step == 0) {
lcd_commands_step = 6;
}
if (lcd_commands_step == 1 && !blocks_queued()) if (lcd_commands_step == 1 && !blocks_queued())
{ {
@ -3945,9 +3955,14 @@ static void lcd_sort_type_set() {
uint8_t sdSort; uint8_t sdSort;
EEPROM_read(EEPROM_SD_SORT, (uint8_t*)&sdSort, sizeof(sdSort)); EEPROM_read(EEPROM_SD_SORT, (uint8_t*)&sdSort, sizeof(sdSort));
switch (sdSort) { switch (sdSort) {
case SD_SORT_TIME: sdSort = SD_SORT_ALPHA; break; case SD_SORT_TIME:
case SD_SORT_ALPHA: sdSort = SD_SORT_NONE; break; sdSort = SD_SORT_ALPHA;
default: sdSort = SD_SORT_TIME; break;
case SD_SORT_ALPHA:
sdSort = SD_SORT_NONE;
break;
default:
sdSort = SD_SORT_TIME;
} }
eeprom_update_byte((unsigned char *)EEPROM_SD_SORT, sdSort); eeprom_update_byte((unsigned char *)EEPROM_SD_SORT, sdSort);
presort_flag = true; presort_flag = true;
@ -4017,14 +4032,28 @@ Sound_CycleState();
static void lcd_silent_mode_set() { static void lcd_silent_mode_set() {
switch (SilentModeMenu) { switch (SilentModeMenu) {
#ifdef TMC2130 #ifdef TMC2130
case SILENT_MODE_NORMAL: SilentModeMenu = SILENT_MODE_STEALTH; break; case SILENT_MODE_NORMAL:
case SILENT_MODE_STEALTH: SilentModeMenu = SILENT_MODE_NORMAL; break; SilentModeMenu = SILENT_MODE_STEALTH;
default: SilentModeMenu = SILENT_MODE_NORMAL; break; // (probably) not needed break;
case SILENT_MODE_STEALTH:
SilentModeMenu = SILENT_MODE_NORMAL;
break;
default:
SilentModeMenu = SILENT_MODE_NORMAL;
break; // (probably) not needed
#else #else
case SILENT_MODE_POWER: SilentModeMenu = SILENT_MODE_SILENT; break; case SILENT_MODE_POWER:
case SILENT_MODE_SILENT: SilentModeMenu = SILENT_MODE_AUTO; break; SilentModeMenu = SILENT_MODE_SILENT;
case SILENT_MODE_AUTO: SilentModeMenu = SILENT_MODE_POWER; break; break;
default: SilentModeMenu = SILENT_MODE_POWER; break; // (probably) not needed 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 #endif //TMC2130
} }
eeprom_update_byte((unsigned char *)EEPROM_SILENT, SilentModeMenu); eeprom_update_byte((unsigned char *)EEPROM_SILENT, SilentModeMenu);
@ -4472,12 +4501,25 @@ void lcd_wizard(WizState state)
break; break;
case S::Restore: // restore calibration status case S::Restore: // restore calibration status
switch (calibration_status()) { switch (calibration_status()) {
case CALIBRATION_STATUS_ASSEMBLED: state = S::Selftest; break; //run selftest case CALIBRATION_STATUS_ASSEMBLED:
case CALIBRATION_STATUS_XYZ_CALIBRATION: state = S::Xyz; break; //run xyz cal. state = S::Selftest;
case CALIBRATION_STATUS_Z_CALIBRATION: state = S::Z; break; //run z cal. break; //run selftest
case CALIBRATION_STATUS_LIVE_ADJUST: state = S::IsFil; break; //run live adjust case CALIBRATION_STATUS_XYZ_CALIBRATION:
case CALIBRATION_STATUS_CALIBRATED: end = true; eeprom_write_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 0); break; state = S::Xyz;
default: state = S::Selftest; break; //if calibration status is unknown, run wizard from the beginning break; //run xyz cal.
case CALIBRATION_STATUS_Z_CALIBRATION:
state = S::Z;
break; //run z cal.
case CALIBRATION_STATUS_LIVE_ADJUST:
state = S::IsFil;
break; //run live adjust
case CALIBRATION_STATUS_CALIBRATED:
end = true;
eeprom_write_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 0);
break;
default:
state = S::Selftest;
break; //if calibration status is unknown, run wizard from the beginning
} }
break; break;
case S::Selftest: case S::Selftest:
@ -4583,7 +4625,8 @@ void lcd_wizard(WizState state)
end = true; end = true;
break; break;
default: break; default:
break;
} }
} }
@ -5075,8 +5118,10 @@ void bowden_menu() {
static char snmm_stop_print_menu() { //menu for choosing which filaments will be unloaded in stop print static char snmm_stop_print_menu() { //menu for choosing which filaments will be unloaded in stop print
lcd_clear(); lcd_clear();
lcd_puts_at_P(0,0,_T(MSG_UNLOAD_FILAMENT)); lcd_print(":"); lcd_puts_at_P(0,0,_T(MSG_UNLOAD_FILAMENT));
lcd_set_cursor(0, 1); lcd_print(">"); lcd_print(":");
lcd_set_cursor(0, 1);
lcd_print(">");
lcd_puts_at_P(1,2,_i("Used during print"));////MSG_USED c=19 r=1 lcd_puts_at_P(1,2,_i("Used during print"));////MSG_USED c=19 r=1
lcd_puts_at_P(1,3,_i("Current"));////MSG_CURRENT c=19 r=1 lcd_puts_at_P(1,3,_i("Current"));////MSG_CURRENT c=19 r=1
char cursor_pos = 1; char cursor_pos = 1;
@ -5443,19 +5488,33 @@ static void lcd_farm_no()
if (abs((enc_dif - lcd_encoder_diff)) > 2) { if (abs((enc_dif - lcd_encoder_diff)) > 2) {
if (enc_dif > lcd_encoder_diff) { if (enc_dif > lcd_encoder_diff) {
switch (step) { switch (step) {
case(0): if (_farmno >= 100) _farmno -= 100; break; case(0):
case(1): if (_farmno % 100 >= 10) _farmno -= 10; break; if (_farmno >= 100) _farmno -= 100;
case(2): if (_farmno % 10 >= 1) _farmno--; break; break;
default: break; case(1):
if (_farmno % 100 >= 10) _farmno -= 10;
break;
case(2):
if (_farmno % 10 >= 1) _farmno--;
break;
default:
break;
} }
} }
if (enc_dif < lcd_encoder_diff) { if (enc_dif < lcd_encoder_diff) {
switch (step) { switch (step) {
case(0): if (_farmno < 900) _farmno += 100; break; case(0):
case(1): if (_farmno % 100 < 90) _farmno += 10; break; if (_farmno < 900) _farmno += 100;
case(2): if (_farmno % 10 <= 8)_farmno++; break; break;
default: break; case(1):
if (_farmno % 100 < 90) _farmno += 10;
break;
case(2):
if (_farmno % 10 <= 8)_farmno++;
break;
default:
break;
} }
} }
enc_dif = 0; enc_dif = 0;
@ -5564,9 +5623,15 @@ unsigned char lcd_choose_color() {
if (lcd_clicked()) { if (lcd_clicked()) {
switch(cursor_pos + first - 1) { switch(cursor_pos + first - 1) {
case 0: return 1; break; case 0:
case 1: return 0; break; return 1;
default: return 99; break; break;
case 1:
return 0;
break;
default:
return 99;
break;
} }
} }
@ -5601,11 +5666,17 @@ void lcd_confirm_print()
enc_dif = lcd_encoder_diff; enc_dif = lcd_encoder_diff;
} }
if (cursor_pos > 2) { cursor_pos = 2; } if (cursor_pos > 2) {
if (cursor_pos < 1) { cursor_pos = 1; } cursor_pos = 2;
}
if (cursor_pos < 1) {
cursor_pos = 1;
}
lcd_set_cursor(0, 2); lcd_print(" "); lcd_set_cursor(0, 2);
lcd_set_cursor(0, 3); lcd_print(" "); lcd_print(" ");
lcd_set_cursor(0, 3);
lcd_print(" ");
lcd_set_cursor(2, 2); lcd_set_cursor(2, 2);
lcd_puts_P(_T(MSG_YES)); lcd_puts_P(_T(MSG_YES));
lcd_set_cursor(2, 3); lcd_set_cursor(2, 3);
@ -5969,10 +6040,18 @@ static void lcd_tune_menu()
#else //TMC2130 #else //TMC2130
if (!farm_mode) { //dont show in menu if we are in farm mode if (!farm_mode) { //dont show in menu if we are in farm mode
switch (SilentModeMenu) { switch (SilentModeMenu) {
case SILENT_MODE_POWER: MENU_ITEM_FUNCTION_P(_T(MSG_SILENT_MODE_OFF), lcd_silent_mode_set); break; case SILENT_MODE_POWER:
case SILENT_MODE_SILENT: MENU_ITEM_FUNCTION_P(_T(MSG_SILENT_MODE_ON), lcd_silent_mode_set); break; MENU_ITEM_FUNCTION_P(_T(MSG_SILENT_MODE_OFF), lcd_silent_mode_set);
case SILENT_MODE_AUTO: MENU_ITEM_FUNCTION_P(_T(MSG_AUTO_MODE_ON), lcd_silent_mode_set); break; break;
default: MENU_ITEM_FUNCTION_P(_T(MSG_SILENT_MODE_OFF), lcd_silent_mode_set); break; // (probably) not needed case SILENT_MODE_SILENT:
MENU_ITEM_FUNCTION_P(_T(MSG_SILENT_MODE_ON), lcd_silent_mode_set);
break;
case SILENT_MODE_AUTO:
MENU_ITEM_FUNCTION_P(_T(MSG_AUTO_MODE_ON), lcd_silent_mode_set);
break;
default:
MENU_ITEM_FUNCTION_P(_T(MSG_SILENT_MODE_OFF), lcd_silent_mode_set);
break; // (probably) not needed
} }
} }
#endif //TMC2130 #endif //TMC2130
@ -6088,11 +6167,17 @@ void lcd_sdcard_stop()
lcd_puts_P(_T(MSG_NO)); lcd_puts_P(_T(MSG_NO));
lcd_set_cursor(2, 3); lcd_set_cursor(2, 3);
lcd_puts_P(_T(MSG_YES)); lcd_puts_P(_T(MSG_YES));
lcd_set_cursor(0, 2); lcd_print(" "); lcd_set_cursor(0, 2);
lcd_set_cursor(0, 3); lcd_print(" "); lcd_print(" ");
lcd_set_cursor(0, 3);
lcd_print(" ");
if ((int32_t)lcd_encoder > 2) { lcd_encoder = 2; } if ((int32_t)lcd_encoder > 2) {
if ((int32_t)lcd_encoder < 1) { lcd_encoder = 1; } lcd_encoder = 2;
}
if ((int32_t)lcd_encoder < 1) {
lcd_encoder = 1;
}
lcd_set_cursor(0, 1 + lcd_encoder); lcd_set_cursor(0, 1 + lcd_encoder);
lcd_print(">"); lcd_print(">");
@ -6177,7 +6262,8 @@ bool lcd_selftest()
bool _result = true; bool _result = true;
lcd_wait_for_cool_down(); lcd_wait_for_cool_down();
lcd_clear(); lcd_clear();
lcd_set_cursor(0, 0); lcd_puts_P(_i("Self test start "));////MSG_SELFTEST_START c=20 r=0 lcd_set_cursor(0, 0);
lcd_puts_P(_i("Self test start "));////MSG_SELFTEST_START c=20 r=0
#ifdef TMC2130 #ifdef TMC2130
FORCE_HIGH_POWER_START; FORCE_HIGH_POWER_START;
#endif // TMC2130 #endif // TMC2130
@ -6373,9 +6459,15 @@ static bool lcd_selfcheck_axis_sg(unsigned char axis) {
float margin = 60; float margin = 60;
float max_error_mm = 5; float max_error_mm = 5;
switch (axis) { switch (axis) {
case 0: axis_length = X_MAX_POS; break; case 0:
case 1: axis_length = Y_MAX_POS + 8; break; axis_length = X_MAX_POS;
default: axis_length = 210; break; break;
case 1:
axis_length = Y_MAX_POS + 8;
break;
default:
axis_length = 210;
break;
} }
tmc2130_sg_stop_on_crash = false; tmc2130_sg_stop_on_crash = false;
@ -6894,7 +6986,8 @@ static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite)
bool _result = check_opposite; bool _result = check_opposite;
lcd_clear(); lcd_clear();
lcd_set_cursor(0, 0); lcd_puts_P(_T(MSG_SELFTEST_FAN)); lcd_set_cursor(0, 0);
lcd_puts_P(_T(MSG_SELFTEST_FAN));
switch (_fan) switch (_fan)
{ {
@ -6917,9 +7010,12 @@ static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite)
} }
delay(500); delay(500);
lcd_set_cursor(1, 2); lcd_puts_P(_T(MSG_SELFTEST_FAN_YES)); lcd_set_cursor(1, 2);
lcd_set_cursor(0, 3); lcd_print(">"); lcd_puts_P(_T(MSG_SELFTEST_FAN_YES));
lcd_set_cursor(1, 3); lcd_puts_P(_T(MSG_SELFTEST_FAN_NO)); lcd_set_cursor(0, 3);
lcd_print(">");
lcd_set_cursor(1, 3);
lcd_puts_P(_T(MSG_SELFTEST_FAN_NO));
int8_t enc_dif = 0; int8_t enc_dif = 0;
KEEPALIVE_STATE(PAUSED_FOR_USER); KEEPALIVE_STATE(PAUSED_FOR_USER);
@ -6944,18 +7040,26 @@ static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite)
if (abs((enc_dif - lcd_encoder_diff)) > 2) { if (abs((enc_dif - lcd_encoder_diff)) > 2) {
if (enc_dif > lcd_encoder_diff) { if (enc_dif > lcd_encoder_diff) {
_result = !check_opposite; _result = !check_opposite;
lcd_set_cursor(0, 2); lcd_print(">"); lcd_set_cursor(0, 2);
lcd_set_cursor(1, 2); lcd_puts_P(_T(MSG_SELFTEST_FAN_YES)); lcd_print(">");
lcd_set_cursor(0, 3); lcd_print(" "); lcd_set_cursor(1, 2);
lcd_set_cursor(1, 3); lcd_puts_P(_T(MSG_SELFTEST_FAN_NO)); lcd_puts_P(_T(MSG_SELFTEST_FAN_YES));
lcd_set_cursor(0, 3);
lcd_print(" ");
lcd_set_cursor(1, 3);
lcd_puts_P(_T(MSG_SELFTEST_FAN_NO));
} }
if (enc_dif < lcd_encoder_diff) { if (enc_dif < lcd_encoder_diff) {
_result = check_opposite; _result = check_opposite;
lcd_set_cursor(0, 2); lcd_print(" "); lcd_set_cursor(0, 2);
lcd_set_cursor(1, 2); lcd_puts_P(_T(MSG_SELFTEST_FAN_YES)); lcd_print(" ");
lcd_set_cursor(0, 3); lcd_print(">"); lcd_set_cursor(1, 2);
lcd_set_cursor(1, 3); lcd_puts_P(_T(MSG_SELFTEST_FAN_NO)); lcd_puts_P(_T(MSG_SELFTEST_FAN_YES));
lcd_set_cursor(0, 3);
lcd_print(">");
lcd_set_cursor(1, 3);
lcd_puts_P(_T(MSG_SELFTEST_FAN_NO));
} }
enc_dif = 0; enc_dif = 0;
lcd_encoder_diff = 0; lcd_encoder_diff = 0;
@ -7014,7 +7118,8 @@ static bool lcd_selftest_fan_dialog(int _fan)
manage_heater(); //turn off fan manage_heater(); //turn off fan
manage_inactivity(true); //to turn off print fan manage_inactivity(true); //to turn off print fan
if (!fan_speed[1]) { if (!fan_speed[1]) {
_result = false; _errno = 6; //print fan not spinning _result = false;
_errno = 6; //print fan not spinning
} }
else if (fan_speed[1] < 34) { //fan is spinning, but measured RPM are too low for print fan, it must be left extruder fan else if (fan_speed[1] < 34) { //fan is spinning, but measured RPM are too low for print fan, it must be left extruder fan
//check fans manually //check fans manually

View File

@ -24,8 +24,14 @@
#define PRINT(p) print(p) #define PRINT(p) print(p)
#define DEC 10 #define DEC 10
#define HEX 16 #define HEX 16
void print(const char* pc) { printf("%s", pc); } void print(const char* pc) {
void print(int v) { printf("%d", v); } printf("%s", pc);
void print(float v) { printf("%f", v); } }
void print(int v) {
printf("%d", v);
}
void print(float v) {
printf("%f", v);
}
#endif //RC522_RPI #endif //RC522_RPI

View File

@ -165,7 +165,8 @@ inline bool parse_version_P(const char *str, uint16_t version[4])
uint8_t n = minor - major - 1; uint8_t n = minor - major - 1;
if (n > 4) if (n > 4)
return false; return false;
memcpy_P(buf, major, n); buf[n] = 0; memcpy_P(buf, major, n);
buf[n] = 0;
char *endptr = NULL; char *endptr = NULL;
version[0] = strtol(buf, &endptr, 10); version[0] = strtol(buf, &endptr, 10);
if (*endptr != 0) if (*endptr != 0)
@ -173,7 +174,8 @@ inline bool parse_version_P(const char *str, uint16_t version[4])
n = rev - minor - 1; n = rev - minor - 1;
if (n > 4) if (n > 4)
return false; return false;
memcpy_P(buf, minor, n); buf[n] = 0; memcpy_P(buf, minor, n);
buf[n] = 0;
version[1] = strtol(buf, &endptr, 10); version[1] = strtol(buf, &endptr, 10);
if (*endptr != 0) if (*endptr != 0)
return false; return false;

View File

@ -102,9 +102,15 @@ matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3
//row_1.debug("row_1"); //row_1.debug("row_1");
//row_2.debug("row_2"); //row_2.debug("row_2");
matrix_3x3 new_matrix; matrix_3x3 new_matrix;
new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; new_matrix.matrix[0] = row_0.x;
new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; new_matrix.matrix[1] = row_0.y;
new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; new_matrix.matrix[2] = row_0.z;
new_matrix.matrix[3] = row_1.x;
new_matrix.matrix[4] = row_1.y;
new_matrix.matrix[5] = row_1.z;
new_matrix.matrix[6] = row_2.x;
new_matrix.matrix[7] = row_2.y;
new_matrix.matrix[8] = row_2.z;
//new_matrix.debug("new_matrix"); //new_matrix.debug("new_matrix");
return new_matrix; return new_matrix;
@ -112,9 +118,15 @@ matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3
void matrix_3x3::set_to_identity() void matrix_3x3::set_to_identity()
{ {
matrix[0] = 1; matrix[1] = 0; matrix[2] = 0; matrix[0] = 1;
matrix[3] = 0; matrix[4] = 1; matrix[5] = 0; matrix[1] = 0;
matrix[6] = 0; matrix[7] = 0; matrix[8] = 1; matrix[2] = 0;
matrix[3] = 0;
matrix[4] = 1;
matrix[5] = 0;
matrix[6] = 0;
matrix[7] = 0;
matrix[8] = 1;
} }
matrix_3x3 matrix_3x3::create_look_at(vector_3 target) matrix_3x3 matrix_3x3::create_look_at(vector_3 target)
@ -139,9 +151,15 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target)
matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) matrix_3x3 matrix_3x3::transpose(matrix_3x3 original)
{ {
matrix_3x3 new_matrix; matrix_3x3 new_matrix;
new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; new_matrix.matrix[0] = original.matrix[0];
new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; new_matrix.matrix[1] = original.matrix[3];
new_matrix.matrix[6] = original.matrix[2]; new_matrix.matrix[7] = original.matrix[5]; new_matrix.matrix[8] = original.matrix[8]; new_matrix.matrix[2] = original.matrix[6];
new_matrix.matrix[3] = original.matrix[1];
new_matrix.matrix[4] = original.matrix[4];
new_matrix.matrix[5] = original.matrix[7];
new_matrix.matrix[6] = original.matrix[2];
new_matrix.matrix[7] = original.matrix[5];
new_matrix.matrix[8] = original.matrix[8];
return new_matrix; return new_matrix;
} }

View File

@ -88,9 +88,12 @@ uint8_t xyzcal_dm = 0;
void xyzcal_update_pos(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t) void xyzcal_update_pos(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t)
{ {
// DBG(_n("xyzcal_update_pos dx=%d dy=%d dz=%d dir=%02x\n"), dx, dy, dz, xyzcal_dm); // DBG(_n("xyzcal_update_pos dx=%d dy=%d dz=%d dir=%02x\n"), dx, dy, dz, xyzcal_dm);
if (xyzcal_dm&1) count_position[0] -= dx; else count_position[0] += dx; if (xyzcal_dm&1) count_position[0] -= dx;
if (xyzcal_dm&2) count_position[1] -= dy; else count_position[1] += dy; else count_position[0] += dx;
if (xyzcal_dm&4) count_position[2] -= dz; else count_position[2] += dz; if (xyzcal_dm&2) count_position[1] -= dy;
else count_position[1] += dy;
if (xyzcal_dm&4) count_position[2] -= dz;
else count_position[2] += dz;
// DBG(_n(" after xyzcal_update_pos x=%ld y=%ld z=%ld\n"), count_position[0], count_position[1], count_position[2]); // DBG(_n(" after xyzcal_update_pos x=%ld y=%ld z=%ld\n"), count_position[0], count_position[1], count_position[2]);
} }
@ -792,7 +795,8 @@ bool xyzcal_find_bed_induction_sensor_point_xy(void)
{ {
uint32_t x_avg = 0; uint32_t x_avg = 0;
uint32_t y_avg = 0; uint32_t y_avg = 0;
uint8_t n; for (n = 0; n < 4; n++) uint8_t n;
for (n = 0; n < 4; n++)
{ {
if (!xyzcal_find_point_center2(1000)) break; if (!xyzcal_find_point_center2(1000)) break;
x_avg += _X; x_avg += _X;