Upstream Merging

This commit is contained in:
Rob McKenzie 2018-11-14 16:14:15 +10:00
parent 2c6c976fe3
commit ec8844d744
121 changed files with 25645 additions and 40722 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
Firmware/.DS_Store vendored

Binary file not shown.

0
Firmware/BlinkM.cpp Normal file → Executable file
View File

0
Firmware/BlinkM.h Normal file → Executable file
View File

4
Firmware/Configuration.h Normal file → Executable file
View File

@ -7,8 +7,8 @@
#define STR(x) STR_HELPER(x) #define STR(x) STR_HELPER(x)
// Firmware version // Firmware version
#define FW_VERSION "5.0.2" #define FW_VERSION "3.5.0-RC1"
#define FW_COMMIT_NR 9999 #define FW_COMMIT_NR 1688
// FW_VERSION_UNKNOWN means this is an unofficial build. // FW_VERSION_UNKNOWN means this is an unofficial build.
// The firmware should only be checked into github with this symbol. // The firmware should only be checked into github with this symbol.
#define FW_DEV_VERSION FW_VERSION_UNKNOWN #define FW_DEV_VERSION FW_VERSION_UNKNOWN

0
Firmware/ConfigurationStore.cpp Normal file → Executable file
View File

17
Firmware/ConfigurationStore.h Normal file → Executable file
View File

@ -54,20 +54,11 @@ 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() { FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }
Config_ResetDefault();
Config_PrintSettings();
}
#endif #endif
inline uint8_t calibration_status() { inline uint8_t calibration_status() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS); }
return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS); 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); }
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

0
Firmware/Configuration_adv.h Normal file → Executable file
View File

78
Firmware/Dcodes.cpp Normal file → Executable file
View File

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

0
Firmware/Dcodes.h Normal file → Executable file
View File

0
Firmware/Firmware.ino Normal file → Executable file
View File

File diff suppressed because it is too large Load Diff

4
Firmware/Marlin.h Normal file → Executable file
View File

@ -262,9 +262,7 @@ 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() { FORCE_INLINE unsigned long millis_nc() { return timer0_millis; }
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);

0
Firmware/MarlinSerial.cpp Normal file → Executable file
View File

0
Firmware/MarlinSerial.h Normal file → Executable file
View File

333
Firmware/Marlin_main.cpp Normal file → Executable file
View File

@ -407,26 +407,15 @@ 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() { int freeMemory() { return SdFatUtil::FreeRam(); }
return SdFatUtil::FreeRam();
}
#else #else
extern "C" { extern "C" {
extern unsigned int __bss_end; extern unsigned int __bss_end;
@ -829,18 +818,10 @@ void factory_reset()
factory_reset(level); factory_reset(level);
switch (level) { switch (level) {
case 0: case 0: _delay_ms(0); break;
_delay_ms(0); case 1: _delay_ms(0); break;
break; case 2: _delay_ms(0); break;
case 1: case 3: _delay_ms(0); break;
_delay_ms(0);
break;
case 2:
_delay_ms(0);
break;
case 3:
_delay_ms(0);
break;
} }
} }
@ -851,12 +832,8 @@ void factory_reset()
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): 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
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.")); 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
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);
@ -867,8 +844,7 @@ 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_at_P(0, 2, PSTR("ver ")); lcd_puts_P(PSTR(FW_VERSION_FULL));
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;
@ -1505,8 +1481,7 @@ 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: default: break; //no change, show no message
break; //no change, show no message
} }
if (!previous_settings_retrieved) { if (!previous_settings_retrieved) {
@ -1843,15 +1818,9 @@ void loop()
// crashdet_stop_and_save_print(); // crashdet_stop_and_save_print();
switch (crash) switch (crash)
{ {
case 1: case 1: enquecommand_P((PSTR("CRASH_DETECTEDX"))); break;
enquecommand_P((PSTR("CRASH_DETECTEDX"))); case 2: enquecommand_P((PSTR("CRASH_DETECTEDY"))); break;
break; case 3: enquecommand_P((PSTR("CRASH_DETECTEDXY"))); break;
case 2:
enquecommand_P((PSTR("CRASH_DETECTEDY")));
break;
case 3:
enquecommand_P((PSTR("CRASH_DETECTEDXY")));
break;
} }
} }
#endif //TMC2130 #endif //TMC2130
@ -1887,12 +1856,8 @@ static void axis_is_at_home(int axis) {
} }
inline void set_current_to_destination() { inline void set_current_to_destination() { memcpy(current_position, destination, sizeof(current_position)); }
memcpy(current_position, destination, sizeof(current_position)); inline void set_destination_to_current() { memcpy(destination, current_position, sizeof(destination)); }
}
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) {
@ -2078,8 +2043,7 @@ 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); if (ratio) SERIAL_ECHOLN(ratio); else SERIAL_ECHOLNPGM("Auto");
else SERIAL_ECHOLNPGM("Auto");
} }
#endif // LIN_ADVANCE #endif // LIN_ADVANCE
@ -2448,10 +2412,8 @@ 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 "); SERIAL_ECHOPGM("G28, initial "); print_world_coordinates();
print_world_coordinates(); SERIAL_ECHOPGM("G28, initial "); print_physical_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.
@ -2518,14 +2480,12 @@ 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[X_AXIS] = 0;current_position[Y_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[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[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];
@ -2608,20 +2568,15 @@ 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[X_AXIS]);MYSERIAL.println(current_position[Y_AXIS]);
MYSERIAL.println(current_position[Y_AXIS]); MYSERIAL.println(current_position[Z_AXIS]);MYSERIAL.println(current_position[E_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[X_AXIS]);MYSERIAL.println(destination[Y_AXIS]);
MYSERIAL.println(destination[Y_AXIS]); MYSERIAL.println(destination[Z_AXIS]);MYSERIAL.println(destination[E_AXIS]);
MYSERIAL.println(destination[Z_AXIS]); MYSERIAL.println(feedrate);MYSERIAL.println(active_extruder);
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();
@ -2728,18 +2683,13 @@ void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, long home_
} }
#endif #endif
if (farm_mode) { if (farm_mode) { prusa_statistics(20); };
prusa_statistics(20);
};
homing_flag = false; homing_flag = false;
#if 0 #if 0
SERIAL_ECHOPGM("G28, final "); SERIAL_ECHOPGM("G28, final "); print_world_coordinates();
print_world_coordinates(); SERIAL_ECHOPGM("G28, final "); print_physical_coordinates();
SERIAL_ECHOPGM("G28, final "); SERIAL_ECHOPGM("G28, final "); print_mesh_bed_leveling_table();
print_physical_coordinates();
SERIAL_ECHOPGM("G28, final ");
print_mesh_bed_leveling_table();
#endif #endif
} }
@ -2975,7 +2925,6 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float
{ {
st_synchronize(); st_synchronize();
float lastpos[4]; float lastpos[4];
mmuFSensorLoading = false;
if (farm_mode) if (farm_mode)
{ {
@ -4150,8 +4099,7 @@ void process_commands()
printf_P(_N("\nZERO: %.3f\n"), current_position[Z_AXIS]); printf_P(_N("\nZERO: %.3f\n"), current_position[Z_AXIS]);
int i = -1; int i = -1; for (; i < 5; i++)
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));
@ -4323,27 +4271,14 @@ void process_commands()
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")) { if (code_seen("XP")) { strchr_pointer+=1; points_x = code_value(); }
strchr_pointer+=1; if (code_seen("YP")) { strchr_pointer+=1; points_y = code_value(); }
points_x = code_value(); if (code_seen("XO")) { strchr_pointer+=1; offset_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
@ -4357,8 +4292,7 @@ void process_commands()
} }
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
@ -5025,8 +4959,7 @@ case_G80:
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){
@ -5549,8 +5482,7 @@ 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);
@ -5565,9 +5497,7 @@ Sigma_Exit:
} }
LCD_MESSAGERPGM(_T(MSG_HEATING)); LCD_MESSAGERPGM(_T(MSG_HEATING));
heating_status = 1; heating_status = 1;
if (farm_mode) { if (farm_mode) { prusa_statistics(1); };
prusa_statistics(1);
};
#ifdef AUTOTEMP #ifdef AUTOTEMP
autotemp_enabled=false; autotemp_enabled=false;
@ -5604,9 +5534,7 @@ 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) { if (farm_mode) { prusa_statistics(2); };
prusa_statistics(2);
};
//starttime=millis(); //starttime=millis();
previous_millis_cmd = millis(); previous_millis_cmd = millis();
@ -5616,9 +5544,7 @@ 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) { if (farm_mode) { prusa_statistics(1); };
prusa_statistics(1);
};
if (code_seen('S')) if (code_seen('S'))
{ {
setTargetBed(code_value()); setTargetBed(code_value());
@ -6075,8 +6001,7 @@ 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'))
@ -6087,8 +6012,7 @@ 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'))
@ -6106,8 +6030,7 @@ 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;
@ -6118,8 +6041,7 @@ 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);
@ -6128,8 +6050,7 @@ 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>
@ -6156,8 +6077,7 @@ 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
{ {
@ -6994,44 +6914,6 @@ Sigma_Exit:
{ {
#ifdef SNMM #ifdef SNMM
if ((*(strchr_pointer + index) < '0' || *(strchr_pointer + index) > '4') && *(strchr_pointer + index) != '?') {
SERIAL_ECHOLNPGM("Invalid T code.");
}
else {
if (*(strchr_pointer + index) == '?')
{
if(mmu_enabled)
{
tmp_extruder = choose_menu_P(_T(MSG_CHOOSE_FILAMENT), _T(MSG_FILAMENT));
} else
{
tmp_extruder = choose_menu_P(_T(MSG_CHOOSE_EXTRUDER), _T(MSG_EXTRUDER));
}
}
else {
tmp_extruder = code_value();
}
snmm_filaments_used |= (1 << tmp_extruder); //for stop print
if (mmu_enabled)
{
mmu_command(MMU_CMD_T0 + tmp_extruder);
manage_response(true, true);
delay(150);
mmu_command(MMU_CMD_C0);
mmu_extruder = tmp_extruder; //filament change is finished
if (*(strchr_pointer + index) == '?')// for single material usage with mmu
{
delay(100);
mmu_load_to_nozzle();
}
}
else
{
#ifdef SNMM
#ifdef LIN_ADVANCE #ifdef LIN_ADVANCE
if (mmu_extruder != tmp_extruder) if (mmu_extruder != tmp_extruder)
clear_current_adv_vars(); //Check if the selected extruder is not the active one and reset LIN_ADVANCE variables if so. clear_current_adv_vars(); //Check if the selected extruder is not the active one and reset LIN_ADVANCE variables if so.
@ -7133,63 +7015,49 @@ Sigma_Exit:
{ {
#ifdef DEBUG_DCODES #ifdef DEBUG_DCODES
case -1: //! D-1 - Endless loop case -1: //! D-1 - Endless loop
dcode__1(); dcode__1(); break;
break;
case 0: //! D0 - Reset case 0: //! D0 - Reset
dcode_0(); dcode_0(); break;
break;
case 1: //! D1 - Clear EEPROM case 1: //! D1 - Clear EEPROM
dcode_1(); dcode_1(); break;
break;
case 2: //! D2 - Read/Write RAM case 2: //! D2 - Read/Write RAM
dcode_2(); dcode_2(); break;
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(); dcode_3(); break;
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(); dcode_4(); break;
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(); dcode_5(); break;
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(); dcode_6(); break;
break;
case 7: //! D7 - Read/Write Bootloader case 7: //! D7 - Read/Write Bootloader
dcode_7(); dcode_7(); break;
break;
case 8: //! D8 - Read/Write PINDA case 8: //! D8 - Read/Write PINDA
dcode_8(); dcode_8(); break;
break;
case 9: //! D9 - Read/Write ADC case 9: //! D9 - Read/Write ADC
dcode_9(); dcode_9(); break;
break;
case 10: //! D10 - XYZ calibration = OK case 10: //! D10 - XYZ calibration = OK
dcode_10(); dcode_10(); break;
break;
#ifdef TMC2130 #ifdef TMC2130
case 2130: //! D2130 - TMC2130 case 2130: //! D2130 - TMC2130
dcode_2130(); dcode_2130(); break;
break;
#endif //TMC2130 #endif //TMC2130
#ifdef FILAMENT_SENSOR #ifdef FILAMENT_SENSOR
case 9125: //! D9125 - FILAMENT_SENSOR case 9125: //! D9125 - FILAMENT_SENSOR
dcode_9125(); dcode_9125(); break;
break;
#endif //FILAMENT_SENSOR #endif //FILAMENT_SENSOR
#endif //DEBUG_DCODES #endif //DEBUG_DCODES
@ -7601,6 +7469,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
disable_e2(); disable_e2();
} }
} }
}
#ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH
if (chdkActive && (millis() - chdkHigh > CHDK_DELAY)) if (chdkActive && (millis() - chdkHigh > CHDK_DELAY))
@ -7718,9 +7587,7 @@ void Stop()
} }
} }
bool IsStopped() { bool IsStopped() { return Stopped; };
return Stopped;
};
#ifdef FAST_PWM_FAN #ifdef FAST_PWM_FAN
void setPwmFrequency(uint8_t pin, int val) void setPwmFrequency(uint8_t pin, int val)
@ -7928,7 +7795,7 @@ static void wait_for_heater(long codenum, uint8_t extruder) {
codenum = millis(); codenum = millis();
} }
manage_heater(); manage_heater();
manage_inactivity(); manage_inactivity(true); //do not disable steppers
lcd_update(0); lcd_update(0);
#ifdef TEMP_RESIDENCY_TIME #ifdef TEMP_RESIDENCY_TIME
/* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
@ -8136,37 +8003,9 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_
output = atof(mergeOutput); output = atof(mergeOutput);
#ifdef TEMP_RESIDENCY_TIME if (digit[4] == 8) //Handle sign
SERIAL_PROTOCOLPGM(" W:");
if (residencyStart > -1)
{ {
codenum = ((TEMP_RESIDENCY_TIME * 1000UL) - (millis() - residencyStart)) / 1000UL; output *= -1;
SERIAL_PROTOCOLLN(codenum);
}
else
{
SERIAL_PROTOCOLLN("?");
}
}
#else
SERIAL_PROTOCOLLN("");
#endif
codenum = millis();
}
manage_heater();
manage_inactivity(true); //do not disable steppers
lcd_update(0);
#ifdef TEMP_RESIDENCY_TIME
/* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
or when current temp falls outside the hysteresis after target temp was reached */
if ((residencyStart == -1 && target_direction && (degHotend(extruder) >= (degTargetHotend(extruder) - TEMP_WINDOW))) ||
(residencyStart == -1 && !target_direction && (degHotend(extruder) <= (degTargetHotend(extruder) + TEMP_WINDOW))) ||
(residencyStart > -1 && labs(degHotend(extruder) - degTargetHotend(extruder)) > TEMP_HYSTERESIS))
{
residencyStart = millis();
}
#endif //TEMP_RESIDENCY_TIME
}
} }
for (int i = digit[11]; i > 0; i--) //Handle floating point for (int i = digit[11]; i > 0; i--) //Handle floating point
@ -8727,12 +8566,9 @@ 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; axis_known_position[X_AXIS] = true; enable_x();
enable_x(); axis_known_position[Y_AXIS] = true; enable_y();
axis_known_position[Y_AXIS] = true; axis_known_position[Z_AXIS] = true; enable_z();
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();
@ -8794,15 +8630,12 @@ 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")); strcpy_P(cmd, PSTR("G1 X")); strcat(cmd, ftostr32(eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0))));
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(" 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")); strcpy_P(cmd, PSTR("G1 Z")); strcat(cmd, ftostr32(eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_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"));
@ -8872,18 +8705,12 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
} }
#if 0 #if 0
SERIAL_ECHOPGM("SDPOS_ATOMIC="); SERIAL_ECHOPGM("SDPOS_ATOMIC="); MYSERIAL.println(sdpos_atomic, DEC);
MYSERIAL.println(sdpos_atomic, DEC); SERIAL_ECHOPGM("SDPOS="); MYSERIAL.println(card.get_sdpos(), DEC);
SERIAL_ECHOPGM("SDPOS="); SERIAL_ECHOPGM("SDLEN_PLAN="); MYSERIAL.println(sdlen_planner, DEC);
MYSERIAL.println(card.get_sdpos(), DEC); SERIAL_ECHOPGM("SDLEN_CMDQ="); MYSERIAL.println(sdlen_cmdqueue, DEC);
SERIAL_ECHOPGM("SDLEN_PLAN="); SERIAL_ECHOPGM("PLANNERBLOCKS="); MYSERIAL.println(int(nplanner_blocks), DEC);
MYSERIAL.println(sdlen_planner, DEC); SERIAL_ECHOPGM("SDSAVED="); MYSERIAL.println(saved_sdpos, 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);

0
Firmware/Sd2Card.cpp Normal file → Executable file
View File

28
Firmware/Sd2Card.h Normal file → Executable file
View File

@ -170,19 +170,13 @@ public:
* 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) { void error(uint8_t code) {errorCode_ = 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 { int errorCode() const {return errorCode_;}
return errorCode_;
}
/** \return error data for last error. */ /** \return error data for last error. */
int errorData() const { int errorData() const {return status_;}
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).
@ -222,9 +216,7 @@ public:
/** 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 { int type() const {return type_;}
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);
@ -233,12 +225,8 @@ public:
// 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) { void setFlashAirCompatible(bool flashAirCompatible) { flash_air_compatible_ = flashAirCompatible; }
flash_air_compatible_ = flashAirCompatible; bool getFlashAirCompatible() const { return flash_air_compatible_; }
}
bool getFlashAirCompatible() const {
return flash_air_compatible_;
}
private: private:
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -259,9 +247,7 @@ private:
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) { void type(uint8_t value) {type_ = 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);

0
Firmware/Sd2PinMap.h Normal file → Executable file
View File

0
Firmware/SdBaseFile.cpp Normal file → Executable file
View File

76
Firmware/SdBaseFile.h Normal file → Executable file
View File

@ -184,9 +184,7 @@ public:
/** 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() { ~SdBaseFile() {if(isOpen()) close();}
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
@ -209,17 +207,11 @@ public:
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 { uint32_t curCluster() const {return curCluster_;}
return curCluster_;
}
/** \return The current position for a file or directory. */ /** \return The current position for a file or directory. */
uint32_t curPosition() const { uint32_t curPosition() const {return curPosition_;}
return curPosition_;
}
/** \return Current working directory */ /** \return Current working directory */
static SdBaseFile* cwd() { static SdBaseFile* cwd() {return 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
@ -252,38 +244,24 @@ public:
dateTime_ = dateTime; dateTime_ = dateTime;
} }
/** Cancel the date/time callback function. */ /** Cancel the date/time callback function. */
static void dateTimeCallbackCancel() { static void dateTimeCallbackCancel() {dateTime_ = 0;}
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 { uint32_t fileSize() const {return fileSize_;}
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 { uint32_t firstCluster() const {return firstCluster_;}
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 { bool isDir() const {return type_ >= FAT_FILE_TYPE_MIN_DIR;}
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 { bool isFile() const {return type_ == FAT_FILE_TYPE_NORMAL;}
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 { bool isOpen() const {return type_ != FAT_FILE_TYPE_CLOSED;}
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 { bool isSubDir() const {return type_ == FAT_FILE_TYPE_SUBDIR;}
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;
@ -309,15 +287,11 @@ public:
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() { void rewind() {seekSet(0);}
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() { bool rmDir() {return 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.
@ -330,9 +304,7 @@ public:
* \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) { bool seekEnd(int32_t offset = 0) {return seekSet(fileSize_ + offset);}
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);
@ -343,14 +315,10 @@ public:
* *
* \return The file or directory type. * \return The file or directory type.
*/ */
uint8_t type() const { uint8_t type() const {return type_;}
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 { SdVolume* volume() const {return vol_;}
return vol_;
}
int16_t write(const void* buf, uint16_t nbyte); int16_t write(const void* buf, uint16_t nbyte);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
private: private:
@ -433,9 +401,7 @@ public:
* \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) { bool dirEntry(dir_t& dir) {return dirEntry(&dir);} // NOLINT
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
@ -484,16 +450,12 @@ public:
* \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) { bool openRoot(SdVolume& vol) {return openRoot(&vol);} // NOLINT
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) { int8_t readDir(dir_t& dir, char* longFilename) {return readDir(&dir, longFilename);} // NOLINT
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.

0
Firmware/SdFatConfig.h Normal file → Executable file
View File

0
Firmware/SdFatStructs.h Normal file → Executable file
View File

0
Firmware/SdFatUtil.cpp Normal file → Executable file
View File

0
Firmware/SdFatUtil.h Normal file → Executable file
View File

0
Firmware/SdFile.cpp Normal file → Executable file
View File

2
Firmware/SdFile.h Normal file → Executable 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);

0
Firmware/SdInfo.h Normal file → Executable file
View File

0
Firmware/SdVolume.cpp Normal file → Executable file
View File

80
Firmware/SdVolume.h Normal file → Executable file
View File

@ -80,69 +80,43 @@ public:
* 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) { bool init(Sd2Card* dev) { return init(dev, 1) ? true : init(dev, 0);}
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 { uint8_t blocksPerCluster() const {return blocksPerCluster_;}
return blocksPerCluster_;
}
/** \return The number of blocks in one FAT. */ /** \return The number of blocks in one FAT. */
uint32_t blocksPerFat() const { uint32_t blocksPerFat() const {return blocksPerFat_;}
return blocksPerFat_;
}
/** \return The total number of clusters in the volume. */ /** \return The total number of clusters in the volume. */
uint32_t clusterCount() const { uint32_t clusterCount() const {return clusterCount_;}
return clusterCount_;
}
/** \return The shift count required to multiply by blocksPerCluster. */ /** \return The shift count required to multiply by blocksPerCluster. */
uint8_t clusterSizeShift() const { uint8_t clusterSizeShift() const {return clusterSizeShift_;}
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 { uint32_t dataStartBlock() const {return dataStartBlock_;}
return dataStartBlock_;
}
/** \return The number of FAT structures on the volume. */ /** \return The number of FAT structures on the volume. */
uint8_t fatCount() const { uint8_t fatCount() const {return fatCount_;}
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 { uint32_t fatStartBlock() const {return fatStartBlock_;}
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 { uint8_t fatType() const {return fatType_;}
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 { uint32_t rootDirEntryCount() const {return rootDirEntryCount_;}
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 { uint32_t rootDirStart() const {return rootDirStart_;}
return rootDirStart_;
}
/** Sd2Card object for this volume /** Sd2Card object for this volume
* \return pointer to Sd2Card object. * \return pointer to Sd2Card object.
*/ */
Sd2Card* sdCard() { Sd2Card* sdCard() {return 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) { bool dbgFat(uint32_t n, uint32_t* v) {return fatGet(n, v);}
return fatGet(n, v);
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
private: private:
// Allow SdBaseFile access to SdVolume private data. // Allow SdBaseFile access to SdVolume private data.
@ -180,20 +154,13 @@ private:
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
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_;}
cache_t *cache() { uint32_t cacheBlockNumber() {return cacheBlockNumber_;}
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);
@ -206,9 +173,7 @@ private:
cacheDirty_ = dirty; cacheDirty_ = dirty;
cacheBlockNumber_ = blockNumber; cacheBlockNumber_ = blockNumber;
} }
void cacheSetDirty() { void cacheSetDirty() {cacheDirty_ |= CACHE_FOR_WRITE;}
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);
@ -222,8 +187,7 @@ private:
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);
} }
@ -235,9 +199,7 @@ public:
* \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) { bool init(Sd2Card& dev) {return init(&dev);} // NOLINT
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.

3
Firmware/Servo.cpp Normal file → Executable file
View File

@ -263,8 +263,7 @@ 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; if (pin > 0) this->pin = pin; else pin = this->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;

0
Firmware/Servo.h Normal file → Executable file
View File

0
Firmware/Timer.cpp Normal file → Executable file
View File

12
Firmware/Timer.h Normal file → Executable file
View File

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

0
Firmware/TimerRemaining.h Normal file → Executable file
View File

3
Firmware/adc.c Normal file → Executable file
View File

@ -38,8 +38,7 @@ void adc_reset(void)
{ {
adc_state = 0; adc_state = 0;
adc_count = 0; adc_count = 0;
uint8_t i; uint8_t i; for (i = 0; i < ADC_CHAN_CNT; 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;
} }

0
Firmware/adc.h Normal file → Executable file
View File

0
Firmware/boards.h Normal file → Executable file
View File

0
Firmware/bootapp.c Normal file → Executable file
View File

0
Firmware/bootapp.h Normal file → Executable file
View File

9
Firmware/cardreader.cpp Normal file → Executable file
View File

@ -276,17 +276,12 @@ uint16_t CardReader::getWorkDirDepth() {
void CardReader::getAbsFilename(char *t) void CardReader::getAbsFilename(char *t)
{ {
uint8_t cnt=0; uint8_t cnt=0;
*t='/'; *t='/';t++;cnt++;
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);

52
Firmware/cardreader.h Normal file → Executable file
View File

@ -52,52 +52,22 @@ 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) { FORCE_INLINE void setSortOn(bool b) { sort_alpha = b; presort(); }
sort_alpha = b; FORCE_INLINE void setSortFolders(int i) { sort_folders = i; presort(); }
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() { FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
return file.isOpen(); FORCE_INLINE bool eof() { return sdpos>=filesize ;};
} FORCE_INLINE int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
FORCE_INLINE bool eof() { FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);};
return sdpos>=filesize ; 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 int16_t get() { FORCE_INLINE uint32_t get_sdpos() { if (!isFileOpen()) return 0; else return(sdpos); };
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 { bool ToshibaFlashAir_isEnabled() const { return card.getFlashAirCompatible(); }
return card.getFlashAirCompatible(); void ToshibaFlashAir_enable(bool enable) { card.setFlashAirCompatible(enable); }
}
void ToshibaFlashAir_enable(bool enable) {
card.setFlashAirCompatible(enable);
}
bool ToshibaFlashAir_GetIP(uint8_t *ip); bool ToshibaFlashAir_GetIP(uint8_t *ip);
public: public:

0
Firmware/cmdqueue.cpp Normal file → Executable file
View File

24
Firmware/cmdqueue.h Normal file → Executable file
View File

@ -71,24 +71,12 @@ 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) { static inline bool code_seen(char code) { return (strchr_pointer = strchr(CMDBUFFER_CURRENT_STRING, code)) != NULL; }
return (strchr_pointer = strchr(CMDBUFFER_CURRENT_STRING, code)) != NULL; static inline bool code_seen(const char *code) { return (strchr_pointer = strstr(CMDBUFFER_CURRENT_STRING, code)) != NULL; }
} static inline float code_value() { return strtod(strchr_pointer+1, NULL);}
static inline bool code_seen(const char *code) { static inline long code_value_long() { return strtol(strchr_pointer+1, NULL, 10); }
return (strchr_pointer = strstr(CMDBUFFER_CURRENT_STRING, code)) != NULL; 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() {
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()
{ {

0
Firmware/config.h Normal file → Executable file
View File

23
Firmware/configuration_prusa.h Normal file → Executable file
View File

@ -183,7 +183,7 @@
#define CMD_DIAGNOSTICS //Show cmd queue length on printer display #define CMD_DIAGNOSTICS //Show cmd queue length on printer display
#endif /* DEBUG_BUILD */ #endif /* DEBUG_BUILD */
#define FSENSOR_QUALITY //#define FSENSOR_QUALITY
#define LINEARITY_CORRECTION #define LINEARITY_CORRECTION
@ -261,6 +261,8 @@
#define TMC2130_STEALTH_Z #define TMC2130_STEALTH_Z
//#define TMC2130_SERVICE_CODES_M910_M918
//#define TMC2130_DEBUG //#define TMC2130_DEBUG
//#define TMC2130_DEBUG_WR //#define TMC2130_DEBUG_WR
//#define TMC2130_DEBUG_RD //#define TMC2130_DEBUG_RD
@ -339,12 +341,13 @@
#define FILAMENTCHANGE_FIRSTRETRACT -2 #define FILAMENTCHANGE_FIRSTRETRACT -2
#define FILAMENTCHANGE_FINALRETRACT -80 #define FILAMENTCHANGE_FINALRETRACT -80
#define FILAMENTCHANGE_FIRSTFEED 70 #define FILAMENTCHANGE_FIRSTFEED 70 //E distance in mm for fast filament loading sequence used used in filament change (M600)
#define FILAMENTCHANGE_FINALFEED 50 #define FILAMENTCHANGE_FINALFEED 25 //E distance in mm for slow filament loading sequence used used in filament change (M600) and filament load (M701)
#define FILAMENTCHANGE_RECFEED 5 #define FILAMENTCHANGE_RECFEED 5
#define FILAMENTCHANGE_XYFEED 50 #define FILAMENTCHANGE_XYFEED 50
#define FILAMENTCHANGE_EFEED 20 #define FILAMENTCHANGE_EFEED_FIRST 20 // feedrate in mm/s for fast filament loading sequence used in filament change (M600)
#define FILAMENTCHANGE_EFEED_FINAL 3.3f // feedrate in mm/s for slow filament loading sequence used in filament change (M600) and filament load (M701)
//#define FILAMENTCHANGE_RFEED 400 //#define FILAMENTCHANGE_RFEED 400
#define FILAMENTCHANGE_RFEED 7000 / 60 #define FILAMENTCHANGE_RFEED 7000 / 60
#define FILAMENTCHANGE_EXFEED 2 #define FILAMENTCHANGE_EXFEED 2
@ -374,16 +377,8 @@
MOTOR CURRENT SETTINGS MOTOR CURRENT SETTINGS
*------------------------------------*/ *------------------------------------*/
// Motor Current setting for BIG RAMBo // Motor Current settings for Einsy/tmc = 0..63
#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) #define MOTOR_CURRENT_PWM_RANGE 63
#define DIGIPOT_MOTOR_CURRENT_LOUD {135,135,135,135,135}
// Motor Current settings for RAMBo mini PWM value = MotorCurrentSetting * 255 / range
#if MOTHERBOARD == BOARD_RAMBO_MINI_1_0 || MOTHERBOARD == BOARD_RAMBO_MINI_1_3
#define MOTOR_CURRENT_PWM_RANGE 2000
#define DEFAULT_PWM_MOTOR_CURRENT {400, 750, 750} // {XY,Z,E}
#define DEFAULT_PWM_MOTOR_CURRENT_LOUD {400, 750, 750} // {XY,Z,E}
#endif
/*------------------------------------ /*------------------------------------
BED SETTINGS BED SETTINGS

0
Firmware/conv2str.cpp Normal file → Executable file
View File

0
Firmware/conv2str.h Normal file → Executable file
View File

0
Firmware/doxyfile Normal file → Executable file
View File

0
Firmware/eeprom.h Normal file → Executable file
View File

0
Firmware/fastio.h Normal file → Executable file
View File

View File

@ -294,7 +294,6 @@ bool fsensor_check_autoload(void)
// if ((fsensor_autoload_c >= 15) && (fsensor_autoload_sum > 30)) // if ((fsensor_autoload_c >= 15) && (fsensor_autoload_sum > 30))
if ((fsensor_autoload_c >= 12) && (fsensor_autoload_sum > 20)) if ((fsensor_autoload_c >= 12) && (fsensor_autoload_sum > 20))
{ {
//puts_P(_N("fsensor_check_autoload = true !!!\n"));
if (mmu_enabled) mmu_command(MMU_CMD_FS); if (mmu_enabled) mmu_command(MMU_CMD_FS);
fsensor_autoload_check_stop(); fsensor_autoload_check_stop();
fsensor_autoload_enabled = false; fsensor_autoload_enabled = false;

3
Firmware/fsensor.h Normal file → Executable file
View File

@ -14,9 +14,6 @@ extern bool fsensor_not_responding;
//enable/disable quality meassurement //enable/disable quality meassurement
extern bool fsensor_oq_meassure_enabled; extern bool fsensor_oq_meassure_enabled;
//extern bool mmuFilamentMK3Moving;
extern bool mmuFSensorLoading;
//! @name save restore printing //! @name save restore printing
//! @{ //! @{

0
Firmware/io_atmega2560.h Normal file → Executable file
View File

44
Firmware/language.c Normal file → Executable file
View File

@ -17,22 +17,12 @@ 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) { uint8_t lang_select(uint8_t lang) { return 0; }
return 0; uint8_t lang_get_count() { return 1; }
} uint16_t lang_get_code(uint8_t lang) { return LANG_CODE_EN; }
uint8_t lang_get_count() { const char* lang_get_name_by_code(uint16_t code) { return _n("English"); }
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) { uint8_t lang_is_selected(void) { return 1; }
return 1;
}
#else //(LANG_MODE == 0) //secondary languages in progmem or xflash #else //(LANG_MODE == 0) //secondary languages in progmem or xflash
@ -106,8 +96,7 @@ 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; uint16_t i; for (i = 0; i < size; 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
@ -214,20 +203,13 @@ const char* lang_get_name_by_code(uint16_t code)
{ {
switch (code) switch (code)
{ {
case LANG_CODE_EN: case LANG_CODE_EN: return _n("English");
return _n("English"); case LANG_CODE_CZ: return _n("Cestina");
case LANG_CODE_CZ: case LANG_CODE_DE: return _n("Deutsch");
return _n("Cestina"); case LANG_CODE_ES: return _n("Espanol");
case LANG_CODE_DE: case LANG_CODE_FR: return _n("Francais");
return _n("Deutsch"); case LANG_CODE_IT: return _n("Italiano");
case LANG_CODE_ES: case LANG_CODE_PL: return _n("Polski");
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("??");
} }

0
Firmware/language.h Normal file → Executable file
View File

51
Firmware/lcd.cpp Normal file → Executable file
View File

@ -419,10 +419,8 @@ uint8_t lcd_escape_write(uint8_t chr)
case 2: case 2:
switch (chr) switch (chr)
{ {
case '2': case '2': return 1; // escape = "\x1b[2"
return 1; // escape = "\x1b[2" case '?': return 1; // escape = "\x1b[?"
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"
} }
@ -435,11 +433,7 @@ 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;"
@ -867,8 +861,7 @@ const uint8_t lcd_chardata_bedTemp[8] PROGMEM = {
B10101, B10101,
B11111, B11111,
B00000, B00000,
B00000 B00000}; //thanks Sonny Mounicou
}; //thanks Sonny Mounicou
const uint8_t lcd_chardata_degree[8] PROGMEM = { const uint8_t lcd_chardata_degree[8] PROGMEM = {
B01100, B01100,
@ -878,8 +871,7 @@ 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,
@ -889,8 +881,7 @@ 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,
@ -900,8 +891,7 @@ const uint8_t lcd_chardata_uplevel[8] PROGMEM = {
B11100, B11100,
B00000, B00000,
B00000, B00000,
B00000 B00000}; //thanks joris
}; //thanks joris
const uint8_t lcd_chardata_refresh[8] PROGMEM = { const uint8_t lcd_chardata_refresh[8] PROGMEM = {
B00000, B00000,
@ -911,8 +901,7 @@ const uint8_t lcd_chardata_refresh[8] PROGMEM = {
B00011, B00011,
B10011, B10011,
B01100, B01100,
B00000 B00000}; //thanks joris
}; //thanks joris
const uint8_t lcd_chardata_folder[8] PROGMEM = { const uint8_t lcd_chardata_folder[8] PROGMEM = {
B00000, B00000,
@ -922,8 +911,7 @@ const uint8_t lcd_chardata_folder[8] PROGMEM = {
B10001, B10001,
B11111, B11111,
B00000, B00000,
B00000 B00000}; //thanks joris
}; //thanks joris
/*const uint8_t lcd_chardata_feedrate[8] PROGMEM = { /*const uint8_t lcd_chardata_feedrate[8] PROGMEM = {
B11100, B11100,
@ -963,8 +951,7 @@ 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,
@ -974,8 +961,7 @@ const uint8_t lcd_chardata_clock[8] PROGMEM = {
B10001, B10001,
B01110, B01110,
B00000, B00000,
B00000 B00000}; //thanks Sonny Mounicou
}; //thanks Sonny Mounicou
const uint8_t lcd_chardata_arrup[8] PROGMEM = { const uint8_t lcd_chardata_arrup[8] PROGMEM = {
B00100, B00100,
@ -985,8 +971,7 @@ 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,
@ -996,8 +981,7 @@ const uint8_t lcd_chardata_arrdown[8] PROGMEM = {
B00000, B00000,
B10001, B10001,
B01010, B01010,
B00100 B00100};
};
@ -1028,8 +1012,7 @@ 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)
{ {
@ -1044,8 +1027,7 @@ 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,
@ -1054,8 +1036,7 @@ 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)
{ {

0
Firmware/lcd.h Normal file → Executable file
View File

0
Firmware/le.sh Normal file → Executable file
View File

0
Firmware/menu.cpp Normal file → Executable file
View File

0
Firmware/menu.h Normal file → Executable file
View File

18
Firmware/mesh_bed_calibration.cpp Normal file → Executable file
View File

@ -129,9 +129,7 @@ const float bed_ref_points[] PROGMEM = {
#endif //not HEATBED_V2 #endif //not HEATBED_V2
static inline float sqr(float x) { static inline float sqr(float x) { return x * 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*/)
@ -1160,8 +1158,7 @@ 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) {
@ -2568,14 +2565,9 @@ 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: case 0: found = improve_bed_induction_sensor_point(); break;
found = improve_bed_induction_sensor_point(); case 1: found = improve_bed_induction_sensor_point2(mesh_point < 2, verbosity_level); break;
break; default: break;
case 1:
found = improve_bed_induction_sensor_point2(mesh_point < 2, verbosity_level);
break;
default:
break;
} }
} }
if (found) { if (found) {

0
Firmware/mesh_bed_calibration.h Normal file → Executable file
View File

4
Firmware/mesh_bed_leveling.cpp Normal file → Executable file
View File

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

12
Firmware/mesh_bed_leveling.h Normal file → Executable file
View File

@ -21,21 +21,15 @@ public:
void upsample_3x3(); void upsample_3x3();
#endif #endif
static float get_x(int i) { static float get_x(int i) { return float(MESH_MIN_X) + float(MESH_X_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); }
}
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) { void set_z(int ix, int iy, float z) { z_values[iy][ix] = z; }
z_values[iy][ix] = z;
}
int select_x_index(float x) { int select_x_index(float x) {
int i = 1; int i = 1;

0
Firmware/messages.c Normal file → Executable file
View File

0
Firmware/messages.h Normal file → Executable file
View File

View File

@ -440,7 +440,7 @@ void mmu_loop(void)
if (!mmu_finda && CHECK_FINDA && fsensor_enabled) { if (!mmu_finda && CHECK_FINDA && fsensor_enabled) {
fsensor_stop_and_save_print(); fsensor_stop_and_save_print();
enquecommand_front_P(PSTR("FSENSOR_RECOVER")); //then recover enquecommand_front_P(PSTR("FSENSOR_RECOVER")); //then recover
if (lcd_autoDeplete) enquecommand_front_P(PSTR("M600 AUTO")); //save print and run M600 command if (lcd_autoDepleteEnabled()) enquecommand_front_P(PSTR("M600 AUTO")); //save print and run M600 command
else enquecommand_front_P(PSTR("M600")); //save print and run M600 command else enquecommand_front_P(PSTR("M600")); //save print and run M600 command
} }
mmu_state = 1; mmu_state = 1;

12
Firmware/motion_control.cpp Normal file → Executable file
View File

@ -41,12 +41,8 @@ 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) { if (angular_travel < 0) { angular_travel += 2*M_PI; }
angular_travel += 2*M_PI; if (isclockwise) { 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
@ -57,9 +53,7 @@ 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) { if (millimeters_of_travel < 0.001) { return; }
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;

0
Firmware/motion_control.h Normal file → Executable file
View File

3
Firmware/optiboot_w25x20cl.cpp Normal file → Executable file
View File

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

0
Firmware/optiboot_w25x20cl.h Normal file → Executable file
View File

2
Firmware/pat9125.c Normal file → Executable file
View File

@ -26,8 +26,6 @@
#define PAT9125_BANK_SELECTION 0x7f #define PAT9125_BANK_SELECTION 0x7f
#define PAT9125_NEW_INIT
#ifdef PAT9125_SWSPI #ifdef PAT9125_SWSPI
#include "swspi.h" #include "swspi.h"
#endif //PAT9125_SWSPI #endif //PAT9125_SWSPI

0
Firmware/pins.h Normal file → Executable file
View File

0
Firmware/pins_Einsy_1_0.h Normal file → Executable file
View File

0
Firmware/pins_Rambo_1_0.h Normal file → Executable file
View File

0
Firmware/pins_Rambo_1_3.h Normal file → Executable file
View File

44
Firmware/planner.cpp Normal file → Executable file
View File

@ -872,34 +872,22 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
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) { if(g_uc_extruder_last_move[1] == 0) {disable_e1();}
disable_e1(); if(g_uc_extruder_last_move[2] == 0) {disable_e2();}
}
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) { if(g_uc_extruder_last_move[0] == 0) {disable_e0();}
disable_e0(); if(g_uc_extruder_last_move[2] == 0) {disable_e2();}
}
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) { if(g_uc_extruder_last_move[0] == 0) {disable_e0();}
disable_e0(); if(g_uc_extruder_last_move[1] == 0) {disable_e1();}
}
if(g_uc_extruder_last_move[1] == 0) {
disable_e1();
}
break; break;
} }
} }
@ -1014,25 +1002,13 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
// 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;

0
Firmware/planner.h Normal file → Executable file
View File

0
Firmware/printers.h Normal file → Executable file
View File

0
Firmware/qr_solve.cpp Normal file → Executable file
View File

0
Firmware/qr_solve.h Normal file → Executable file
View File

0
Firmware/rbuf.c Normal file → Executable file
View File

0
Firmware/rbuf.h Normal file → Executable file
View File

64
Firmware/sm4.c Normal file → Executable file
View File

@ -50,23 +50,15 @@ 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: case 0: return (PORTL & 2)?0:1;
return (PORTL & 2)?0:1; case 1: return (PORTL & 1)?0:1;
case 1: case 2: return (PORTL & 4)?0:1;
return (PORTL & 1)?0:1; case 3: return (PORTL & 64)?1:0;
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: case 0: return (PORTL & 1)?1:0;
return (PORTL & 1)?1:0; case 1: return (PORTL & 2)?0:1;
case 1: case 2: return (PORTL & 4)?1:0;
return (PORTL & 2)?0:1; case 3: return (PORTL & 64)?0:1;
case 2:
return (PORTL & 4)?1:0;
case 3:
return (PORTL & 64)?0:1;
#endif #endif
} }
return 0; return 0;
@ -77,39 +69,15 @@ 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: case 0: if (!dir) PORTL |= 2; else PORTL &= ~2; break;
if (!dir) PORTL |= 2; case 1: if (!dir) PORTL |= 1; else PORTL &= ~1; break;
else PORTL &= ~2; case 2: if (!dir) PORTL |= 4; else PORTL &= ~4; break;
break; case 3: if (dir) PORTL |= 64; else PORTL &= ~64; 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: case 0: if (dir) PORTL |= 1; else PORTL &= ~1; break;
if (dir) PORTL |= 1; case 1: if (!dir) PORTL |= 2; else PORTL &= ~2; break;
else PORTL &= ~1; case 2: if (dir) PORTL |= 4; else PORTL &= ~4; break;
break; case 3: if (!dir) PORTL |= 64; else PORTL &= ~64; 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");

0
Firmware/sm4.h Normal file → Executable file
View File

0
Firmware/sound.cpp Normal file → Executable file
View File

0
Firmware/sound.h Normal file → Executable file
View File

0
Firmware/speed_lookuptable.h Normal file → Executable file
View File

0
Firmware/spi.c Normal file → Executable file
View File

0
Firmware/spi.h Normal file → Executable file
View File

0
Firmware/static_assert.h Normal file → Executable file
View File

63
Firmware/stepper.cpp Normal file → Executable file
View File

@ -1525,8 +1525,7 @@ void babystep(const uint8_t axis,const bool direction)
} }
break; break;
default: default: break;
break;
} }
} }
#endif //BABYSTEPPING #endif //BABYSTEPPING
@ -1624,42 +1623,22 @@ void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2)
{ {
if(ms1 > -1) switch(driver) if(ms1 > -1) switch(driver)
{ {
case 0: case 0: digitalWrite( X_MS1_PIN,ms1); break;
digitalWrite( X_MS1_PIN,ms1); case 1: digitalWrite( Y_MS1_PIN,ms1); break;
break; case 2: digitalWrite( Z_MS1_PIN,ms1); break;
case 1: case 3: digitalWrite(E0_MS1_PIN,ms1); break;
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: case 4: digitalWrite(E1_MS1_PIN,ms1); break;
digitalWrite(E1_MS1_PIN,ms1);
break;
#endif #endif
} }
if(ms2 > -1) switch(driver) if(ms2 > -1) switch(driver)
{ {
case 0: case 0: digitalWrite( X_MS2_PIN,ms2); break;
digitalWrite( X_MS2_PIN,ms2); case 1: digitalWrite( Y_MS2_PIN,ms2); break;
break; case 2: digitalWrite( Z_MS2_PIN,ms2); break;
case 1: case 3: digitalWrite(E0_MS2_PIN,ms2); break;
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: case 4: digitalWrite(E1_MS2_PIN,ms2); break;
digitalWrite(E1_MS2_PIN,ms2);
break;
#endif #endif
} }
} }
@ -1668,21 +1647,11 @@ void microstep_mode(uint8_t driver, uint8_t stepping_mode)
{ {
switch(stepping_mode) switch(stepping_mode)
{ {
case 1: case 1: microstep_ms(driver,MICROSTEP1); break;
microstep_ms(driver,MICROSTEP1); case 2: microstep_ms(driver,MICROSTEP2); break;
break; case 4: microstep_ms(driver,MICROSTEP4); break;
case 2: case 8: microstep_ms(driver,MICROSTEP8); break;
microstep_ms(driver,MICROSTEP2); case 16: microstep_ms(driver,MICROSTEP16); break;
break;
case 4:
microstep_ms(driver,MICROSTEP4);
break;
case 8:
microstep_ms(driver,MICROSTEP8);
break;
case 16:
microstep_ms(driver,MICROSTEP16);
break;
} }
} }

0
Firmware/stepper.h Normal file → Executable file
View File

0
Firmware/stk500.h Normal file → Executable file
View File

34
Firmware/swi2c.c Normal file → Executable file
View File

@ -25,8 +25,7 @@ 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; uint8_t i; for (i = 0; i < 100; i++)
for (i = 0; i < 100; i++)
__delay(); __delay();
} }
@ -82,8 +81,7 @@ 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; int8_t bit; for (bit = 7; bit >= 0; bit--)
for (bit = 7; bit >= 0; bit--)
{ {
PIN_SET(SWI2C_SCL); PIN_SET(SWI2C_SCL);
__delay(); __delay();
@ -97,8 +95,7 @@ uint8_t swi2c_read(void)
void swi2c_write(uint8_t data) void swi2c_write(uint8_t data)
{ {
int8_t bit; int8_t bit; for (bit = 7; bit >= 0; 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);
@ -114,10 +111,7 @@ 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()) { if (!swi2c_wait_ack()) { swi2c_stop(); return 0; }
swi2c_stop();
return 0;
}
swi2c_stop(); swi2c_stop();
return 1; return 1;
} }
@ -128,10 +122,7 @@ 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()) { if (!swi2c_wait_ack()) { swi2c_stop(); return 0; }
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();
@ -148,10 +139,7 @@ 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()) { if (!swi2c_wait_ack()) { swi2c_stop(); return 0; }
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);
@ -168,10 +156,7 @@ 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()) { if (!swi2c_wait_ack()) { swi2c_stop(); return 0; }
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);
@ -190,10 +175,7 @@ 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()) { if (!swi2c_wait_ack()) { swi2c_stop(); return 0; }
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);

0
Firmware/swi2c.h Normal file → Executable file
View File

9
Firmware/swspi.cpp Normal file → Executable file
View File

@ -42,8 +42,7 @@ 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; unsigned char i = 0; for (; i < 8; i++)
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);
@ -60,8 +59,7 @@ 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; unsigned char i = 0; for (; i < 8; i++)
for (; i < 8; i++)
{ {
rx <<= 1; rx <<= 1;
DELAY(delay); DELAY(delay);
@ -77,8 +75,7 @@ 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; unsigned char i = 0; for (; i < 8; i++)
for (; i < 8; i++)
{ {
rx <<= 1; rx <<= 1;
if (tx & 0x80) GPIO_SET(swspi_mosi); if (tx & 0x80) GPIO_SET(swspi_mosi);

69
Firmware/temperature.cpp Normal file → Executable file
View File

@ -307,31 +307,22 @@ void PID_autotune(float temp, int extruder, int ncycles)
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_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias);
SERIAL_PROTOCOL(bias); SERIAL_PROTOCOLPGM(" d: "); SERIAL_PROTOCOL(d);
SERIAL_PROTOCOLPGM(" d: "); SERIAL_PROTOCOLPGM(" min: "); SERIAL_PROTOCOL(min);
SERIAL_PROTOCOL(d); SERIAL_PROTOCOLPGM(" max: "); SERIAL_PROTOCOLLN(max);
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_PROTOCOLPGM(" Ku: "); SERIAL_PROTOCOL(Ku);
SERIAL_PROTOCOL(Ku); SERIAL_PROTOCOLPGM(" Tu: "); SERIAL_PROTOCOLLN(Tu);
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_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(_Kp);
SERIAL_PROTOCOLLN(_Kp); SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(_Ki);
SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(_Kd);
SERIAL_PROTOCOLLN(_Ki);
SERIAL_PROTOCOLPGM(" Kd: ");
SERIAL_PROTOCOLLN(_Kd);
/* /*
_Kp = 0.33*Ku; _Kp = 0.33*Ku;
_Ki = _Kp/Tu; _Ki = _Kp/Tu;
@ -1242,13 +1233,9 @@ 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) { if (farm_mode) { prusa_statistics(0); }
prusa_statistics(0);
}
temp_runaway_stop(true, _isbed); temp_runaway_stop(true, _isbed);
if (farm_mode) { if (farm_mode) { prusa_statistics(91); }
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;
@ -1282,13 +1269,9 @@ 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) { if (farm_mode) { prusa_statistics(0); }
prusa_statistics(0);
}
temp_runaway_stop(false, _isbed); temp_runaway_stop(false, _isbed);
if (farm_mode) { if (farm_mode) { prusa_statistics(90); }
prusa_statistics(90);
}
} }
} }
} }
@ -1407,9 +1390,7 @@ void max_temp_error(uint8_t e) {
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) { if (farm_mode) { prusa_statistics(93); }
prusa_statistics(93);
}
} }
void min_temp_error(uint8_t e) { void min_temp_error(uint8_t e) {
@ -1427,9 +1408,7 @@ void min_temp_error(uint8_t e) {
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
Stop(); Stop();
#endif #endif
if (farm_mode) { if (farm_mode) { prusa_statistics(92); }
prusa_statistics(92);
}
} }
@ -1611,23 +1590,19 @@ 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); if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1); else WRITE(HEATER_1_PIN,0);
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); if(soft_pwm_2 > 0) WRITE(HEATER_2_PIN,1); else WRITE(HEATER_2_PIN,0);
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); if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0);
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); if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0);
else WRITE(FAN_PIN,0);
#endif #endif
} }
if(soft_pwm_0 < pwm_count) if(soft_pwm_0 < pwm_count)
@ -1837,8 +1812,7 @@ 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); if (soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0);
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
@ -1890,7 +1864,8 @@ ISR(TIMER0_COMPB_vect)
babystepsTodo[axis]--; //less to do next time babystepsTodo[axis]--; //less to do next time
asm("sei"); asm("sei");
} }
else if(curTodo<0) else
if(curTodo<0)
{ {
asm("cli"); asm("cli");
babystep(axis,/*fwd*/false); babystep(axis,/*fwd*/false);

0
Firmware/temperature.h Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More