merge MK3_dev into MK3

This commit is contained in:
PavelSindler 2018-10-22 20:25:29 +02:00
commit 940f436a5f
36 changed files with 1681 additions and 1777 deletions

View file

@ -1,3 +1,5 @@
//! @file
#include "Marlin.h"
#include "planner.h"
#include "temperature.h"
@ -9,149 +11,71 @@
#include "mesh_bed_leveling.h"
#endif
M500_conf cs;
//! @brief Write data to EEPROM
//! @param pos destination in EEPROM, 0 is start
//! @param value value to be written
//! @param size size of type pointed by value
//! @param name name of variable written, used only for debug input if DEBUG_EEPROM_WRITE defined
//! @retval true success
//! @retval false failed
#ifdef DEBUG_EEPROM_WRITE
#define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value), #value)
static bool EEPROM_writeData(uint8_t* pos, uint8_t* value, uint8_t size, const char* name)
#else //DEBUG_EEPROM_WRITE
#define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value), 0)
static bool EEPROM_writeData(uint8_t* pos, uint8_t* value, uint8_t size, const char*)
#endif //DEBUG_EEPROM_WRITE
void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size, char* name)
{
#ifdef DEBUG_EEPROM_WRITE
printf_P(PSTR("EEPROM_WRITE_VAR addr=0x%04x size=0x%02hhx name=%s\n"), pos, size, name);
#endif //DEBUG_EEPROM_WRITE
while (size--) {
uint8_t * const p = (uint8_t * const)pos;
uint8_t v = *value;
// EEPROM has only ~100,000 write cycles,
// so only write bytes that have changed!
if (v != eeprom_read_byte(p)) {
eeprom_write_byte(p, v);
if (eeprom_read_byte(p) != v) {
SERIAL_ECHOLNPGM("EEPROM Error");
return;
}
}
while (size--)
{
eeprom_update_byte(pos, *value);
if (eeprom_read_byte(pos) != *value) {
SERIAL_ECHOLNPGM("EEPROM Error");
return false;
}
pos++;
value++;
};
}
return true;
}
#ifdef DEBUG_EEPROM_READ
#define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value), #value)
static void EEPROM_readData(uint8_t* pos, uint8_t* value, uint8_t size, const char* name)
#else //DEBUG_EEPROM_READ
#define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value), 0)
static void EEPROM_readData(uint8_t* pos, uint8_t* value, uint8_t size, const char*)
#endif //DEBUG_EEPROM_READ
void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size, char* name)
{
#ifdef DEBUG_EEPROM_READ
printf_P(PSTR("EEPROM_READ_VAR addr=0x%04x size=0x%02hhx name=%s\n"), pos, size, name);
#endif //DEBUG_EEPROM_READ
do
while(size--)
{
*value = eeprom_read_byte((unsigned char*)pos);
*value = eeprom_read_byte(pos);
pos++;
value++;
}while(--size);
}
}
//======================================================================================
// IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
// in the functions below, also increment the version number and update EEPROM_M500_SIZE. This makes sure that
// the default values are used whenever there is a change to the data, to prevent
// wrong data being written to the variables.
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
#define EEPROM_VERSION "V2"
#ifdef EEPROM_SETTINGS
void Config_StoreSettings(uint16_t offset)
void Config_StoreSettings()
{
char ver[4]= "000";
int i = offset;
EEPROM_WRITE_VAR(i,ver); // invalidate data first
EEPROM_WRITE_VAR(i,axis_steps_per_unit);
EEPROM_WRITE_VAR(i,max_feedrate_normal);
EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second_normal);
EEPROM_WRITE_VAR(i,acceleration);
EEPROM_WRITE_VAR(i,retract_acceleration);
EEPROM_WRITE_VAR(i,minimumfeedrate);
EEPROM_WRITE_VAR(i,mintravelfeedrate);
EEPROM_WRITE_VAR(i,minsegmenttime);
EEPROM_WRITE_VAR(i,max_jerk[X_AXIS]);
EEPROM_WRITE_VAR(i,max_jerk[Y_AXIS]);
EEPROM_WRITE_VAR(i,max_jerk[Z_AXIS]);
EEPROM_WRITE_VAR(i,max_jerk[E_AXIS]);
EEPROM_WRITE_VAR(i,add_homing);
/* EEPROM_WRITE_VAR(i,plaPreheatHotendTemp);
EEPROM_WRITE_VAR(i,plaPreheatHPBTemp);
EEPROM_WRITE_VAR(i,plaPreheatFanSpeed);
EEPROM_WRITE_VAR(i,absPreheatHotendTemp);
EEPROM_WRITE_VAR(i,absPreheatHPBTemp);
EEPROM_WRITE_VAR(i,absPreheatFanSpeed);
*/
strcpy(cs.version,"000"); //!< invalidate data first @TODO use erase to save one erase cycle
EEPROM_WRITE_VAR(i,zprobe_zoffset);
#ifdef PIDTEMP
EEPROM_WRITE_VAR(i,Kp);
EEPROM_WRITE_VAR(i,Ki);
EEPROM_WRITE_VAR(i,Kd);
#else
float dummy = 3000.0f;
EEPROM_WRITE_VAR(i,dummy);
dummy = 0.0f;
EEPROM_WRITE_VAR(i,dummy);
EEPROM_WRITE_VAR(i,dummy);
#endif
#ifdef PIDTEMPBED
EEPROM_WRITE_VAR(i, bedKp);
EEPROM_WRITE_VAR(i, bedKi);
EEPROM_WRITE_VAR(i, bedKd);
#endif
int lcd_contrast = 0;
EEPROM_WRITE_VAR(i,lcd_contrast);
#ifdef FWRETRACT
EEPROM_WRITE_VAR(i,autoretract_enabled);
EEPROM_WRITE_VAR(i,retract_length);
#if EXTRUDERS > 1
EEPROM_WRITE_VAR(i,retract_length_swap);
#endif
EEPROM_WRITE_VAR(i,retract_feedrate);
EEPROM_WRITE_VAR(i,retract_zlift);
EEPROM_WRITE_VAR(i,retract_recover_length);
#if EXTRUDERS > 1
EEPROM_WRITE_VAR(i,retract_recover_length_swap);
#endif
EEPROM_WRITE_VAR(i,retract_recover_feedrate);
#endif
// Save filament sizes
EEPROM_WRITE_VAR(i, volumetric_enabled);
EEPROM_WRITE_VAR(i, filament_size[0]);
#if EXTRUDERS > 1
EEPROM_WRITE_VAR(i, filament_size[1]);
#if EXTRUDERS > 2
EEPROM_WRITE_VAR(i, filament_size[2]);
#endif
#endif
EEPROM_WRITE_VAR(i,max_feedrate_silent);
EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second_silent);
if (EEPROM_M500_SIZE + EEPROM_OFFSET == i) {
char ver2[4] = EEPROM_VERSION;
i = offset;
EEPROM_WRITE_VAR(i, ver2); // validate data
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Settings Stored");
}
else { //size of eeprom M500 section probably changed by mistake and data are not valid; do not validate data by storing eeprom version
//M500 EEPROM section will be erased on next printer reboot and default vaules will be used
puts_P(PSTR("Data stored to EEPROM not valid."));
if (EEPROM_writeData(reinterpret_cast<uint8_t*>(EEPROM_M500_base),reinterpret_cast<uint8_t*>(&cs),sizeof(cs),0), "cs, invalid version")
{
strcpy(cs.version,EEPROM_VERSION); //!< validate data if write succeed
EEPROM_writeData(reinterpret_cast<uint8_t*>(EEPROM_M500_base->version), reinterpret_cast<uint8_t*>(cs.version), sizeof(cs.version), "cs.version valid");
}
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Settings Stored");
}
#endif //EEPROM_SETTINGS
@ -170,14 +94,14 @@ void Config_PrintSettings(uint8_t level)
"%SAdvanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)\n%S M205 S%.2f T%.2f B%.2f X%.2f Y%.2f Z%.2f E%.2f\n"
"%SHome offset (mm):\n%S M206 X%.2f Y%.2f Z%.2f\n"
),
echomagic, echomagic, axis_steps_per_unit[X_AXIS], axis_steps_per_unit[Y_AXIS], axis_steps_per_unit[Z_AXIS], axis_steps_per_unit[E_AXIS],
echomagic, echomagic, max_feedrate_normal[X_AXIS], max_feedrate_normal[Y_AXIS], max_feedrate_normal[Z_AXIS], max_feedrate_normal[E_AXIS],
echomagic, echomagic, max_feedrate_silent[X_AXIS], max_feedrate_silent[Y_AXIS], max_feedrate_silent[Z_AXIS], max_feedrate_silent[E_AXIS],
echomagic, echomagic, max_acceleration_units_per_sq_second_normal[X_AXIS], max_acceleration_units_per_sq_second_normal[Y_AXIS], max_acceleration_units_per_sq_second_normal[Z_AXIS], max_acceleration_units_per_sq_second_normal[E_AXIS],
echomagic, echomagic, max_acceleration_units_per_sq_second_silent[X_AXIS], max_acceleration_units_per_sq_second_silent[Y_AXIS], max_acceleration_units_per_sq_second_silent[Z_AXIS], max_acceleration_units_per_sq_second_silent[E_AXIS],
echomagic, echomagic, acceleration, retract_acceleration,
echomagic, echomagic, minimumfeedrate, mintravelfeedrate, minsegmenttime, max_jerk[X_AXIS], max_jerk[Y_AXIS], max_jerk[Z_AXIS], max_jerk[E_AXIS],
echomagic, echomagic, add_homing[X_AXIS], add_homing[Y_AXIS], add_homing[Z_AXIS]
echomagic, echomagic, cs.axis_steps_per_unit[X_AXIS], cs.axis_steps_per_unit[Y_AXIS], cs.axis_steps_per_unit[Z_AXIS], cs.axis_steps_per_unit[E_AXIS],
echomagic, echomagic, cs.max_feedrate_normal[X_AXIS], cs.max_feedrate_normal[Y_AXIS], cs.max_feedrate_normal[Z_AXIS], cs.max_feedrate_normal[E_AXIS],
echomagic, echomagic, cs.max_feedrate_silent[X_AXIS], cs.max_feedrate_silent[Y_AXIS], cs.max_feedrate_silent[Z_AXIS], cs.max_feedrate_silent[E_AXIS],
echomagic, echomagic, cs.max_acceleration_units_per_sq_second_normal[X_AXIS], cs.max_acceleration_units_per_sq_second_normal[Y_AXIS], cs.max_acceleration_units_per_sq_second_normal[Z_AXIS], cs.max_acceleration_units_per_sq_second_normal[E_AXIS],
echomagic, echomagic, cs.max_acceleration_units_per_sq_second_silent[X_AXIS], cs.max_acceleration_units_per_sq_second_silent[Y_AXIS], cs.max_acceleration_units_per_sq_second_silent[Z_AXIS], cs.max_acceleration_units_per_sq_second_silent[E_AXIS],
echomagic, echomagic, cs.acceleration, cs.retract_acceleration,
echomagic, echomagic, cs.minimumfeedrate, cs.mintravelfeedrate, cs.minsegmenttime, cs.max_jerk[X_AXIS], cs.max_jerk[Y_AXIS], cs.max_jerk[Z_AXIS], cs.max_jerk[E_AXIS],
echomagic, echomagic, cs.add_homing[X_AXIS], cs.add_homing[Y_AXIS], cs.add_homing[Z_AXIS]
#else //TMC2130
printf_P(PSTR(
"%SSteps per unit:\n%S M92 X%.2f Y%.2f Z%.2f E%.2f\n"
@ -187,21 +111,21 @@ void Config_PrintSettings(uint8_t level)
"%SAdvanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)\n%S M205 S%.2f T%.2f B%.2f X%.2f Y%.2f Z%.2f E%.2f\n"
"%SHome offset (mm):\n%S M206 X%.2f Y%.2f Z%.2f\n"
),
echomagic, echomagic, axis_steps_per_unit[X_AXIS], axis_steps_per_unit[Y_AXIS], axis_steps_per_unit[Z_AXIS], axis_steps_per_unit[E_AXIS],
echomagic, echomagic, cs.axis_steps_per_unit[X_AXIS], cs.axis_steps_per_unit[Y_AXIS], cs.axis_steps_per_unit[Z_AXIS], cs.axis_steps_per_unit[E_AXIS],
echomagic, echomagic, max_feedrate[X_AXIS], max_feedrate[Y_AXIS], max_feedrate[Z_AXIS], max_feedrate[E_AXIS],
echomagic, echomagic, max_acceleration_units_per_sq_second[X_AXIS], max_acceleration_units_per_sq_second[Y_AXIS], max_acceleration_units_per_sq_second[Z_AXIS], max_acceleration_units_per_sq_second[E_AXIS],
echomagic, echomagic, acceleration, retract_acceleration,
echomagic, echomagic, minimumfeedrate, mintravelfeedrate, minsegmenttime, max_jerk[X_AXIS], max_jerk[Y_AXIS], max_jerk[Z_AXIS], max_jerk[E_AXIS],
echomagic, echomagic, add_homing[X_AXIS], add_homing[Y_AXIS], add_homing[Z_AXIS]
echomagic, echomagic, cs.acceleration, cs.retract_acceleration,
echomagic, echomagic, cs.minimumfeedrate, cs.mintravelfeedrate, cs.minsegmenttime, cs.max_jerk[X_AXIS], cs.max_jerk[Y_AXIS], cs.max_jerk[Z_AXIS], cs.max_jerk[E_AXIS],
echomagic, echomagic, cs.add_homing[X_AXIS], cs.add_homing[Y_AXIS], cs.add_homing[Z_AXIS]
#endif //TMC2130
);
#ifdef PIDTEMP
printf_P(PSTR("%SPID settings:\n%S M301 P%.2f I%.2f D%.2f\n"),
echomagic, echomagic, Kp, unscalePID_i(Ki), unscalePID_d(Kd));
echomagic, echomagic, cs.Kp, unscalePID_i(cs.Ki), unscalePID_d(cs.Kd));
#endif
#ifdef PIDTEMPBED
printf_P(PSTR("%SPID heatbed settings:\n%S M304 P%.2f I%.2f D%.2f\n"),
echomagic, echomagic, bedKp, unscalePID_i(bedKi), unscalePID_d(bedKd));
echomagic, echomagic, cs.bedKp, unscalePID_i(cs.bedKi), unscalePID_d(cs.bedKd));
#endif
#ifdef FWRETRACT
printf_P(PSTR(
@ -209,23 +133,23 @@ void Config_PrintSettings(uint8_t level)
"%SRecover: S=Extra length (mm) F:Speed (mm/m)\n%S M208 S%.2f F%.2f\n"
"%SAuto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries\n%S M209 S%d\n"
),
echomagic, echomagic, retract_length, retract_feedrate*60, retract_zlift,
echomagic, echomagic, retract_recover_length, retract_recover_feedrate*60,
echomagic, echomagic, (autoretract_enabled ? 1 : 0)
echomagic, echomagic, cs.retract_length, cs.retract_feedrate*60, cs.retract_zlift,
echomagic, echomagic, cs.retract_recover_length, cs.retract_recover_feedrate*60,
echomagic, echomagic, (cs.autoretract_enabled ? 1 : 0)
);
#if EXTRUDERS > 1
printf_P(PSTR("%SMulti-extruder settings:\n%S Swap retract length (mm): %.2f\n%S Swap rec. addl. length (mm): %.2f\n"),
echomagic, echomagic, retract_length_swap, echomagic, retract_recover_length_swap);
#endif
if (volumetric_enabled) {
if (cs.volumetric_enabled) {
printf_P(PSTR("%SFilament settings:\n%S M200 D%.2f\n"),
echomagic, echomagic, filament_size[0]);
echomagic, echomagic, cs.filament_size[0]);
#if EXTRUDERS > 1
printf_P(PSTR("%S M200 T1 D%.2f\n"),
echomagic, echomagic, filament_size[1]);
echomagic, echomagic, cs.filament_size[1]);
#if EXTRUDERS > 2
printf_P(PSTR("%S M200 T1 D%.2f\n"),
echomagic, echomagic, filament_size[2]);
echomagic, echomagic, cs.filament_size[2]);
#endif
#endif
} else {
@ -243,110 +167,112 @@ void Config_PrintSettings(uint8_t level)
#ifdef EEPROM_SETTINGS
bool Config_RetrieveSettings(uint16_t offset)
static_assert (EXTRUDERS == 1, "ConfigurationStore M500_conf not implemented for more extruders, fix filament_size array size.");
static_assert (NUM_AXIS == 4, "ConfigurationStore M500_conf not implemented for more axis."
"Fix axis_steps_per_unit max_feedrate_normal max_acceleration_units_per_sq_second_normal max_jerk max_feedrate_silent"
" max_acceleration_units_per_sq_second_silent array size.");
#ifdef ENABLE_AUTO_BED_LEVELING
static_assert (false, "zprobe_zoffset was not initialized in printers in field to -(Z_PROBE_OFFSET_FROM_EXTRUDER), so it contains"
"0.0, if this is not acceptable, increment EEPROM_VERSION to force use default_conf");
#endif
static_assert (sizeof(M500_conf) == 188, "sizeof(M500_conf) has changed, ensure that EEPROM_VERSION has been incremented, "
"or if you added members in the end of struct, ensure that historically uninitialized values will be initialized."
"If this is caused by change to more then 8bit processor, decide whether make this struct packed to save EEPROM,"
"leave as it is to keep fast code, or reorder struct members to pack more tightly.");
static const M500_conf default_conf PROGMEM =
{
int i=offset;
bool previous_settings_retrieved = true;
char stored_ver[4];
char ver[4]=EEPROM_VERSION;
EEPROM_READ_VAR(i,stored_ver); //read stored version
// SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
if (strncmp(ver,stored_ver,3) == 0)
{
// version number match
EEPROM_READ_VAR(i,axis_steps_per_unit);
EEPROM_READ_VAR(i,max_feedrate_normal);
EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second_normal);
// steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
EEPROM_READ_VAR(i,acceleration);
EEPROM_READ_VAR(i,retract_acceleration);
EEPROM_READ_VAR(i,minimumfeedrate);
EEPROM_READ_VAR(i,mintravelfeedrate);
EEPROM_READ_VAR(i,minsegmenttime);
EEPROM_READ_VAR(i,max_jerk[X_AXIS]);
EEPROM_READ_VAR(i,max_jerk[Y_AXIS]);
EEPROM_READ_VAR(i,max_jerk[Z_AXIS]);
EEPROM_READ_VAR(i,max_jerk[E_AXIS]);
if (max_jerk[X_AXIS] > DEFAULT_XJERK) max_jerk[X_AXIS] = DEFAULT_XJERK;
if (max_jerk[Y_AXIS] > DEFAULT_YJERK) max_jerk[Y_AXIS] = DEFAULT_YJERK;
EEPROM_READ_VAR(i,add_homing);
/*
EEPROM_READ_VAR(i,plaPreheatHotendTemp);
EEPROM_READ_VAR(i,plaPreheatHPBTemp);
EEPROM_READ_VAR(i,plaPreheatFanSpeed);
EEPROM_READ_VAR(i,absPreheatHotendTemp);
EEPROM_READ_VAR(i,absPreheatHPBTemp);
EEPROM_READ_VAR(i,absPreheatFanSpeed);
*/
EEPROM_READ_VAR(i,zprobe_zoffset);
#ifndef PIDTEMP
float Kp,Ki,Kd;
#endif
// do not need to scale PID values as the values in EEPROM are already scaled
EEPROM_READ_VAR(i,Kp);
EEPROM_READ_VAR(i,Ki);
EEPROM_READ_VAR(i,Kd);
#ifdef PIDTEMPBED
EEPROM_READ_VAR(i, bedKp);
EEPROM_READ_VAR(i, bedKi);
EEPROM_READ_VAR(i, bedKd);
#endif
int lcd_contrast;
EEPROM_READ_VAR(i,lcd_contrast);
#ifdef FWRETRACT
EEPROM_READ_VAR(i,autoretract_enabled);
EEPROM_READ_VAR(i,retract_length);
#if EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_length_swap);
#endif
EEPROM_READ_VAR(i,retract_feedrate);
EEPROM_READ_VAR(i,retract_zlift);
EEPROM_READ_VAR(i,retract_recover_length);
#if EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_recover_length_swap);
#endif
EEPROM_READ_VAR(i,retract_recover_feedrate);
#endif
EEPROM_READ_VAR(i, volumetric_enabled);
EEPROM_READ_VAR(i, filament_size[0]);
EEPROM_VERSION,
DEFAULT_AXIS_STEPS_PER_UNIT,
DEFAULT_MAX_FEEDRATE,
DEFAULT_MAX_ACCELERATION,
DEFAULT_ACCELERATION,
DEFAULT_RETRACT_ACCELERATION,
DEFAULT_MINIMUMFEEDRATE,
DEFAULT_MINTRAVELFEEDRATE,
DEFAULT_MINSEGMENTTIME,
{DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK},
{0,0,0},
-(Z_PROBE_OFFSET_FROM_EXTRUDER),
DEFAULT_Kp,
DEFAULT_Ki*PID_dT,
DEFAULT_Kd/PID_dT,
DEFAULT_bedKp,
DEFAULT_bedKi*PID_dT,
DEFAULT_bedKd/PID_dT,
0,
false,
RETRACT_LENGTH,
RETRACT_FEEDRATE,
RETRACT_ZLIFT,
RETRACT_RECOVER_LENGTH,
RETRACT_RECOVER_FEEDRATE,
false,
{DEFAULT_NOMINAL_FILAMENT_DIA,
#if EXTRUDERS > 1
EEPROM_READ_VAR(i, filament_size[1]);
DEFAULT_NOMINAL_FILAMENT_DIA,
#if EXTRUDERS > 2
EEPROM_READ_VAR(i, filament_size[2]);
DEFAULT_NOMINAL_FILAMENT_DIA,
#endif
#endif
},
DEFAULT_MAX_FEEDRATE_SILENT,
DEFAULT_MAX_ACCELERATION_SILENT,
};
//! @brief Read M500 configuration
//! @retval true Succeeded. Stored settings retrieved or default settings retrieved in case EEPROM has been erased.
//! @retval false Failed. Default settings has been retrieved, because of older version or corrupted data.
bool Config_RetrieveSettings()
{
bool previous_settings_retrieved = true;
char ver[4]=EEPROM_VERSION;
EEPROM_readData(reinterpret_cast<uint8_t*>(EEPROM_M500_base->version), reinterpret_cast<uint8_t*>(cs.version), sizeof(cs.version), "cs.version"); //read stored version
// SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << cs.version << "]");
if (strncmp(ver,cs.version,3) == 0) // version number match
{
EEPROM_readData(reinterpret_cast<uint8_t*>(EEPROM_M500_base), reinterpret_cast<uint8_t*>(&cs), sizeof(cs), "cs");
if (cs.max_jerk[X_AXIS] > DEFAULT_XJERK) cs.max_jerk[X_AXIS] = DEFAULT_XJERK;
if (cs.max_jerk[Y_AXIS] > DEFAULT_YJERK) cs.max_jerk[Y_AXIS] = DEFAULT_YJERK;
calculate_extruder_multipliers();
calculate_extruder_multipliers();
int max_feedrate_silent_address = i;
EEPROM_READ_VAR(i,max_feedrate_silent);
EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second_silent);
//if max_feedrate_silent and max_acceleration_units_per_sq_second_silent were never stored to eeprom, use default values:
float tmp_feedrate[]=DEFAULT_MAX_FEEDRATE_SILENT;
unsigned long tmp_acceleration[]=DEFAULT_MAX_ACCELERATION_SILENT;
for (uint8_t axis = X_AXIS; axis <= E_AXIS; axis++) {
if (eeprom_read_dword((uint32_t*)(max_feedrate_silent_address + axis * 4)) == 0xffffffff) max_feedrate_silent[axis] = tmp_feedrate[axis];
if (max_acceleration_units_per_sq_second_silent[axis] == 0xffffffff) max_acceleration_units_per_sq_second_silent[axis] = tmp_acceleration[axis];
}
{
const uint32_t erased = 0xffffffff;
bool initialized = false;
for (uint8_t i = 0; i < (sizeof(cs.max_feedrate_silent)/sizeof(cs.max_feedrate_silent[0])); ++i)
{
for(uint8_t j = 0; j < sizeof(float); ++j)
{
if(0xff != reinterpret_cast<uint8_t*>(&(cs.max_feedrate_silent[i]))[j]) initialized = true;
}
if(erased != cs.max_acceleration_units_per_sq_second_silent[i]) initialized = true;
}
if (!initialized)
{
memcpy_P(&cs.max_feedrate_silent,&default_conf.max_feedrate_silent, sizeof(cs.max_feedrate_silent));
memcpy_P(&cs.max_acceleration_units_per_sq_second_silent,&default_conf.max_acceleration_units_per_sq_second_silent,
sizeof(cs.max_acceleration_units_per_sq_second_silent));
}
}
#ifdef TMC2130
for (uint8_t j = X_AXIS; j <= Y_AXIS; j++)
{
if (max_feedrate_normal[j] > NORMAL_MAX_FEEDRATE_XY)
max_feedrate_normal[j] = NORMAL_MAX_FEEDRATE_XY;
if (max_feedrate_silent[j] > SILENT_MAX_FEEDRATE_XY)
max_feedrate_silent[j] = SILENT_MAX_FEEDRATE_XY;
if (max_acceleration_units_per_sq_second_normal[j] > NORMAL_MAX_ACCEL_XY)
max_acceleration_units_per_sq_second_normal[j] = NORMAL_MAX_ACCEL_XY;
if (max_acceleration_units_per_sq_second_silent[j] > SILENT_MAX_ACCEL_XY)
max_acceleration_units_per_sq_second_silent[j] = SILENT_MAX_ACCEL_XY;
if (cs.max_feedrate_normal[j] > NORMAL_MAX_FEEDRATE_XY)
cs.max_feedrate_normal[j] = NORMAL_MAX_FEEDRATE_XY;
if (cs.max_feedrate_silent[j] > SILENT_MAX_FEEDRATE_XY)
cs.max_feedrate_silent[j] = SILENT_MAX_FEEDRATE_XY;
if (cs.max_acceleration_units_per_sq_second_normal[j] > NORMAL_MAX_ACCEL_XY)
cs.max_acceleration_units_per_sq_second_normal[j] = NORMAL_MAX_ACCEL_XY;
if (cs.max_acceleration_units_per_sq_second_silent[j] > SILENT_MAX_ACCEL_XY)
cs.max_acceleration_units_per_sq_second_silent[j] = SILENT_MAX_ACCEL_XY;
}
#endif //TMC2130
@ -354,27 +280,18 @@ bool Config_RetrieveSettings(uint16_t offset)
// Call updatePID (similar to when we have processed M301)
updatePID();
if (EEPROM_M500_SIZE + EEPROM_OFFSET == i) {
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Stored settings retrieved");
}
else { //size of eeprom M500 section probably changed by mistake and data are not valid; default values will be used
puts_P(PSTR("Data read from EEPROM not valid."));
Config_ResetDefault();
previous_settings_retrieved = false;
}
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Stored settings retrieved");
}
else
{
Config_ResetDefault();
//Return false to inform user that eeprom version was changed and firmware is using default hardcoded settings now.
//In case that storing to eeprom was not used yet, do not inform user that hardcoded settings are used.
if (eeprom_read_byte((uint8_t *)offset) != 0xFF ||
eeprom_read_byte((uint8_t *)offset + 1) != 0xFF ||
eeprom_read_byte((uint8_t *)offset + 2) != 0xFF) {
if (eeprom_read_byte(reinterpret_cast<uint8_t*>(&(EEPROM_M500_base->version[0]))) != 0xFF ||
eeprom_read_byte(reinterpret_cast<uint8_t*>(&(EEPROM_M500_base->version[1]))) != 0xFF ||
eeprom_read_byte(reinterpret_cast<uint8_t*>(&(EEPROM_M500_base->version[2]))) != 0xFF)
{
previous_settings_retrieved = false;
}
}
@ -387,73 +304,18 @@ bool Config_RetrieveSettings(uint16_t offset)
void Config_ResetDefault()
{
float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
float tmp2[]=DEFAULT_MAX_FEEDRATE;
long tmp3[]=DEFAULT_MAX_ACCELERATION;
float tmp4[]=DEFAULT_MAX_FEEDRATE_SILENT;
long tmp5[]=DEFAULT_MAX_ACCELERATION_SILENT;
for (short i=0;i<4;i++)
{
axis_steps_per_unit[i]=tmp1[i];
max_feedrate_normal[i]=tmp2[i];
max_acceleration_units_per_sq_second_normal[i]=tmp3[i];
max_feedrate_silent[i]=tmp4[i];
max_acceleration_units_per_sq_second_silent[i]=tmp5[i];
}
memcpy_P(&cs,&default_conf, sizeof(cs));
// steps per sq second need to be updated to agree with the units per sq second
reset_acceleration_rates();
acceleration=DEFAULT_ACCELERATION;
retract_acceleration=DEFAULT_RETRACT_ACCELERATION;
minimumfeedrate=DEFAULT_MINIMUMFEEDRATE;
minsegmenttime=DEFAULT_MINSEGMENTTIME;
mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE;
max_jerk[X_AXIS] = DEFAULT_XJERK;
max_jerk[Y_AXIS] = DEFAULT_YJERK;
max_jerk[Z_AXIS] = DEFAULT_ZJERK;
max_jerk[E_AXIS] = DEFAULT_EJERK;
add_homing[X_AXIS] = add_homing[Y_AXIS] = add_homing[Z_AXIS] = 0;
#ifdef ENABLE_AUTO_BED_LEVELING
zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
#endif
#ifdef PIDTEMP
Kp = DEFAULT_Kp;
Ki = scalePID_i(DEFAULT_Ki);
Kd = scalePID_d(DEFAULT_Kd);
// call updatePID (similar to when we have processed M301)
updatePID();
#ifdef PID_ADD_EXTRUSION_RATE
Kc = DEFAULT_Kc;
Kc = DEFAULT_Kc; //this is not stored by Config_StoreSettings
#endif//PID_ADD_EXTRUSION_RATE
#endif//PIDTEMP
#ifdef FWRETRACT
autoretract_enabled = false;
retract_length = RETRACT_LENGTH;
#if EXTRUDERS > 1
retract_length_swap = RETRACT_LENGTH_SWAP;
#endif
retract_feedrate = RETRACT_FEEDRATE;
retract_zlift = RETRACT_ZLIFT;
retract_recover_length = RETRACT_RECOVER_LENGTH;
#if EXTRUDERS > 1
retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
#endif
retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
#endif
volumetric_enabled = false;
filament_size[0] = DEFAULT_NOMINAL_FILAMENT_DIA;
#if EXTRUDERS > 1
filament_size[1] = DEFAULT_NOMINAL_FILAMENT_DIA;
#if EXTRUDERS > 2
filament_size[2] = DEFAULT_NOMINAL_FILAMENT_DIA;
#endif
#endif
calculate_extruder_multipliers();
SERIAL_ECHO_START;

View file

@ -3,6 +3,43 @@
#define EEPROM_SETTINGS
#include "Configuration.h"
#include <stdint.h>
#include <avr/eeprom.h>
typedef struct
{
char version[4];
float axis_steps_per_unit[4];
float max_feedrate_normal[4];
unsigned long max_acceleration_units_per_sq_second_normal[4];
float acceleration; //!< Normal acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
float retract_acceleration; //!< mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX
float minimumfeedrate;
float mintravelfeedrate;
unsigned long minsegmenttime;
float max_jerk[4]; //!< Jerk is a maximum immediate velocity change.
float add_homing[3];
float zprobe_zoffset;
float Kp;
float Ki;
float Kd;
float bedKp;
float bedKi;
float bedKd;
int lcd_contrast; //!< unused
bool autoretract_enabled;
float retract_length;
float retract_feedrate;
float retract_zlift;
float retract_recover_length;
float retract_recover_feedrate;
bool volumetric_enabled;
float filament_size[1]; //!< cross-sectional area of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder.
float max_feedrate_silent[4]; //!< max speeds for silent mode
unsigned long max_acceleration_units_per_sq_second_silent[4];
} M500_conf;
extern M500_conf cs;
void Config_ResetDefault();
@ -13,8 +50,8 @@ FORCE_INLINE void Config_PrintSettings() {}
#endif
#ifdef EEPROM_SETTINGS
void Config_StoreSettings(uint16_t offset);
bool Config_RetrieveSettings(uint16_t offset);
void Config_StoreSettings();
bool Config_RetrieveSettings();
#else
FORCE_INLINE void Config_StoreSettings() {}
FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }

View file

@ -34,7 +34,6 @@ void print_eeprom(uint16_t address, uint16_t count, uint8_t countperline = 16)
uint8_t count_line = countperline;
while (count && count_line)
{
uint8_t data = 0;
putchar(' ');
print_hex_byte(eeprom_read_byte((uint8_t*)address++));
count_line--;
@ -115,7 +114,7 @@ void dcode_3()
count = parse_hex(strchr_pointer + 1, data, 16);
if (count > 0)
{
for (int i = 0; i < count; i++)
for (uint16_t i = 0; i < count; i++)
eeprom_write_byte((uint8_t*)(address + i), data[i]);
printf_P(_N("%d bytes written to EEPROM at address 0x%04x"), count, address);
putchar('\n');

View file

@ -148,7 +148,7 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#else
#define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
#define disable_z() ;
#define disable_z() {}
#endif
#else
#ifdef Z_DUAL_STEPPER_DRIVERS
@ -160,8 +160,8 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#endif
#endif
#else
#define enable_z() ;
#define disable_z() ;
#define enable_z() {}
#define disable_z() {}
#endif
@ -269,19 +269,16 @@ extern float homing_feedrate[];
extern bool axis_relative_modes[];
extern int feedmultiply;
extern int extrudemultiply; // Sets extrude multiply factor (in percent) for all extruders
extern bool volumetric_enabled;
extern int extruder_multiply[EXTRUDERS]; // sets extrude multiply factor (in percent) for each extruder individually
extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder.
extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
extern float current_position[NUM_AXIS] ;
extern float destination[NUM_AXIS] ;
extern float add_homing[3];
extern float min_pos[3];
extern float max_pos[3];
extern bool axis_known_position[3];
extern float zprobe_zoffset;
extern int fanSpeed;
extern void homeaxis(int axis, uint8_t cnt = 1, uint8_t* pstep = 0);
extern int8_t lcd_change_fil_state;
#ifdef FAN_SOFT_PWM
@ -289,10 +286,9 @@ extern unsigned char fanSpeedSoftPwm;
#endif
#ifdef FWRETRACT
extern bool autoretract_enabled;
extern bool retracted[EXTRUDERS];
extern float retract_length, retract_length_swap, retract_feedrate, retract_zlift;
extern float retract_recover_length, retract_recover_length_swap, retract_recover_feedrate;
extern float retract_length_swap;
extern float retract_recover_length_swap;
#endif
#ifdef HOST_KEEPALIVE_FEATURE
@ -333,10 +329,6 @@ extern uint8_t active_extruder;
#endif
//Long pause
extern int saved_feedmultiply;
extern float HotendTempBckp;
extern int fanSpeedBckp;
extern float pause_lastpos[4];
extern unsigned long pause_time;
extern unsigned long start_pause_print;
extern unsigned long t_fan_rising_edge;
@ -360,12 +352,14 @@ extern uint8_t print_percent_done_normal;
extern uint16_t print_time_remaining_normal;
extern uint8_t print_percent_done_silent;
extern uint16_t print_time_remaining_silent;
#define PRINT_TIME_REMAINING_INIT 0xffff
extern uint16_t mcode_in_progress;
extern uint16_t gcode_in_progress;
extern bool wizard_active; //autoload temporarily disabled during wizard
#define PRINT_TIME_REMAINING_INIT 0xffff
#define PRINT_PERCENT_DONE_INIT 0xff
#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CUSTOM_MSG_TYPE_TEMCAL) || saved_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL) || card.paused || mmu_print_saved)
@ -378,6 +372,7 @@ extern void delay_keep_alive(unsigned int ms);
extern void check_babystep();
extern void long_pause();
extern void crashdet_stop_and_save_print();
#ifdef DIS
@ -390,7 +385,6 @@ float temp_comp_interpolation(float temperature);
void temp_compensation_apply();
void temp_compensation_start();
void show_fw_version_warnings();
void erase_eeprom_section(uint16_t offset, uint16_t bytes);
uint8_t check_printer_version();
#ifdef PINDA_THERMISTOR
@ -418,6 +412,9 @@ extern void print_world_coordinates();
extern void print_physical_coordinates();
extern void print_mesh_bed_leveling_table();
extern void stop_and_save_print_to_ram(float z_move, float e_move);
extern void restore_print_from_ram_and_continue(float e_move);
//estimated time to end of the print
extern uint16_t print_time_remaining();
@ -472,5 +469,5 @@ void proc_commands();
void M600_load_filament();
void M600_load_filament_movements();
void M600_wait_for_user();
void M600_wait_for_user(float HotendTempBckp);
void M600_check_state();

File diff suppressed because it is too large Load diff

View file

@ -288,6 +288,76 @@ void CardReader::getAbsFilename(char *t)
else
t[0]=0;
}
/**
* @brief Dive into subfolder
*
* Method sets curDir to point to root, in case fileName is null.
* Method sets curDir to point to workDir, in case fileName path is relative
* (doesn't start with '/')
* Method sets curDir to point to dir, which is specified by absolute path
* specified by fileName. In such case fileName is updated so it points to
* file name without the path.
*
* @param[in,out] fileName
* expects file name including path
* in case of absolute path, file name without path is returned
* @param[in,out] dir SdFile object to operate with,
* in case of absolute path, curDir is modified to point to dir,
* so it is not possible to create on stack inside this function,
* as curDir would point to destroyed object.
*/
void CardReader::diveSubfolder (const char *fileName, SdFile& dir)
{
curDir=&root;
if (!fileName) return;
const char *dirname_start, *dirname_end;
if (fileName[0] == '/') // absolute path
{
dirname_start = fileName + 1;
while (*dirname_start)
{
dirname_end = strchr(dirname_start, '/');
//SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
if (dirname_end && dirname_end > dirname_start)
{
const size_t maxLen = 12;
char subdirname[maxLen+1];
subdirname[maxLen] = 0;
const size_t len = ((static_cast<size_t>(dirname_end-dirname_start))>maxLen) ? maxLen : (dirname_end-dirname_start);
strncpy(subdirname, dirname_start, len);
SERIAL_ECHOLN(subdirname);
if (!dir.open(curDir, subdirname, O_READ))
{
SERIAL_PROTOCOLRPGM(_T(MSG_SD_OPEN_FILE_FAIL));
SERIAL_PROTOCOL(subdirname);
SERIAL_PROTOCOLLNPGM(".");
return;
}
else
{
//SERIAL_ECHOLN("dive ok");
}
curDir = &dir;
dirname_start = dirname_end + 1;
}
else // the reminder after all /fsa/fdsa/ is the filename
{
fileName = dirname_start;
//SERIAL_ECHOLN("remaider");
//SERIAL_ECHOLN(fname);
break;
}
}
}
else //relative path
{
curDir = &workDir;
}
}
void CardReader::openFile(const char* name,bool read, bool replace_current/*=true*/)
{
@ -340,53 +410,9 @@ void CardReader::openFile(const char* name,bool read, bool replace_current/*=tru
SdFile myDir;
curDir=&root;
const char *fname=name;
char *dirname_start,*dirname_end;
if(name[0]=='/')
{
dirname_start=strchr(name,'/')+1;
while(dirname_start>0)
{
dirname_end=strchr(dirname_start,'/');
//SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
if(dirname_end>0 && dirname_end>dirname_start)
{
char subdirname[13];
strncpy(subdirname, dirname_start, dirname_end-dirname_start);
subdirname[dirname_end-dirname_start]=0;
SERIAL_ECHOLN(subdirname);
if(!myDir.open(curDir,subdirname,O_READ))
{
SERIAL_PROTOCOLRPGM(_T(MSG_SD_OPEN_FILE_FAIL));
SERIAL_PROTOCOL(subdirname);
SERIAL_PROTOCOLLNPGM(".");
return;
}
else
{
//SERIAL_ECHOLN("dive ok");
}
curDir=&myDir;
dirname_start=dirname_end+1;
}
else // the reminder after all /fsa/fdsa/ is the filename
{
fname=dirname_start;
//SERIAL_ECHOLN("remaider");
//SERIAL_ECHOLN(fname);
break;
}
}
}
else //relative path
{
curDir=&workDir;
}
diveSubfolder(fname,myDir);
if(read)
{
if (file.open(curDir, fname, O_READ))
@ -431,60 +457,14 @@ void CardReader::openFile(const char* name,bool read, bool replace_current/*=tru
void CardReader::removeFile(const char* name)
{
if(!cardOK)
return;
file.close();
sdprinting = false;
SdFile myDir;
curDir=&root;
const char *fname=name;
char *dirname_start,*dirname_end;
if(name[0]=='/')
{
dirname_start=strchr(name,'/')+1;
while(dirname_start>0)
{
dirname_end=strchr(dirname_start,'/');
//SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
if(dirname_end>0 && dirname_end>dirname_start)
{
char subdirname[13];
strncpy(subdirname, dirname_start, dirname_end-dirname_start);
subdirname[dirname_end-dirname_start]=0;
SERIAL_ECHOLN(subdirname);
if(!myDir.open(curDir,subdirname,O_READ))
{
SERIAL_PROTOCOLRPGM("open failed, File: ");
SERIAL_PROTOCOL(subdirname);
SERIAL_PROTOCOLLNPGM(".");
return;
}
else
{
//SERIAL_ECHOLN("dive ok");
}
curDir=&myDir;
dirname_start=dirname_end+1;
}
else // the reminder after all /fsa/fdsa/ is the filename
{
fname=dirname_start;
//SERIAL_ECHOLN("remaider");
//SERIAL_ECHOLN(fname);
break;
}
}
}
else //relative path
{
curDir=&workDir;
}
if(!cardOK) return;
file.close();
sdprinting = false;
SdFile myDir;
const char *fname=name;
diveSubfolder(fname,myDir);
if (file.remove(curDir, fname))
{
SERIAL_PROTOCOLPGM("File deleted:");

View file

@ -154,6 +154,8 @@ private:
LsAction lsAction; //stored for recursion.
int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
char* diveDirName;
void diveSubfolder (const char *fileName, SdFile& dir);
void lsDive(const char *prepend, SdFile parent, const char * const match=NULL);
#ifdef SDCARD_SORT_ALPHA
void flush_presort();

View file

@ -453,7 +453,7 @@ EXTRACT_PACKAGE = NO
# included in the documentation.
# The default value is: NO.
EXTRACT_STATIC = NO
EXTRACT_STATIC = YES
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
# locally in source files will be included in the documentation. If set to NO,
@ -2421,7 +2421,7 @@ DIAFILE_DIRS =
# generate a warning when it encounters a \startuml command in this case and
# will not generate output for the diagram.
PLANTUML_JAR_PATH =
PLANTUML_JAR_PATH = /usr/share/plantuml/
# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
# configuration file for plantuml.

View file

@ -184,7 +184,10 @@
// Magic string, indicating that the current or the previous firmware running was the Prusa3D firmware.
#define EEPROM_FIRMWARE_PRUSA_MAGIC 0
#define EEPROM_OFFSET 20 //offset for storing settings using M500
#define EEPROM_M500_SIZE 188 //size of M500 eeprom section in bytes; if EEPROM_M500_SIZE increases it is necessary to update also EEPROM_VERSION
#ifdef __cplusplus
#include "ConfigurationStore.h"
static M500_conf * const EEPROM_M500_base = reinterpret_cast<M500_conf*>(20); //offset for storing settings using M500
#endif
#endif // EEPROM_H

View file

@ -1,3 +1,5 @@
//! @file
#include "Marlin.h"
#include "fsensor.h"
@ -7,61 +9,79 @@
#include "planner.h"
#include "fastio.h"
#include "cmdqueue.h"
#include "ultralcd.h"
#include "ConfigurationStore.h"
//Basic params
#define FSENSOR_CHUNK_LEN 0.64F //filament sensor chunk length 0.64mm
#define FSENSOR_ERR_MAX 17 //filament sensor maximum error count for runout detection
//Optical quality meassurement params
#define FSENSOR_OQ_MAX_ES 6 //maximum error sum while loading (length ~64mm = 100chunks)
#define FSENSOR_OQ_MAX_EM 2 //maximum error counter value while loading
#define FSENSOR_OQ_MIN_YD 2 //minimum yd per chunk (applied to avg value)
#define FSENSOR_OQ_MAX_YD 200 //maximum yd per chunk (applied to avg value)
#define FSENSOR_OQ_MAX_PD 4 //maximum positive deviation (= yd_max/yd_avg)
#define FSENSOR_OQ_MAX_ND 5 //maximum negative deviation (= yd_avg/yd_min)
#define FSENSOR_OQ_MAX_SH 13 //maximum shutter value
//! @name Basic parameters
//! @{
#define FSENSOR_CHUNK_LEN 0.64F //!< filament sensor chunk length 0.64mm
#define FSENSOR_ERR_MAX 17 //!< filament sensor maximum error count for runout detection
//! @}
//! @name Optical quality measurement parameters
//! @{
#define FSENSOR_OQ_MAX_ES 6 //!< maximum error sum while loading (length ~64mm = 100chunks)
#define FSENSOR_OQ_MAX_EM 2 //!< maximum error counter value while loading
#define FSENSOR_OQ_MIN_YD 2 //!< minimum yd per chunk (applied to avg value)
#define FSENSOR_OQ_MAX_YD 200 //!< maximum yd per chunk (applied to avg value)
#define FSENSOR_OQ_MAX_PD 4 //!< maximum positive deviation (= yd_max/yd_avg)
#define FSENSOR_OQ_MAX_ND 5 //!< maximum negative deviation (= yd_avg/yd_min)
#define FSENSOR_OQ_MAX_SH 13 //!< maximum shutter value
//! @}
const char ERRMSG_PAT9125_NOT_RESP[] PROGMEM = "PAT9125 not responding (%d)!\n";
#define FSENSOR_INT_PIN 63 //filament sensor interrupt pin PK1
#define FSENSOR_INT_PIN_MSK 0x02 //filament sensor interrupt pin mask (bit1)
#define FSENSOR_INT_PIN 63 //!< filament sensor interrupt pin PK1
#define FSENSOR_INT_PIN_MSK 0x02 //!< filament sensor interrupt pin mask (bit1)
extern void stop_and_save_print_to_ram(float z_move, float e_move);
extern void restore_print_from_ram_and_continue(float e_move);
extern int8_t FSensorStateMenu;
void fsensor_stop_and_save_print(void)
{
printf_P(PSTR("fsensor_stop_and_save_print\n"));
stop_and_save_print_to_ram(0, 0); //XYZE - no change
}
void fsensor_restore_print_and_continue(void)
{
printf_P(PSTR("fsensor_restore_print_and_continue\n"));
restore_print_from_ram_and_continue(0); //XYZ = orig, E - no change
}
//uint8_t fsensor_int_pin = FSENSOR_INT_PIN;
uint8_t fsensor_int_pin_old = 0;
int16_t fsensor_chunk_len = 0;
//enabled = initialized and sampled every chunk event
//! enabled = initialized and sampled every chunk event
bool fsensor_enabled = true;
//runout watching is done in fsensor_update (called from main loop)
//! runout watching is done in fsensor_update (called from main loop)
bool fsensor_watch_runout = true;
//not responding - is set if any communication error occured durring initialization or readout
//! not responding - is set if any communication error occurred during initialization or readout
bool fsensor_not_responding = false;
//enable/disable quality meassurement
//! printing saved
bool fsensor_printing_saved = false;
//! enable/disable quality meassurement
bool fsensor_oq_meassure_enabled = false;
//number of errors, updated in ISR
//! number of errors, updated in ISR
uint8_t fsensor_err_cnt = 0;
//variable for accumolating step count (updated callbacks from stepper and ISR)
//! variable for accumulating step count (updated callbacks from stepper and ISR)
int16_t fsensor_st_cnt = 0;
//last dy value from pat9125 sensor (used in ISR)
//! last dy value from pat9125 sensor (used in ISR)
int16_t fsensor_dy_old = 0;
//log flag: 0=log disabled, 1=log enabled
//! log flag: 0=log disabled, 1=log enabled
uint8_t fsensor_log = 1;
////////////////////////////////////////////////////////////////////////////////
//filament autoload variables
//autoload feature enabled
//! @name filament autoload variables
//! @{
//! autoload feature enabled
bool fsensor_autoload_enabled = true;
//autoload watching enable/disable flag
//! autoload watching enable/disable flag
bool fsensor_watch_autoload = false;
//
uint16_t fsensor_autoload_y;
@ -71,30 +91,33 @@ uint8_t fsensor_autoload_c;
uint32_t fsensor_autoload_last_millis;
//
uint8_t fsensor_autoload_sum;
//! @}
////////////////////////////////////////////////////////////////////////////////
//filament optical quality meassurement variables
//meassurement enable/disable flag
//! @name filament optical quality measurement variables
//! @{
//! Measurement enable/disable flag
bool fsensor_oq_meassure = false;
//skip-chunk counter, for accurate meassurement is necesary to skip first chunk...
//! skip-chunk counter, for accurate measurement is necessary to skip first chunk...
uint8_t fsensor_oq_skipchunk;
//number of samples from start of meassurement
//! number of samples from start of measurement
uint8_t fsensor_oq_samples;
//sum of steps in positive direction movements
//! sum of steps in positive direction movements
uint16_t fsensor_oq_st_sum;
//sum of deltas in positive direction movements
//! sum of deltas in positive direction movements
uint16_t fsensor_oq_yd_sum;
//sum of errors durring meassurement
//! sum of errors during measurement
uint16_t fsensor_oq_er_sum;
//max error counter value durring meassurement
//! max error counter value during measurement
uint8_t fsensor_oq_er_max;
//minimum delta value
uint16_t fsensor_oq_yd_min;
//maximum delta value
uint16_t fsensor_oq_yd_max;
//sum of shutter value
//! minimum delta value
int16_t fsensor_oq_yd_min;
//! maximum delta value
int16_t fsensor_oq_yd_max;
//! sum of shutter value
uint16_t fsensor_oq_sh_sum;
//! @}
void fsensor_stop_and_save_print(void)
{
@ -118,7 +141,7 @@ void fsensor_init(void)
fsensor_autoload_enabled=eeprom_read_byte((uint8_t*)EEPROM_FSENS_AUTOLOAD_ENABLED);
uint8_t oq_meassure_enabled = eeprom_read_byte((uint8_t*)EEPROM_FSENS_OQ_MEASS_ENABLED);
fsensor_oq_meassure_enabled = (oq_meassure_enabled == 1)?true:false;
fsensor_chunk_len = (int16_t)(FSENSOR_CHUNK_LEN * axis_steps_per_unit[E_AXIS]);
fsensor_chunk_len = (int16_t)(FSENSOR_CHUNK_LEN * cs.axis_steps_per_unit[E_AXIS]);
if (!pat9125)
{
@ -222,7 +245,9 @@ bool fsensor_check_autoload(void)
fsensor_autoload_check_start();
return false;
}
#if 0
uint8_t fsensor_autoload_c_old = fsensor_autoload_c;
#endif
if ((millis() - fsensor_autoload_last_millis) < 25) return false;
fsensor_autoload_last_millis = millis();
if (!pat9125_update_y()) //update sensor
@ -247,9 +272,11 @@ bool fsensor_check_autoload(void)
else if (fsensor_autoload_c > 0)
fsensor_autoload_c--;
if (fsensor_autoload_c == 0) fsensor_autoload_sum = 0;
// puts_P(_N("fsensor_check_autoload\n"));
// if (fsensor_autoload_c != fsensor_autoload_c_old)
// printf_P(PSTR("fsensor_check_autoload dy=%d c=%d sum=%d\n"), dy, fsensor_autoload_c, fsensor_autoload_sum);
#if 0
puts_P(_N("fsensor_check_autoload\n"));
if (fsensor_autoload_c != fsensor_autoload_c_old)
printf_P(PSTR("fsensor_check_autoload dy=%d c=%d sum=%d\n"), dy, fsensor_autoload_c, fsensor_autoload_sum);
#endif
// if ((fsensor_autoload_c >= 15) && (fsensor_autoload_sum > 30))
if ((fsensor_autoload_c >= 12) && (fsensor_autoload_sum > 20))
{
@ -440,6 +467,11 @@ void fsensor_st_block_chunk(block_t* bl, int cnt)
}
}
//! @brief filament sensor update (perform M600 on filament runout)
//!
//! Works only if filament sensor is enabled.
//! When the filament sensor error count is larger then FSENSOR_ERR_MAX, pauses print, tries to move filament back and forth.
//! If there is still no plausible signal from filament sensor plans M600 (Filament change).
void fsensor_update(void)
{
if (fsensor_enabled && fsensor_watch_runout && (fsensor_err_cnt > FSENSOR_ERR_MAX))
@ -454,24 +486,11 @@ void fsensor_update(void)
fsensor_err_cnt = 0;
fsensor_oq_meassure_start(0);
// st_synchronize();
// for (int axis = X_AXIS; axis <= E_AXIS; axis++)
// current_position[axis] = st_get_position_mm(axis);
/*
current_position[E_AXIS] -= 3;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 200 / 60, active_extruder);
st_synchronize();
current_position[E_AXIS] += 3;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 200 / 60, active_extruder);
st_synchronize();
*/
enquecommand_front_P((PSTR("G1 E-3 F200")));
process_commands();
KEEPALIVE_STATE(IN_HANDLER);
cmdqueue_pop_front();
st_synchronize();
enquecommand_front_P((PSTR("G1 E-3 F200")));
process_commands();
KEEPALIVE_STATE(IN_HANDLER);
cmdqueue_pop_front();
st_synchronize();
enquecommand_front_P((PSTR("G1 E3 F200")));
process_commands();

View file

@ -1,55 +1,65 @@
//! @file
#ifndef FSENSOR_H
#define FSENSOR_H
#include <inttypes.h>
//minimum meassured chunk length in steps
//! minimum meassured chunk length in steps
extern int16_t fsensor_chunk_len;
//enable/disable flag
// enable/disable flag
extern bool fsensor_enabled;
//not responding flag
// not responding flag
extern bool fsensor_not_responding;
//enable/disable quality meassurement
extern bool fsensor_oq_meassure_enabled;
//save restore printing
//! @name save restore printing
//! @{
extern void fsensor_stop_and_save_print(void);
extern void fsensor_restore_print_and_continue(void);
//! @}
//initialize
//! initialize
extern void fsensor_init(void);
//enable/disable
//! @name enable/disable
//! @{
extern bool fsensor_enable(void);
extern void fsensor_disable(void);
//! @}
//autoload feature enabled
extern bool fsensor_autoload_enabled;
extern void fsensor_autoload_set(bool State);
//update (perform M600 on filament runout)
extern void fsensor_update(void);
//setup pin-change interrupt
//! setup pin-change interrupt
extern void fsensor_setup_interrupt(void);
//autoload support
//! @name autoload support
//! @{
extern void fsensor_autoload_check_start(void);
extern void fsensor_autoload_check_stop(void);
extern bool fsensor_check_autoload(void);
//! @}
//optical quality meassurement support
//! @name optical quality measurement support
//! @{
extern void fsensor_oq_meassure_set(bool State);
extern void fsensor_oq_meassure_start(uint8_t skip);
extern void fsensor_oq_meassure_stop(void);
extern bool fsensor_oq_result(void);
//! @}
//callbacks from stepper
#include "planner.h"
//! @name callbacks from stepper
//! @{
extern void fsensor_st_block_begin(block_t* bl);
extern void fsensor_st_block_chunk(block_t* bl, int cnt);
//! @}
#endif //FSENSOR_H

View file

@ -56,7 +56,7 @@
#define LCD_5x8DOTS 0x00
FILE _lcdout = {0};
FILE _lcdout; // = {0}; Global variable is always zero initialized, no need to explicitly state that.
uint8_t lcd_rs_pin; // LOW: command. HIGH: character.
@ -157,7 +157,7 @@ uint8_t lcd_write(uint8_t value)
return 1; // assume sucess
}
void lcd_begin(uint8_t cols, uint8_t lines, uint8_t dotsize, uint8_t clear)
static void lcd_begin(uint8_t lines, uint8_t dotsize, uint8_t clear)
{
if (lines > 1) lcd_displayfunction |= LCD_2LINE;
lcd_numlines = lines;
@ -221,7 +221,7 @@ void lcd_begin(uint8_t cols, uint8_t lines, uint8_t dotsize, uint8_t clear)
lcd_escape[0] = 0;
}
int lcd_putchar(char c, FILE *stream)
int lcd_putchar(char c, FILE *)
{
lcd_write(c);
return 0;
@ -247,20 +247,20 @@ void lcd_init(void)
pinMode(lcd_enable_pin, OUTPUT);
if (fourbitmode) lcd_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
else lcd_displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS;
lcd_begin(LCD_WIDTH, LCD_HEIGHT, LCD_5x8DOTS, 1);
lcd_begin(LCD_HEIGHT, LCD_5x8DOTS, 1);
//lcd_clear();
fdev_setup_stream(lcdout, lcd_putchar, NULL, _FDEV_SETUP_WRITE); //setup lcdout stream
}
void lcd_refresh(void)
{
lcd_begin(LCD_WIDTH, LCD_HEIGHT, LCD_5x8DOTS, 1);
lcd_begin(LCD_HEIGHT, LCD_5x8DOTS, 1);
lcd_set_custom_characters();
}
void lcd_refresh_noclear(void)
{
lcd_begin(LCD_WIDTH, LCD_HEIGHT, LCD_5x8DOTS, 0);
lcd_begin(LCD_HEIGHT, LCD_5x8DOTS, 0);
lcd_set_custom_characters();
}
@ -506,7 +506,6 @@ uint8_t lcd_escape_write(uint8_t chr)
break;
}
escape_cnt = 0; // reset escape
end:
return 1; // assume sucess
}
@ -684,10 +683,22 @@ ShortTimer longPressTimer;
LongTimer lcd_timeoutToStatus;
//! @brief Was button clicked?
//!
//! Consume click event, following call would return 0.
//! See #LCD_CLICKED macro for version not consuming the event.
//!
//! Generally is used in modal dialogs.
//!
//! @retval 0 not clicked
//! @retval nonzero clicked
uint8_t lcd_clicked(void)
{
bool clicked = LCD_CLICKED;
if(clicked) lcd_button_pressed = 0;
if(clicked)
{
lcd_consume_click();
}
return clicked;
}
@ -695,7 +706,7 @@ void lcd_beeper_quick_feedback(void)
{
SET_OUTPUT(BEEPER);
//-//
Sound_MakeSound(e_SOUND_CLASS_Echo,e_SOUND_TYPE_ButtonEcho);
Sound_MakeSound(e_SOUND_TYPE_ButtonEcho);
/*
for(int8_t i = 0; i < 10; i++)
{
@ -710,7 +721,7 @@ Sound_MakeSound(e_SOUND_CLASS_Echo,e_SOUND_TYPE_ButtonEcho);
void lcd_quick_feedback(void)
{
lcd_draw_update = 2;
lcd_button_pressed = false;
lcd_button_pressed = false;
lcd_beeper_quick_feedback();
}
@ -727,7 +738,6 @@ void lcd_update(uint8_t lcdDrawUpdateOverride)
lcd_draw_update = lcdDrawUpdateOverride;
if (!lcd_update_enabled)
return;
lcd_buttons_update();
if (lcd_lcdupdate_func)
lcd_lcdupdate_func();
}
@ -761,57 +771,45 @@ void lcd_update_enable(uint8_t enabled)
extern LongTimer safetyTimer;
void lcd_buttons_update(void)
{
static bool _lock = false;
if (_lock) return;
_lock = true;
uint8_t newbutton = 0;
if (READ(BTN_EN1) == 0) newbutton |= EN_A;
if (READ(BTN_EN2) == 0) newbutton |= EN_B;
if (lcd_update_enabled)
{ //if we are in non-modal mode, long press can be used and short press triggers with button release
if (READ(BTN_ENC) == 0)
{ //button is pressed
lcd_timeoutToStatus.start();
if (!buttonBlanking.running() || buttonBlanking.expired(BUTTON_BLANKING_TIME)) {
buttonBlanking.start();
safetyTimer.start();
if ((lcd_button_pressed == 0) && (lcd_long_press_active == 0))
{
longPressTimer.start();
lcd_button_pressed = 1;
}
else
{
if (longPressTimer.expired(LONG_PRESS_TIME))
{
lcd_long_press_active = 1;
if (lcd_longpress_func)
lcd_longpress_func();
}
}
}
}
else
{ //button not pressed
if (lcd_button_pressed)
{ //button was released
buttonBlanking.start();
if (lcd_long_press_active == 0)
{ //button released before long press gets activated
newbutton |= EN_C;
}
//else if (menu_menu == lcd_move_z) lcd_quick_feedback();
//lcd_button_pressed is set back to false via lcd_quick_feedback function
}
else
lcd_long_press_active = 0;
}
}
else
{ //we are in modal mode
if (READ(BTN_ENC) == 0)
newbutton |= EN_C;
}
if (READ(BTN_ENC) == 0)
{ //button is pressed
lcd_timeoutToStatus.start();
if (!buttonBlanking.running() || buttonBlanking.expired(BUTTON_BLANKING_TIME)) {
buttonBlanking.start();
safetyTimer.start();
if ((lcd_button_pressed == 0) && (lcd_long_press_active == 0))
{
//long press is not possible in modal mode
if (lcd_update_enabled) longPressTimer.start();
lcd_button_pressed = 1;
}
else if (longPressTimer.expired(LONG_PRESS_TIME))
{
lcd_long_press_active = 1;
if (lcd_longpress_func)
lcd_longpress_func();
}
}
}
else
{ //button not pressed
if (lcd_button_pressed)
{ //button was released
buttonBlanking.start();
if (lcd_long_press_active == 0)
{ //button released before long press gets activated
newbutton |= EN_C;
}
//else if (menu_menu == lcd_move_z) lcd_quick_feedback();
//lcd_button_pressed is set back to false via lcd_quick_feedback function
}
else
lcd_long_press_active = 0;
}
lcd_buttons = newbutton;
//manage encoder rotation
@ -849,7 +847,6 @@ void lcd_buttons_update(void)
}
}
lcd_encoder_bits = enc;
_lock = false;
}

View file

@ -1,4 +1,4 @@
//lcd.h
//! @file
#ifndef _LCD_H
#define _LCD_H
@ -131,7 +131,6 @@ extern lcd_lcdupdate_func_t lcd_lcdupdate_func;
extern uint8_t lcd_clicked(void);
extern void lcd_beeper_quick_feedback(void);
//Cause an LCD refresh, and give the user visual or audible feedback that something has happened
@ -150,6 +149,29 @@ extern void lcd_update_enable(uint8_t enabled);
extern void lcd_buttons_update(void);
//! @brief Helper class to temporarily disable LCD updates
//!
//! When constructed (on stack), original state state of lcd_update_enabled is stored
//! and LCD updates are disabled.
//! When destroyed (gone out of scope), original state of LCD update is restored.
//! It has zero overhead compared to storing bool saved = lcd_update_enabled
//! and calling lcd_update_enable(false) and lcd_update_enable(saved).
class LcdUpdateDisabler
{
public:
LcdUpdateDisabler(): m_updateEnabled(lcd_update_enabled)
{
lcd_update_enable(false);
}
~LcdUpdateDisabler()
{
lcd_update_enable(m_updateEnabled);
}
private:
bool m_updateEnabled;
};
@ -187,7 +209,16 @@ extern void lcd_buttons_update(void);
#define EN_A (1<<BLEN_A)
#define BLEN_C 2
#define EN_C (1<<BLEN_C)
//! @brief Was button clicked?
//!
//! Doesn't consume button click event. See lcd_clicked()
//! for function consuming the event.
//!
//! Generally is used in non-modal menus.
//!
//! @retval 0 button was not clicked
//! @retval 1 button was clicked
#define LCD_CLICKED (lcd_buttons&EN_C)
////////////////////////
@ -221,6 +252,12 @@ extern void lcd_set_custom_characters_progress(void);
extern void lcd_set_custom_characters_nextpage(void);
extern void lcd_set_custom_characters_degree(void);
//! @brief Consume click event
inline void lcd_consume_click()
{
lcd_button_pressed = 0;
lcd_buttons &= 0xff^EN_C;
}
#endif //_LCD_H

View file

@ -237,6 +237,7 @@ uint8_t menu_item_function_P(const char* str, menu_func_t func)
if (menu_clicked && (lcd_encoder == menu_item))
{
menu_clicked = false;
lcd_consume_click();
lcd_update_enabled = 0;
if (func) func();
lcd_update_enabled = 1;

View file

@ -132,7 +132,7 @@ const float bed_ref_points[] PROGMEM = {
static inline float sqr(float x) { return x * x; }
#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*/)
{
return false;
}
@ -147,7 +147,7 @@ static inline bool point_on_1st_row(const uint8_t i)
// The first row of points may not be fully reachable
// and the y values may be shortened a bit by the bed carriage
// pulling the belt up.
static inline float point_weight_x(const uint8_t i, const uint8_t npts, const float &y)
static inline float point_weight_x(const uint8_t i, const float &y)
{
float w = 1.f;
if (point_on_1st_row(i)) {
@ -169,7 +169,7 @@ static inline float point_weight_x(const uint8_t i, const uint8_t npts, const fl
// The first row of points may not be fully reachable
// and the y values may be shortened a bit by the bed carriage
// pulling the belt up.
static inline float point_weight_y(const uint8_t i, const uint8_t npts, const float &y)
static inline float point_weight_y(const uint8_t i, const float &y)
{
float w = 1.f;
if (point_on_1st_row(i)) {
@ -209,7 +209,10 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
float *vec_x,
float *vec_y,
float *cntr,
int8_t verbosity_level
int8_t
#ifdef SUPPORT_VERBOSITY
verbosity_level
#endif //SUPPORT_VERBOSITY
)
{
float angleDiff;
@ -291,7 +294,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
(c == 0) ? 1.f :
((c == 2) ? (-s1 * measured_pts[2 * i]) :
(-c2 * measured_pts[2 * i + 1]));
float w = point_weight_x(i, npts, measured_pts[2 * i + 1]);
float w = point_weight_x(i, measured_pts[2 * i + 1]);
acc += a * b * w;
}
// Second for the residuum in the y axis.
@ -306,7 +309,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
(c == 1) ? 1.f :
((c == 2) ? ( c1 * measured_pts[2 * i]) :
(-s2 * measured_pts[2 * i + 1]));
float w = point_weight_y(i, npts, measured_pts[2 * i + 1]);
float w = point_weight_y(i, measured_pts[2 * i + 1]);
acc += a * b * w;
}
}
@ -322,7 +325,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
((r == 2) ? (-s1 * measured_pts[2 * i]) :
(-c2 * measured_pts[2 * i + 1])));
float fx = c1 * measured_pts[2 * i] - s2 * measured_pts[2 * i + 1] + cntr[0] - pgm_read_float(true_pts + i * 2);
float w = point_weight_x(i, npts, measured_pts[2 * i + 1]);
float w = point_weight_x(i, measured_pts[2 * i + 1]);
acc += j * fx * w;
}
{
@ -332,7 +335,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
((r == 2) ? ( c1 * measured_pts[2 * i]) :
(-s2 * measured_pts[2 * i + 1])));
float fy = s1 * measured_pts[2 * i] + c2 * measured_pts[2 * i + 1] + cntr[1] - pgm_read_float(true_pts + i * 2 + 1);
float w = point_weight_y(i, npts, measured_pts[2 * i + 1]);
float w = point_weight_y(i, measured_pts[2 * i + 1]);
acc += j * fy * w;
}
}
@ -453,7 +456,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
#ifdef SUPPORT_VERBOSITY
if(verbosity_level >= 20) SERIAL_ECHOPGM("Point on first row");
#endif // SUPPORT_VERBOSITY
float w = point_weight_y(i, npts, measured_pts[2 * i + 1]);
float w = point_weight_y(i, measured_pts[2 * i + 1]);
if (sqrt(errX) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_X ||
(w != 0.f && sqrt(errY) > BED_CALIBRATION_POINT_OFFSET_MAX_1ST_ROW_Y)) {
result = BED_SKEW_OFFSET_DETECTION_FITTING_FAILED;
@ -550,7 +553,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
for (int8_t i = 0; i < npts; ++ i) {
float x = vec_x[0] * measured_pts[i * 2] + vec_y[0] * measured_pts[i * 2 + 1];
float y = vec_x[1] * measured_pts[i * 2] + vec_y[1] * measured_pts[i * 2 + 1];
float w = point_weight_x(i, npts, y);
float w = point_weight_x(i, y);
cntr[0] += w * (pgm_read_float(true_pts + i * 2) - x);
wx += w;
#ifdef SUPPORT_VERBOSITY
@ -567,7 +570,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
MYSERIAL.print(wx);
}
#endif // SUPPORT_VERBOSITY
w = point_weight_y(i, npts, y);
w = point_weight_y(i, y);
cntr[1] += w * (pgm_read_float(true_pts + i * 2 + 1) - y);
wy += w;
#ifdef SUPPORT_VERBOSITY
@ -960,7 +963,11 @@ static inline void update_current_position_z()
}
// At the current position, find the Z stop.
inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int verbosity_level)
inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
#ifdef SUPPORT_VERBOSITY
verbosity_level
#endif //SUPPORT_VERBOSITY
)
{
#ifdef TMC2130
FORCE_HIGH_POWER_START;
@ -1047,7 +1054,11 @@ extern bool xyzcal_find_bed_induction_sensor_point_xy();
#endif //HEATBED_V2
#ifdef HEATBED_V2
inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
inline bool find_bed_induction_sensor_point_xy(int
#if !defined (NEW_XYZCAL) && defined (SUPPORT_VERBOSITY)
verbosity_level
#endif
)
{
#ifdef NEW_XYZCAL
return xyzcal_find_bed_induction_sensor_point_xy();
@ -3009,7 +3020,7 @@ void babystep_apply()
{
babystep_load();
#ifdef BABYSTEP_LOADZ_BY_PLANNER
shift_z(- float(babystepLoadZ) / float(axis_steps_per_unit[Z_AXIS]));
shift_z(- float(babystepLoadZ) / float(cs.axis_steps_per_unit[Z_AXIS]));
#else
babystepsTodoZadd(babystepLoadZ);
#endif /* BABYSTEP_LOADZ_BY_PLANNER */
@ -3018,7 +3029,7 @@ void babystep_apply()
void babystep_undo()
{
#ifdef BABYSTEP_LOADZ_BY_PLANNER
shift_z(float(babystepLoadZ) / float(axis_steps_per_unit[Z_AXIS]));
shift_z(float(babystepLoadZ) / float(cs.axis_steps_per_unit[Z_AXIS]));
#else
babystepsTodoZsubtract(babystepLoadZ);
#endif /* BABYSTEP_LOADZ_BY_PLANNER */

View file

@ -21,7 +21,7 @@ static inline bool vec_undef(const float v[2])
return vx[0] == 0x0FFFFFFFF || vx[1] == 0x0FFFFFFFF;
}
void mesh_bed_leveling::get_meas_xy(int ix, int iy, float &x, float &y, bool use_default)
void mesh_bed_leveling::get_meas_xy(int ix, int iy, float &x, float &y, bool /*use_default*/)
{
#if 0
float cntr[2] = {

View file

@ -29,12 +29,13 @@ bool mmu_enabled = false;
bool mmu_ready = false;
int8_t mmu_state = 0;
static int8_t mmu_state = 0;
uint8_t mmu_cmd = 0;
uint8_t mmu_extruder = 0;
//! This variable probably has no meaning and is planed to be removed
uint8_t tmp_extruder = 0;
int8_t mmu_finda = -1;
@ -494,15 +495,11 @@ void mmu_M600_wait_and_beep() {
void mmu_M600_load_filament(bool automatic)
{
//load filament for mmu v2
bool response = false;
bool yes = false;
tmp_extruder = mmu_extruder;
if (!automatic) {
#ifdef MMU_M600_SWITCH_EXTRUDER
yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false);
bool yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false);
if(yes) tmp_extruder = choose_extruder_menu();
else tmp_extruder = mmu_extruder;
#endif //MMU_M600_SWITCH_EXTRUDER
}
else {
@ -541,7 +538,11 @@ void extr_mov(float shift, float feed_rate)
}
void change_extr(int extr) { //switches multiplexer for extruders
void change_extr(int
#ifdef SNMM
extr
#endif //SNMM
) { //switches multiplexer for extruders
#ifdef SNMM
st_synchronize();
delay(100);
@ -1011,23 +1012,24 @@ void mmu_eject_filament(uint8_t filament, bool recover)
if (degHotend0() > EXTRUDE_MINTEMP)
{
st_synchronize();
lcd_update_enable(false);
lcd_clear();
lcd_set_cursor(0, 1); lcd_puts_P(_i("Ejecting filament"));
current_position[E_AXIS] -= 80;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
st_synchronize();
lcd_update_enable(true);
mmu_command(MMU_CMD_E0 + filament);
manage_response(false, false);
if (recover)
{
lcd_show_fullscreen_message_and_wait_P(_i("Please remove filament and then press the knob."));
mmu_command(MMU_CMD_R0);
manage_response(false, false);
}
LcdUpdateDisabler disableLcdUpdate;
lcd_clear();
lcd_set_cursor(0, 1); lcd_puts_P(_i("Ejecting filament"));
current_position[E_AXIS] -= 80;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
st_synchronize();
mmu_command(MMU_CMD_E0 + filament);
manage_response(false, false);
if (recover)
{
lcd_show_fullscreen_message_and_wait_P(_i("Please remove filament and then press the knob."));
mmu_command(MMU_CMD_R0);
manage_response(false, false);
}
}
}
else
{

View file

@ -5,8 +5,6 @@
extern bool mmu_enabled;
extern int8_t mmu_state;
extern uint8_t mmu_extruder;
extern uint8_t tmp_extruder;

View file

@ -272,7 +272,6 @@ void optiboot_w25x20cl_enter()
/* Read memory block mode, length is big endian. */
else if(ch == STK_READ_PAGE) {
uint32_t addr = (((uint32_t)rampz) << 16) | address;
uint8_t desttype;
register pagelen_t i;
// Read the page length, with the length transferred each nibble separately to work around
// the Prusa's USB to serial infamous semicolon issue.
@ -280,8 +279,8 @@ void optiboot_w25x20cl_enter()
length |= ((pagelen_t)getch()) << 8;
length |= getch();
length |= getch();
// Read the destination type. It should always be 'F' as flash.
desttype = getch();
// Read the destination type. It should always be 'F' as flash. It is not checked.
(void)getch();
verifySpace();
w25x20cl_wait_busy();
w25x20cl_rd_data(addr, buff, length);

View file

@ -57,6 +57,7 @@
#include "temperature.h"
#include "ultralcd.h"
#include "language.h"
#include "ConfigurationStore.h"
#ifdef MESH_BED_LEVELING
#include "mesh_bed_leveling.h"
@ -71,27 +72,12 @@
//=============================public variables ============================
//===========================================================================
unsigned long minsegmenttime;
// Use M203 to override by software
float max_feedrate_normal[NUM_AXIS]; // max speeds for normal mode
float max_feedrate_silent[NUM_AXIS]; // max speeds for silent mode
float* max_feedrate = max_feedrate_normal;
float* max_feedrate = cs.max_feedrate_normal;
// Use M92 to override by software
float axis_steps_per_unit[NUM_AXIS];
// Use M201 to override by software
unsigned long max_acceleration_units_per_sq_second_normal[NUM_AXIS];
unsigned long max_acceleration_units_per_sq_second_silent[NUM_AXIS];
unsigned long* max_acceleration_units_per_sq_second = max_acceleration_units_per_sq_second_normal;
float minimumfeedrate;
float acceleration; // Normal acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
float retract_acceleration; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX
// Jerk is a maximum immediate velocity change.
float max_jerk[NUM_AXIS];
float mintravelfeedrate;
unsigned long* max_acceleration_units_per_sq_second = cs.max_acceleration_units_per_sq_second_normal;
unsigned long axis_steps_per_sqr_second[NUM_AXIS];
#ifdef ENABLE_AUTO_BED_LEVELING
@ -623,9 +609,9 @@ void planner_abort_hard()
else {
float t = float(step_events_completed) / float(current_block->step_event_count);
float vec[3] = {
current_block->steps_x / axis_steps_per_unit[X_AXIS],
current_block->steps_y / axis_steps_per_unit[Y_AXIS],
current_block->steps_z / axis_steps_per_unit[Z_AXIS]
current_block->steps_x / cs.axis_steps_per_unit[X_AXIS],
current_block->steps_y / cs.axis_steps_per_unit[Y_AXIS],
current_block->steps_z / cs.axis_steps_per_unit[Z_AXIS]
};
float pos1[3], pos2[3];
for (int8_t i = 0; i < 3; ++ i) {
@ -743,18 +729,18 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
// Calculate target position in absolute steps
//this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow
long target[4];
target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]);
target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]);
target[X_AXIS] = lround(x*cs.axis_steps_per_unit[X_AXIS]);
target[Y_AXIS] = lround(y*cs.axis_steps_per_unit[Y_AXIS]);
#ifdef MESH_BED_LEVELING
if (mbl.active){
target[Z_AXIS] = lround((z+mbl.get_z(x, y))*axis_steps_per_unit[Z_AXIS]);
target[Z_AXIS] = lround((z+mbl.get_z(x, y))*cs.axis_steps_per_unit[Z_AXIS]);
}else{
target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
target[Z_AXIS] = lround(z*cs.axis_steps_per_unit[Z_AXIS]);
}
#else
target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
target[Z_AXIS] = lround(z*cs.axis_steps_per_unit[Z_AXIS]);
#endif // ENABLE_MESH_BED_LEVELING
target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
target[E_AXIS] = lround(e*cs.axis_steps_per_unit[E_AXIS]);
#ifdef LIN_ADVANCE
const float mm_D_float = sqrt(sq(x - position_float[X_AXIS]) + sq(y - position_float[Y_AXIS]));
@ -776,7 +762,7 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
}
#ifdef PREVENT_LENGTHY_EXTRUDE
if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH)
if(labs(target[E_AXIS]-position[E_AXIS])>cs.axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH)
{
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
#ifdef LIN_ADVANCE
@ -886,22 +872,22 @@ block->steps_y.wide = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-p
enable_e0();
g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE*2;
if(g_uc_extruder_last_move[1] == 0) disable_e1();
if(g_uc_extruder_last_move[2] == 0) disable_e2();
if(g_uc_extruder_last_move[1] == 0) {disable_e1();}
if(g_uc_extruder_last_move[2] == 0) {disable_e2();}
break;
case 1:
enable_e1();
g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2;
if(g_uc_extruder_last_move[0] == 0) disable_e0();
if(g_uc_extruder_last_move[2] == 0) disable_e2();
if(g_uc_extruder_last_move[0] == 0) {disable_e0();}
if(g_uc_extruder_last_move[2] == 0) {disable_e2();}
break;
case 2:
enable_e2();
g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2;
if(g_uc_extruder_last_move[0] == 0) disable_e0();
if(g_uc_extruder_last_move[1] == 0) disable_e1();
if(g_uc_extruder_last_move[0] == 0) {disable_e0();}
if(g_uc_extruder_last_move[1] == 0) {disable_e1();}
break;
}
}
@ -915,11 +901,11 @@ block->steps_y.wide = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-p
if (block->steps_e.wide == 0)
{
if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
if(feed_rate<cs.mintravelfeedrate) feed_rate=cs.mintravelfeedrate;
}
else
{
if(feed_rate<minimumfeedrate) feed_rate=minimumfeedrate;
if(feed_rate<cs.minimumfeedrate) feed_rate=cs.minimumfeedrate;
}
/* This part of the code calculates the total length of the movement.
@ -931,17 +917,17 @@ Having the real displacement of the head, we can calculate the total movement le
*/
#ifndef COREXY
float delta_mm[4];
delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS];
delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/cs.axis_steps_per_unit[X_AXIS];
delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/cs.axis_steps_per_unit[Y_AXIS];
#else
float delta_mm[6];
delta_mm[X_HEAD] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS];
delta_mm[Y_HEAD] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
delta_mm[X_AXIS] = ((target[X_AXIS]-position[X_AXIS]) + (target[Y_AXIS]-position[Y_AXIS]))/axis_steps_per_unit[X_AXIS];
delta_mm[Y_AXIS] = ((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]))/axis_steps_per_unit[Y_AXIS];
delta_mm[X_HEAD] = (target[X_AXIS]-position[X_AXIS])/cs.axis_steps_per_unit[X_AXIS];
delta_mm[Y_HEAD] = (target[Y_AXIS]-position[Y_AXIS])/cs.axis_steps_per_unit[Y_AXIS];
delta_mm[X_AXIS] = ((target[X_AXIS]-position[X_AXIS]) + (target[Y_AXIS]-position[Y_AXIS]))/cs.axis_steps_per_unit[X_AXIS];
delta_mm[Y_AXIS] = ((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]))/cs.axis_steps_per_unit[Y_AXIS];
#endif
delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
delta_mm[E_AXIS] = (target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS];
delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/cs.axis_steps_per_unit[Z_AXIS];
delta_mm[E_AXIS] = (target[E_AXIS]-position[E_AXIS])/cs.axis_steps_per_unit[E_AXIS];
if ( block->steps_x.wide <=dropsegments && block->steps_y.wide <=dropsegments && block->steps_z.wide <=dropsegments )
{
block->millimeters = fabs(delta_mm[E_AXIS]);
@ -968,9 +954,9 @@ Having the real displacement of the head, we can calculate the total movement le
if (moves_queued > 1 && moves_queued < (BLOCK_BUFFER_SIZE >> 1)) {
// segment time in micro seconds
unsigned long segment_time = lround(1000000.0/inverse_second);
if (segment_time < minsegmenttime)
if (segment_time < cs.minsegmenttime)
// buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.
inverse_second=1000000.0/(segment_time+lround(2*(minsegmenttime-segment_time)/moves_queued));
inverse_second=1000000.0/(segment_time+lround(2*(cs.minsegmenttime-segment_time)/moves_queued));
}
#endif // SLOWDOWN
@ -1008,11 +994,11 @@ Having the real displacement of the head, we can calculate the total movement le
float steps_per_mm = block->step_event_count.wide/block->millimeters;
if(block->steps_x.wide == 0 && block->steps_y.wide == 0 && block->steps_z.wide == 0)
{
block->acceleration_st = ceil(retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
block->acceleration_st = ceil(cs.retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
}
else
{
block->acceleration_st = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
block->acceleration_st = ceil(cs.acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
// Limit acceleration per axis
//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])
@ -1051,20 +1037,20 @@ Having the real displacement of the head, we can calculate the total movement le
bool limited = false;
for (uint8_t axis = 0; axis < 4; ++ axis) {
float jerk = fabs(current_speed[axis]);
if (jerk > max_jerk[axis]) {
if (jerk > cs.max_jerk[axis]) {
// The actual jerk is lower, if it has been limited by the XY jerk.
if (limited) {
// Spare one division by a following gymnastics:
// Instead of jerk *= safe_speed / block->nominal_speed,
// multiply max_jerk[axis] by the divisor.
jerk *= safe_speed;
float mjerk = max_jerk[axis] * block->nominal_speed;
float mjerk = cs.max_jerk[axis] * block->nominal_speed;
if (jerk > mjerk) {
safe_speed *= mjerk / jerk;
limited = true;
}
} else {
safe_speed = max_jerk[axis];
safe_speed = cs.max_jerk[axis];
limited = true;
}
}
@ -1117,8 +1103,8 @@ Having the real displacement of the head, we can calculate the total movement le
(v_entry - v_exit) :
// axis reversal
max(- v_exit, v_entry));
if (jerk > max_jerk[axis]) {
v_factor *= max_jerk[axis] / jerk;
if (jerk > cs.max_jerk[axis]) {
v_factor *= cs.max_jerk[axis] / jerk;
limited = true;
}
}
@ -1188,7 +1174,7 @@ Having the real displacement of the head, we can calculate the total movement le
extruder_advance_k
* ((advance_ed_ratio < 0.000001) ? de_float / mm_D_float : advance_ed_ratio) // Use the fixed ratio, if set
* (block->nominal_speed / (float)block->nominal_rate)
* axis_steps_per_unit[E_AXIS] * 256.0
* cs.axis_steps_per_unit[E_AXIS] * 256.0
);
#endif
@ -1263,16 +1249,16 @@ void plan_set_position(float x, float y, float z, const float &e)
y = world2machine_rotation_and_skew[1][0] * tmpx + world2machine_rotation_and_skew[1][1] * tmpy + world2machine_shift[1];
}
position[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]);
position[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]);
position[X_AXIS] = lround(x*cs.axis_steps_per_unit[X_AXIS]);
position[Y_AXIS] = lround(y*cs.axis_steps_per_unit[Y_AXIS]);
#ifdef MESH_BED_LEVELING
position[Z_AXIS] = mbl.active ?
lround((z+mbl.get_z(x, y))*axis_steps_per_unit[Z_AXIS]) :
lround(z*axis_steps_per_unit[Z_AXIS]);
lround((z+mbl.get_z(x, y))*cs.axis_steps_per_unit[Z_AXIS]) :
lround(z*cs.axis_steps_per_unit[Z_AXIS]);
#else
position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
position[Z_AXIS] = lround(z*cs.axis_steps_per_unit[Z_AXIS]);
#endif // ENABLE_MESH_BED_LEVELING
position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
position[E_AXIS] = lround(e*cs.axis_steps_per_unit[E_AXIS]);
#ifdef LIN_ADVANCE
position_float[X_AXIS] = x;
position_float[Y_AXIS] = y;
@ -1293,7 +1279,7 @@ void plan_set_z_position(const float &z)
#ifdef LIN_ADVANCE
position_float[Z_AXIS] = z;
#endif
position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
position[Z_AXIS] = lround(z*cs.axis_steps_per_unit[Z_AXIS]);
st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]);
}
@ -1302,7 +1288,7 @@ void plan_set_e_position(const float &e)
#ifdef LIN_ADVANCE
position_float[E_AXIS] = e;
#endif
position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
position[E_AXIS] = lround(e*cs.axis_steps_per_unit[E_AXIS]);
st_set_e_position(position[E_AXIS]);
}
@ -1317,7 +1303,7 @@ void set_extrude_min_temp(float temp)
void reset_acceleration_rates()
{
for(int8_t i=0; i < NUM_AXIS; i++)
axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i];
axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * cs.axis_steps_per_unit[i];
}
#ifdef TMC2130
@ -1325,13 +1311,13 @@ void update_mode_profile()
{
if (tmc2130_mode == TMC2130_MODE_NORMAL)
{
max_feedrate = max_feedrate_normal;
max_acceleration_units_per_sq_second = max_acceleration_units_per_sq_second_normal;
max_feedrate = cs.max_feedrate_normal;
max_acceleration_units_per_sq_second = cs.max_acceleration_units_per_sq_second_normal;
}
else if (tmc2130_mode == TMC2130_MODE_SILENT)
{
max_feedrate = max_feedrate_silent;
max_acceleration_units_per_sq_second = max_acceleration_units_per_sq_second_silent;
max_feedrate = cs.max_feedrate_silent;
max_acceleration_units_per_sq_second = cs.max_acceleration_units_per_sq_second_silent;
}
reset_acceleration_rates();
}

View file

@ -158,27 +158,12 @@ extern bool e_active();
void check_axes_activity();
extern unsigned long minsegmenttime;
// Use M203 to override by software
extern float max_feedrate_normal[NUM_AXIS];
extern float max_feedrate_silent[NUM_AXIS];
extern float* max_feedrate;
// Use M92 to override by software
extern float axis_steps_per_unit[NUM_AXIS];
// Use M201 to override by software
extern unsigned long max_acceleration_units_per_sq_second_normal[NUM_AXIS];
extern unsigned long max_acceleration_units_per_sq_second_silent[NUM_AXIS];
extern unsigned long* max_acceleration_units_per_sq_second;
extern float minimumfeedrate;
extern float acceleration; // Normal acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
extern float retract_acceleration; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX
// Jerk is a maximum immediate velocity change.
extern float max_jerk[NUM_AXIS];
extern float mintravelfeedrate;
extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
extern long position[NUM_AXIS];

View file

@ -85,8 +85,8 @@ void sm4_set_dir(uint8_t axis, uint8_t dir)
uint8_t sm4_get_dir_bits(void)
{
uint8_t register dir_bits = 0;
uint8_t register portL = PORTL;
register uint8_t dir_bits = 0;
register uint8_t portL = PORTL;
//TODO -optimize in asm
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
if (portL & 2) dir_bits |= 1;
@ -106,7 +106,7 @@ uint8_t sm4_get_dir_bits(void)
void sm4_set_dir_bits(uint8_t dir_bits)
{
uint8_t register portL = PORTL;
register uint8_t portL = PORTL;
portL &= 0xb8; //set direction bits to zero
//TODO -optimize in asm
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3))
@ -129,7 +129,7 @@ void sm4_set_dir_bits(uint8_t dir_bits)
void sm4_do_step(uint8_t axes_mask)
{
#if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3) || (MOTHERBOARD == BOARD_EINSY_1_0a))
uint8_t register portC = PORTC & 0xf0;
register uint8_t portC = PORTC & 0xf0;
PORTC = portC | (axes_mask & 0x0f); //set step signals by mask
asm("nop");
PORTC = portC; //set step signals to zero

View file

@ -59,7 +59,7 @@ switch(eSoundMode)
Sound_SaveMode();
}
void Sound_MakeSound(eSOUND_CLASS eSoundClass,eSOUND_TYPE eSoundType)
void Sound_MakeSound(eSOUND_TYPE eSoundType)
{
switch(eSoundMode)
{

View file

@ -26,7 +26,7 @@ extern void Sound_Init(void);
extern void Sound_Default(void);
extern void Sound_Save(void);
extern void Sound_CycleState(void);
extern void Sound_MakeSound(eSOUND_CLASS eSoundClass,eSOUND_TYPE eSoundType);
extern void Sound_MakeSound(eSOUND_TYPE eSoundType);
//static void Sound_DoSound_Echo(void);
//static void Sound_DoSound_Prompt(void);

View file

@ -42,6 +42,7 @@ int fsensor_counter = 0; //counter for e-steps
#endif //FILAMENT_SENSOR
#include "mmu.h"
#include "ConfigurationStore.h"
#ifdef DEBUG_STACK_MONITOR
uint16_t SP_min = 0x21FF;
@ -106,8 +107,6 @@ static bool z_endstop_invert = false;
volatile long count_position[NUM_AXIS] = { 0, 0, 0, 0};
volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1};
uint8_t LastStepMask = 0;
#ifdef LIN_ADVANCE
static uint16_t nextMainISR = 0;
@ -231,15 +230,15 @@ void checkHitEndstops()
SERIAL_ECHO_START;
SERIAL_ECHORPGM(_T(MSG_ENDSTOPS_HIT));
if(endstop_x_hit) {
SERIAL_ECHOPAIR(" X:",(float)endstops_trigsteps[X_AXIS]/axis_steps_per_unit[X_AXIS]);
SERIAL_ECHOPAIR(" X:",(float)endstops_trigsteps[X_AXIS]/cs.axis_steps_per_unit[X_AXIS]);
// LCD_MESSAGERPGM(CAT2(_T(MSG_ENDSTOPS_HIT), PSTR("X")));
}
if(endstop_y_hit) {
SERIAL_ECHOPAIR(" Y:",(float)endstops_trigsteps[Y_AXIS]/axis_steps_per_unit[Y_AXIS]);
SERIAL_ECHOPAIR(" Y:",(float)endstops_trigsteps[Y_AXIS]/cs.axis_steps_per_unit[Y_AXIS]);
// LCD_MESSAGERPGM(CAT2(_T(MSG_ENDSTOPS_HIT), PSTR("Y")));
}
if(endstop_z_hit) {
SERIAL_ECHOPAIR(" Z:",(float)endstops_trigsteps[Z_AXIS]/axis_steps_per_unit[Z_AXIS]);
SERIAL_ECHOPAIR(" Z:",(float)endstops_trigsteps[Z_AXIS]/cs.axis_steps_per_unit[Z_AXIS]);
// LCD_MESSAGERPGM(CAT2(_T(MSG_ENDSTOPS_HIT),PSTR("Z")));
}
SERIAL_ECHOLN("");
@ -734,7 +733,6 @@ FORCE_INLINE void stepper_tick_lowres()
counter_x.lo += current_block->steps_x.lo;
if (counter_x.lo > 0) {
WRITE_NC(X_STEP_PIN, !INVERT_X_STEP_PIN);
LastStepMask |= X_AXIS_MASK;
#ifdef DEBUG_XSTEP_DUP_PIN
WRITE_NC(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN);
#endif //DEBUG_XSTEP_DUP_PIN
@ -749,7 +747,6 @@ FORCE_INLINE void stepper_tick_lowres()
counter_y.lo += current_block->steps_y.lo;
if (counter_y.lo > 0) {
WRITE_NC(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
LastStepMask |= Y_AXIS_MASK;
#ifdef DEBUG_YSTEP_DUP_PIN
WRITE_NC(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN);
#endif //DEBUG_YSTEP_DUP_PIN
@ -764,7 +761,6 @@ FORCE_INLINE void stepper_tick_lowres()
counter_z.lo += current_block->steps_z.lo;
if (counter_z.lo > 0) {
WRITE_NC(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
LastStepMask |= Z_AXIS_MASK;
counter_z.lo -= current_block->step_event_count.lo;
count_position[Z_AXIS]+=count_direction[Z_AXIS];
WRITE_NC(Z_STEP_PIN, INVERT_Z_STEP_PIN);
@ -799,7 +795,6 @@ FORCE_INLINE void stepper_tick_highres()
counter_x.wide += current_block->steps_x.wide;
if (counter_x.wide > 0) {
WRITE_NC(X_STEP_PIN, !INVERT_X_STEP_PIN);
LastStepMask |= X_AXIS_MASK;
#ifdef DEBUG_XSTEP_DUP_PIN
WRITE_NC(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN);
#endif //DEBUG_XSTEP_DUP_PIN
@ -814,7 +809,6 @@ FORCE_INLINE void stepper_tick_highres()
counter_y.wide += current_block->steps_y.wide;
if (counter_y.wide > 0) {
WRITE_NC(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
LastStepMask |= Y_AXIS_MASK;
#ifdef DEBUG_YSTEP_DUP_PIN
WRITE_NC(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN);
#endif //DEBUG_YSTEP_DUP_PIN
@ -829,7 +823,6 @@ FORCE_INLINE void stepper_tick_highres()
counter_z.wide += current_block->steps_z.wide;
if (counter_z.wide > 0) {
WRITE_NC(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
LastStepMask |= Z_AXIS_MASK;
counter_z.wide -= current_block->step_event_count.wide;
count_position[Z_AXIS]+=count_direction[Z_AXIS];
WRITE_NC(Z_STEP_PIN, INVERT_Z_STEP_PIN);
@ -867,8 +860,6 @@ FORCE_INLINE void isr() {
if (current_block == NULL)
stepper_next_block();
LastStepMask = 0;
if (current_block != NULL)
{
stepper_check_endstops();
@ -1112,7 +1103,7 @@ FORCE_INLINE void isr() {
}
#ifdef TMC2130
tmc2130_st_isr(LastStepMask);
tmc2130_st_isr();
#endif //TMC2130
//WRITE_NC(LOGIC_ANALYZER_CH0, false);
@ -1424,7 +1415,7 @@ void st_get_position_xy(long &x, long &y)
float st_get_position_mm(uint8_t axis)
{
float steper_position_in_steps = st_get_position(axis);
return steper_position_in_steps / axis_steps_per_unit[axis];
return steper_position_in_steps / cs.axis_steps_per_unit[axis];
}
@ -1467,13 +1458,10 @@ void babystep(const uint8_t axis,const bool direction)
//perform step
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
LastStepMask |= X_AXIS_MASK;
#ifdef DEBUG_XSTEP_DUP_PIN
WRITE(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN);
#endif //DEBUG_XSTEP_DUP_PIN
{
volatile float x=1./float(axis+1)/float(axis+2); //wait a tiny bit
}
delayMicroseconds(1);
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
#ifdef DEBUG_XSTEP_DUP_PIN
WRITE(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN);
@ -1493,13 +1481,10 @@ void babystep(const uint8_t axis,const bool direction)
//perform step
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
LastStepMask |= Y_AXIS_MASK;
#ifdef DEBUG_YSTEP_DUP_PIN
WRITE(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN);
#endif //DEBUG_YSTEP_DUP_PIN
{
volatile float x=1./float(axis+1)/float(axis+2); //wait a tiny bit
}
delayMicroseconds(1);
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
#ifdef DEBUG_YSTEP_DUP_PIN
WRITE(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN);
@ -1522,14 +1507,10 @@ void babystep(const uint8_t axis,const bool direction)
#endif
//perform step
WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
LastStepMask |= Z_AXIS_MASK;
#ifdef Z_DUAL_STEPPER_DRIVERS
WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN);
#endif
//wait a tiny bit
{
volatile float x=1./float(axis+1); //absolutely useless
}
delayMicroseconds(1);
WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
#ifdef Z_DUAL_STEPPER_DRIVERS
WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN);
@ -1549,16 +1530,16 @@ void babystep(const uint8_t axis,const bool direction)
}
#endif //BABYSTEPPING
#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
void digitalPotWrite(int address, int value) // From Arduino DigitalPotControl example
{
#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
digitalWrite(DIGIPOTSS_PIN,LOW); // take the SS pin low to select the chip
SPI.transfer(address); // send in the address and value via SPI:
SPI.transfer(value);
digitalWrite(DIGIPOTSS_PIN,HIGH); // take the SS pin high to de-select the chip:
//delay(10);
#endif
}
#endif
void EEPROM_read_st(int pos, uint8_t* value, uint8_t size)
{
@ -1602,19 +1583,19 @@ uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
#ifdef MOTOR_CURRENT_PWM_XY_PIN
void st_current_set(uint8_t driver, int current)
{
#ifdef MOTOR_CURRENT_PWM_XY_PIN
if (driver == 0) analogWrite(MOTOR_CURRENT_PWM_XY_PIN, (long)current * 255L / (long)MOTOR_CURRENT_PWM_RANGE);
if (driver == 1) analogWrite(MOTOR_CURRENT_PWM_Z_PIN, (long)current * 255L / (long)MOTOR_CURRENT_PWM_RANGE);
if (driver == 2) analogWrite(MOTOR_CURRENT_PWM_E_PIN, (long)current * 255L / (long)MOTOR_CURRENT_PWM_RANGE);
#endif
}
#else //MOTOR_CURRENT_PWM_XY_PIN
void st_current_set(uint8_t, int ){}
#endif //MOTOR_CURRENT_PWM_XY_PIN
void microstep_init()
{
const uint8_t microstep_modes[] = MICROSTEP_MODES;
#if defined(E1_MS1_PIN) && E1_MS1_PIN > -1
pinMode(E1_MS1_PIN,OUTPUT);
@ -1622,6 +1603,7 @@ void microstep_init()
#endif
#if defined(X_MS1_PIN) && X_MS1_PIN > -1
const uint8_t microstep_modes[] = MICROSTEP_MODES;
pinMode(X_MS1_PIN,OUTPUT);
pinMode(X_MS2_PIN,OUTPUT);
pinMode(Y_MS1_PIN,OUTPUT);

View file

@ -90,10 +90,12 @@ extern bool x_min_endstop;
extern bool x_max_endstop;
extern bool y_min_endstop;
extern bool y_max_endstop;
extern volatile long count_position[NUM_AXIS];
void quickStop();
#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
void digitalPotWrite(int address, int value);
#endif //defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2);
void microstep_mode(uint8_t driver, uint8_t stepping);
void st_current_init();

View file

@ -39,6 +39,7 @@
#include <avr/wdt.h>
#include "adc.h"
#include "ConfigurationStore.h"
//===========================================================================
@ -79,19 +80,10 @@ float current_temperature_bed = 0.0;
float _Kp, _Ki, _Kd;
int pid_cycle, pid_number_of_cycles;
bool pid_tuning_finished = false;
float Kp=DEFAULT_Kp;
float Ki=(DEFAULT_Ki*PID_dT);
float Kd=(DEFAULT_Kd/PID_dT);
#ifdef PID_ADD_EXTRUSION_RATE
float Kc=DEFAULT_Kc;
#endif
#endif //PIDTEMP
#ifdef PIDTEMPBED
float bedKp=DEFAULT_bedKp;
float bedKi=(DEFAULT_bedKi*PID_dT);
float bedKd=(DEFAULT_bedKd/PID_dT);
#endif //PIDTEMPBED
#ifdef FAN_SOFT_PWM
unsigned char fanSpeedSoftPwm;
@ -183,7 +175,6 @@ static int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
static float analog2temp(int raw, uint8_t e);
static float analog2tempBed(int raw);
static float analog2tempAmbient(int raw);
static float analog2tempPINDA(int raw);
static void updateTemperaturesFromRawValues();
enum TempRunawayStates
@ -422,11 +413,11 @@ void updatePID()
{
#ifdef PIDTEMP
for(int e = 0; e < EXTRUDERS; e++) {
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki;
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / cs.Ki;
}
#endif
#ifdef PIDTEMPBED
temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi;
temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / cs.bedKi;
#endif
}
@ -501,9 +492,6 @@ void checkFanSpeed()
}
}
extern void stop_and_save_print_to_ram(float z_move, float e_move);
extern void restore_print_from_ram_and_continue(float e_move);
void fanSpeedError(unsigned char _fan) {
if (get_message_level() != 0 && isPrintPaused) return;
//to ensure that target temp. is not set to zero in case taht we are resuming print
@ -512,8 +500,7 @@ void fanSpeedError(unsigned char _fan) {
lcd_print_stop();
}
else {
isPrintPaused = true;
lcd_sdcard_pause();
lcd_pause_print();
}
}
else {
@ -638,14 +625,14 @@ void manage_heater()
temp_iState[e] = 0.0;
pid_reset[e] = false;
}
pTerm[e] = Kp * pid_error[e];
pTerm[e] = cs.Kp * pid_error[e];
temp_iState[e] += pid_error[e];
temp_iState[e] = constrain(temp_iState[e], temp_iState_min[e], temp_iState_max[e]);
iTerm[e] = Ki * temp_iState[e];
iTerm[e] = cs.Ki * temp_iState[e];
//K1 defined in Configuration.h in the PID settings
#define K2 (1.0-K1)
dTerm[e] = (Kd * (pid_input - temp_dState[e]))*K2 + (K1 * dTerm[e]);
dTerm[e] = (cs.Kd * (pid_input - temp_dState[e]))*K2 + (K1 * dTerm[e]);
pid_output = pTerm[e] + iTerm[e] - dTerm[e];
if (pid_output > PID_MAX) {
if (pid_error[e] > 0 ) temp_iState[e] -= pid_error[e]; // conditional un-integration
@ -753,14 +740,14 @@ void manage_heater()
#ifndef PID_OPENLOOP
pid_error_bed = target_temperature_bed - pid_input;
pTerm_bed = bedKp * pid_error_bed;
pTerm_bed = cs.bedKp * pid_error_bed;
temp_iState_bed += pid_error_bed;
temp_iState_bed = constrain(temp_iState_bed, temp_iState_min_bed, temp_iState_max_bed);
iTerm_bed = bedKi * temp_iState_bed;
iTerm_bed = cs.bedKi * temp_iState_bed;
//K1 defined in Configuration.h in the PID settings
#define K2 (1.0-K1)
dTerm_bed= (bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed);
dTerm_bed= (cs.bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed);
temp_dState_bed = pid_input;
pid_output = pTerm_bed + iTerm_bed - dTerm_bed;
@ -936,35 +923,6 @@ static float analog2tempBed(int raw) {
#endif
}
#ifdef PINDA_THERMISTOR
static float analog2tempPINDA(int raw) {
float celsius = 0;
byte i;
for (i = 1; i<BEDTEMPTABLE_LEN; i++)
{
if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw)
{
celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]) +
(raw - PGM_RD_W(BEDTEMPTABLE[i - 1][0])) *
(float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i - 1][1])) /
(float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i - 1][0]));
break;
}
}
// Overflow: Set to last value in the table
if (i == BEDTEMPTABLE_LEN) celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]);
return celsius;
}
#endif //PINDA_THERMISTOR
#ifdef AMBIENT_THERMISTOR
static float analog2tempAmbient(int raw)
{
@ -1040,11 +998,11 @@ void tp_init()
maxttemp[e] = maxttemp[0];
#ifdef PIDTEMP
temp_iState_min[e] = 0.0;
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki;
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / cs.Ki;
#endif //PIDTEMP
#ifdef PIDTEMPBED
temp_iState_min_bed = 0.0;
temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi;
temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / cs.bedKi;
#endif //PIDTEMPBED
}

View file

@ -73,7 +73,7 @@ extern int current_voltage_raw_bed;
#ifdef PIDTEMP
extern int pid_cycle, pid_number_of_cycles;
extern float Kp,Ki,Kd,Kc,_Kp,_Ki,_Kd;
extern float Kc,_Kp,_Ki,_Kd;
extern bool pid_tuning_finished;
float scalePID_i(float i);
float scalePID_d(float d);
@ -81,9 +81,6 @@ extern int current_voltage_raw_bed;
float unscalePID_d(float d);
#endif
#ifdef PIDTEMPBED
extern float bedKp,bedKi,bedKd;
#endif
#ifdef BABYSTEPPING

View file

@ -13,12 +13,6 @@
#define TMC2130_GCONF_SGSENS 0x00003180 // spreadCycle with stallguard (stall activates DIAG0 and DIAG1 [pushpull])
#define TMC2130_GCONF_SILENT 0x00000004 // stealthChop
//externals for debuging
extern float current_position[4];
extern void st_get_position_xy(long &x, long &y);
extern long st_get_position(uint8_t axis);
extern void crashdet_stop_and_save_print();
extern void crashdet_stop_and_save_print2();
//mode
uint8_t tmc2130_mode = TMC2130_MODE_NORMAL;
@ -236,7 +230,7 @@ uint8_t tmc2130_sample_diag()
extern bool is_usb_printing;
void tmc2130_st_isr(uint8_t last_step_mask)
void tmc2130_st_isr()
{
if (tmc2130_mode == TMC2130_MODE_SILENT || tmc2130_sg_stop_on_crash == false) return;
uint8_t crash = 0;
@ -793,7 +787,7 @@ void tmc2130_do_steps(uint8_t axis, uint16_t steps, uint8_t dir, uint16_t delay_
void tmc2130_goto_step(uint8_t axis, uint8_t step, uint8_t dir, uint16_t delay_us, uint16_t microstep_resolution)
{
printf_P(PSTR("tmc2130_goto_step %d %d %d %d \n"), axis, step, dir, delay_us, microstep_resolution);
uint8_t shift; for (shift = 0; shift < 8; shift++) if (microstep_resolution == (256 >> shift)) break;
uint8_t shift; for (shift = 0; shift < 8; shift++) if (microstep_resolution == (256u >> shift)) break;
uint16_t cnt = 4 * (1 << (8 - shift));
uint16_t mscnt = tmc2130_rd_MSCNT(axis);
if (dir == 2)
@ -805,7 +799,7 @@ void tmc2130_goto_step(uint8_t axis, uint8_t step, uint8_t dir, uint16_t delay_u
dir ^= 1;
steps = -steps;
}
if (steps > (cnt / 2))
if (steps > static_cast<int>(cnt / 2))
{
dir ^= 1;
steps = cnt - steps;
@ -830,7 +824,7 @@ void tmc2130_get_wave(uint8_t axis, uint8_t* data, FILE* stream)
tmc2130_setup_chopper(axis, tmc2130_usteps2mres(256), tmc2130_current_h[axis], tmc2130_current_r[axis]);
tmc2130_goto_step(axis, 0, 2, 100, 256);
tmc2130_set_dir(axis, tmc2130_get_inv(axis)?0:1);
for (int i = 0; i <= 255; i++)
for (unsigned int i = 0; i <= 255; i++)
{
uint32_t val = tmc2130_rd_MSCURACT(axis);
uint16_t mscnt = tmc2130_rd_MSCNT(axis);
@ -847,6 +841,7 @@ void tmc2130_get_wave(uint8_t axis, uint8_t* data, FILE* stream)
delayMicroseconds(100);
}
tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
tmc2130_set_pwr(axis, pwr);
}
void tmc2130_set_wave(uint8_t axis, uint8_t amp, uint8_t fac1000)
@ -869,7 +864,7 @@ void tmc2130_set_wave(uint8_t axis, uint8_t amp, uint8_t fac1000)
int8_t b; //encoded bit value
int8_t dA; //delta value
int i; //microstep index
uint32_t reg; //tmc2130 register
uint32_t reg = 0; //tmc2130 register
tmc2130_wr_MSLUTSTART(axis, 0, amp);
for (i = 0; i < 256; i++)
{

View file

@ -53,7 +53,7 @@ extern tmc2130_chopper_config_t tmc2130_chopper_config[4];
//initialize tmc2130
extern void tmc2130_init();
//check diag pins (called from stepper isr)
extern void tmc2130_st_isr(uint8_t last_step_mask);
extern void tmc2130_st_isr();
//update stall guard (called from st_synchronize inside the loop)
extern bool tmc2130_update_sg();
//temperature watching (called from )

View file

@ -16,7 +16,7 @@ uint8_t uart2_ibuf[14] = {0, 0};
FILE _uart2io = {0};
int uart2_putchar(char c, FILE *stream)
int uart2_putchar(char c, FILE *stream __attribute__((unused)))
{
while (!uart2_txready);
UDR2 = c; // transmit byte
@ -25,7 +25,7 @@ int uart2_putchar(char c, FILE *stream)
return 0;
}
int uart2_getchar(FILE *stream)
int uart2_getchar(FILE *stream __attribute__((unused)))
{
if (rbuf_empty(uart2_ibuf)) return -1;
return rbuf_get(uart2_ibuf);

File diff suppressed because it is too large Load diff

View file

@ -5,6 +5,7 @@
#include "lcd.h"
#include "conv2str.h"
#include "menu.h"
#include "mesh_bed_calibration.h"
extern int lcd_puts_P(const char* str);
extern int lcd_printf_P(const char* format, ...);
@ -31,7 +32,8 @@ void lcd_loading_filament();
void lcd_change_success();
void lcd_loading_color();
void lcd_sdcard_stop();
void lcd_sdcard_pause();
void lcd_pause_print();
void lcd_resume_print();
void lcd_print_stop();
void prusa_statistics(int _message, uint8_t _col_nr = 0);
void lcd_confirm_print();
@ -50,6 +52,8 @@ extern void lcd_wait_for_click();
extern void lcd_show_fullscreen_message_and_wait_P(const char *msg);
// 0: no, 1: yes, -1: timeouted
extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false);
extern int8_t lcd_show_multiscreen_message_two_choices_and_wait_P(const char *msg, bool allow_timeouting, bool default_yes,
const char *first_choice, const char *second_choice);
extern int8_t lcd_show_multiscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false);
// Ask the user to move the Z axis up to the end stoppers and let
// the user confirm that it has been done.
@ -59,7 +63,7 @@ extern bool lcd_calibrate_z_end_stop_manual(bool only_z);
#endif
// Show the result of the calibration process on the LCD screen.
extern void lcd_bed_calibration_show_result(uint8_t result, uint8_t point_too_far_mask);
extern void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, uint8_t point_too_far_mask);
extern void lcd_diag_show_end_stops();
@ -76,11 +80,11 @@ extern void lcd_diag_show_end_stops();
#define LCD_COMMAND_STOP_PRINT 2
#define LCD_COMMAND_FARM_MODE_CONFIRM 4
#define LCD_COMMAND_LONG_PAUSE 5
#define LCD_COMMAND_LONG_PAUSE_RESUME 6
#define LCD_COMMAND_PID_EXTRUDER 7
#define LCD_COMMAND_V2_CAL 8
extern int lcd_commands_type;
extern int8_t FSensorStateMenu;
#define CUSTOM_MSG_TYPE_STATUS 0 // status message from lcd_status_message variable
#define CUSTOM_MSG_TYPE_MESHBL 1 // Mesh bed leveling in progress
@ -150,7 +154,7 @@ bool lcd_wait_for_pinda(float temp);
void bowden_menu();
char reset_menu();
char choose_extruder_menu();
uint8_t choose_menu_P(const char *header, const char *item, const char *last_item = nullptr);
void lcd_pinda_calibration_menu();
void lcd_calibrate_pinda();
@ -166,6 +170,26 @@ void lcd_set_progress();
void lcd_language();
void lcd_wizard();
void lcd_wizard(int state);
//! @brief Wizard state
enum class WizState : uint8_t
{
Run, //!< run wizard? Entry point.
Restore, //!< restore calibration status
Selftest,
Xyz, //!< xyz calibration
Z, //!< z calibration
IsFil, //!< Is filament loaded? Entry point for 1st layer calibration
PreheatPla, //!< waiting for preheat nozzle for PLA
Preheat, //!< Preheat for any material
Unload, //!< Unload filament
LoadFil, //!< Load filament
IsPla, //!< Is PLA filament?
Lay1Cal, //!< First layer calibration
RepeatLay1Cal, //!< Repeat first layer calibration?
Finish, //!< Deactivate wizard
};
void lcd_wizard(WizState state);
#endif //ULTRALCD_H

View file

@ -32,8 +32,6 @@
#define _PI 3.14159265F
extern volatile long count_position[NUM_AXIS];
uint8_t check_pinda_0();
uint8_t check_pinda_1();
void xyzcal_update_pos(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de);
@ -87,7 +85,7 @@ uint8_t check_pinda_1()
uint8_t xyzcal_dm = 0;
void xyzcal_update_pos(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de)
void xyzcal_update_pos(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t)
{
// DBG(_n("xyzcal_update_pos dx=%d dy=%d dz=%d dir=%02x\n"), dx, dy, dz, xyzcal_dm);
if (xyzcal_dm&1) count_position[0] -= dx; else count_position[0] += dx;
@ -108,11 +106,9 @@ uint16_t xyzcal_sm4_ac2 = (uint32_t)xyzcal_sm4_ac * 1024 / 10000;
//float xyzcal_sm4_vm = 10000;
#endif //SM4_ACCEL_TEST
#ifdef SM4_ACCEL_TEST
uint16_t xyzcal_calc_delay(uint16_t nd, uint16_t dd)
{
return xyzcal_sm4_delay;
#ifdef SM4_ACCEL_TEST
uint16_t del_us = 0;
if (xyzcal_sm4_v & 0xf000) //>=4096
{
@ -138,9 +134,13 @@ uint16_t xyzcal_calc_delay(uint16_t nd, uint16_t dd)
// return xyzcal_sm4_delay;
// DBG(_n("xyzcal_calc_delay nd=%d dd=%d v=%d del_us=%d\n"), nd, dd, xyzcal_sm4_v, del_us);
return 0;
#endif //SM4_ACCEL_TEST
}
#else //SM4_ACCEL_TEST
uint16_t xyzcal_calc_delay(uint16_t, uint16_t)
{
return xyzcal_sm4_delay;
}
#endif //SM4_ACCEL_TEST
bool xyzcal_lineXYZ_to(int16_t x, int16_t y, int16_t z, uint16_t delay_us, int8_t check_pinda)
{
@ -285,7 +285,7 @@ void xyzcal_scan_pixels_32x32(int16_t cx, int16_t cy, int16_t min_z, int16_t max
xyzcal_lineXYZ_to(cx, cy, z, 2*delay_us, 0);
for (uint8_t r = 0; r < 32; r++)
{
int8_t _pinda = _PINDA;
// int8_t _pinda = _PINDA;
xyzcal_lineXYZ_to((r&1)?(cx+1024):(cx-1024), cy - 1024 + r*64, z, 2*delay_us, 0);
xyzcal_lineXYZ_to(_X, _Y, min_z, delay_us, 1);
xyzcal_lineXYZ_to(_X, _Y, max_z, delay_us, -1);
@ -330,7 +330,7 @@ void xyzcal_scan_pixels_32x32(int16_t cx, int16_t cy, int16_t min_z, int16_t max
}
sm4_do_step(X_AXIS_MASK);
delayMicroseconds(600);
_pinda = pinda;
// _pinda = pinda;
}
sum >>= 6; //div 64
if (z_sum < 0)

View file

@ -11,8 +11,7 @@
1. install `"Arduino Software IDE"` for your preferred operating system
`https://www.arduino.cc -> Software->Downloads`
it is strongly recommended to use older version `"1.6.9"`, by which we can assure correct compilation results
_note: in versions `1.7.x` and `1.8.x` there are known some C/C++ compilator disasters, which disallow correct source code compilation (you can obtain `"... internal compiler error: in extract_insn, at ..."` error message, for example); we are not able to affect this situation afraid_
it is recommended to use older version `"1.6.9"`, as it is used on out build server to produce official builds.
_note: in the case of persistent compilation problems, check the version of the currently used C/C++ compiler (GCC) - should be `4.8.1`; version can be verified by entering the command
`avr-gcc --version`
if you are not sure where the file is placed (depends on how `"Arduino Software IDE"` was installed), you can use the search feature within the file system_
@ -35,8 +34,10 @@ _note: select this item for any variant of board used in printers `'Prusa i3 MKx
'clicking' the item will display the installation button; select choice `"1.0.1"` from the list(last known version as of the date of issue of this document)
_(after installation, the item is labeled as `"INSTALLED"` and can then be used for target board selection)_
3. modify platform.txt to enable float printf support:
`"compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections"`
3. modify platform.txt to enable float printf support:
add "-Wl,-u,vfprintf -lprintf_flt -lm" to "compiler.c.elf.flags=" before existing flag "-Wl,--gc-sections"
example:
`"compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections"`
# 2. Source code compilation

View file

@ -2,8 +2,7 @@
1. nainstalujte vývojové prostředí `"Arduino Software IDE"` pro operační prostředí, které jste zvyklí používat
`https://www.arduino.cc -> Software->Downloads`
důrazně doporučujeme použít starší verzi `"1.6.8"`, u které jsme schopni garantovat bezproblémový překlad a správné výsledky
_pozn.: ve verzích `1.7.x` a `1.8.x` jsou k datu vydání tohoto dokumentu evidovány chyby v překladači jazyka C/C++, které znemožňují překlad zdrojového kódu (můžete např. obdržet chybové hlášení `"... internal compiler error: in extract_insn, at ..."`); tuto nepříjemnou situaci bohužel nedokážeme nijak ovlivnit_
doporučujeme použít starší verzi `"1.6.9"`, kterou používáme na našem build serveru pro překlad oficiálních buildů
_pozn.: v případě přetrvávajících potíží s překladem zkontrolujte verzi aktuálně použitého překladače jazyka C/C++ (GCC) - měla by být `4.8.1`; verzi ověříte zadáním příkazu
`avr-gcc --version`
pokud si nejste jisti umístěním souboru (závisí na způsobu, jakým bylo `"Arduino Software IDE"` nainstalováno), použijte funkci vyhledání v rámci systému souborů_
@ -26,6 +25,10 @@ _pozn.: tuto položku zvolte pro všechny varianty desek použitých v tiskárn
'kliknutím' na položku se zobrazí tlačítko pro instalaci; ve výběrovém seznamu zvolte verzi `"1.0.1"` (poslední známá verze k datu vydání tohoto dokumentu)
_(po provedení instalace je položka označena poznámkou `"INSTALLED"` a lze ji následně použít při výběru cílové desky)_
3. modify platform.txt to enable float printf support:
add "-Wl,-u,vfprintf -lprintf_flt -lm" to "compiler.c.elf.flags=" before existing flag "-Wl,--gc-sections"
example:
`"compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections"`
# 2. Překlad zdrojoveho kódu