Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion Marlin/GuiAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,33 @@
#include "LightManager.h"
#include "cardreader.h"

#ifdef AUTO_BED_LEVELING_GRID
#include "config/hephestos_2/Configuration.h"
#include "qr_solve.h"
static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
{
vector_3 planeNormal = vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1);
planeNormal.debug("planeNormal");
plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
//bedLevel.debug("bedLevel");

//plan_bed_level_matrix.debug("bed level before");
//vector_3 uncorrected_position = plan_get_position_mm();
//uncorrected_position.debug("position before");

vector_3 corrected_position = plan_get_position();
// corrected_position.debug("position after");
current_position[X_AXIS] = corrected_position.x;
current_position[Y_AXIS] = corrected_position.y;
current_position[Z_AXIS] = corrected_position.z;

// put the bed at 0 so we don't go below it.
current_position[Z_AXIS] = zprobe_zoffset; // in the lsq we reach here after raising the extruder due to the loop structure

plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
}
#endif

#ifdef DOGLCD
#include "StatsManager.h"
#include "HeatedbedManager.h"
Expand Down Expand Up @@ -301,9 +328,9 @@ void action_get_plane()
if(HeatedbedManager::single::instance().detected())
{
temp::TemperatureManager::single::instance().setBedTargetTemperature(0);
unsigned long curtime = millis();
while(HeatedbedManager::single::instance().detected() && temp::TemperatureManager::single::instance().getBedCurrentTemperature() > BED_AUTOLEVEL_TEMP)
{
unsigned long curtime = millis();
if(( millis() - curtime) > 1000 ) //Print Temp Reading every 1 second while heating up.
{
float tt=temp::TemperatureManager::single::instance().getCurrentTemperature();
Expand All @@ -316,6 +343,8 @@ void action_get_plane()
SERIAL_PROTOCOLLN("");
curtime = millis();
}
temp::TemperatureManager::single::instance().manageTemperatureControl();
lcd_update();
};
}
#endif // HEATER_BED_PIN > -1
Expand Down Expand Up @@ -698,6 +727,11 @@ void action_start_print()
StatsManager::single::instance().increaseTotalPrints();
#endif //DOGLCD






#ifdef FAN_BOX_PIN
if(FanManager::single::instance().state() == true)
{
Expand Down Expand Up @@ -904,6 +938,11 @@ void action_offset()
current_position[Z_AXIS] = 0;
z_saved_homing = OffsetManager::single::instance().getOffset();


SERIAL_PROTOCOLPGM("actual Offset: ");
SERIAL_PROTOCOL(OffsetManager::single::instance().getOffset());
SERIAL_PROTOCOLPGM("\n");

plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
setup_for_endstop_move();

Expand Down Expand Up @@ -951,9 +990,11 @@ void action_offset()
{
current_position[Z_AXIS] = -(z_saved_homing - z_offset);
}

do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]);

current_position[Z_AXIS] = plan_get_axis_position(Z_AXIS);

}
#endif //LEVEL_SENSOR

Expand Down Expand Up @@ -987,6 +1028,10 @@ void action_offset_rest()
void action_save_offset()
{
OffsetManager::single::instance().saveOffset();

SERIAL_PROTOCOLPGM("actual Offset: ");
SERIAL_PROTOCOL(OffsetManager::single::instance().getOffset());
SERIAL_PROTOCOLPGM("\n");
}

void action_wizard_init()
Expand Down
2 changes: 1 addition & 1 deletion Marlin/HeatedbedManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ uint8_t HeatedbedManager::mode()
{
if(m_bed_detected)
{
uint8_t const num_modes = 3;
uint8_t const num_modes = 2;

mode((m_mode+1) % num_modes);
}
Expand Down
14 changes: 8 additions & 6 deletions Marlin/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ enum class Language
FR, // French
PT, // Portuguese
IT, // Italian
SE, // Swedish
//SE, // Swedish
RU, // Russian
MAX_LANGUAGES
};
Expand Down Expand Up @@ -83,17 +83,19 @@ const char * MSG_##label() \
{ \
text = IT_##label; \
} \
else if (LANG == Language::SE) \
{ \
text = SE_##label; \
} \
else if (LANG == Language::RU) \
else if (LANG == Language::RU) \
{ \
text = RU_##label; \
} \
return text; \
}

/*
else if (LANG == Language::SE) \
{ \
text = SE_##label; \
} \
*/
enum class Label
{
NONE = 0,
Expand Down
62 changes: 23 additions & 39 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,32 +1281,6 @@ static void do_blocking_extrude_to(float e) {
feedrate = oldFeedRate;
}

#ifdef AUTO_BED_LEVELING_GRID
static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
{
vector_3 planeNormal = vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1);
planeNormal.debug("planeNormal");
plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
//bedLevel.debug("bedLevel");

//plan_bed_level_matrix.debug("bed level before");
//vector_3 uncorrected_position = plan_get_position_mm();
//uncorrected_position.debug("position before");

vector_3 corrected_position = plan_get_position();
// corrected_position.debug("position after");
current_position[X_AXIS] = corrected_position.x;
current_position[Y_AXIS] = corrected_position.y;
current_position[Z_AXIS] = corrected_position.z;

// put the bed at 0 so we don't go below it.
current_position[Z_AXIS] = zprobe_zoffset; // in the lsq we reach here after raising the extruder due to the loop structure

plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
}

#endif // AUTO_BED_LEVELING_GRID

static void run_z_probe() {
plan_bed_level_matrix.set_to_identity();
feedrate = homing_feedrate[Z_AXIS];
Expand All @@ -1320,18 +1294,28 @@ static void run_z_probe() {
zPosition = st_get_position_mm(Z_AXIS);
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS]);

// move up the retract distance
zPosition += home_retract_mm(Z_AXIS);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
st_synchronize();

// move back down slowly to find bed
feedrate = homing_slow_feedrate[Z_AXIS];
zPosition -= home_retract_mm(Z_AXIS) * 2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
st_synchronize();

current_position[Z_AXIS] = st_get_position_mm(Z_AXIS);
float zpos=0;
for (int8_t prob = 1; prob <= Z_PROBE_REPEAT_SENSOR; prob++)
{
// move up the retract distance
zPosition += home_retract_mm(Z_AXIS);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
st_synchronize();

// move back down slowly to find bed
feedrate = homing_slow_feedrate[Z_AXIS];
zPosition -= home_retract_mm(Z_AXIS) * 2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
st_synchronize();

zpos = zpos + st_get_position_mm(Z_AXIS);

}

current_position[Z_AXIS] = zpos / Z_PROBE_REPEAT_SENSOR;//st_get_position_mm(Z_AXIS); //st_get_position_mm(Z_AXIS);

// make sure the planner knows where we are as it may be a bit different than we last said to move to
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
}
Expand Down Expand Up @@ -1857,9 +1841,9 @@ void process_commands()

if(HeatedbedManager::single::instance().getMode() == eeprom::HEATEDBED_ON && PrintManager::single::instance().state() != SERIAL_CONTROL)
{
char cmd[LONG_FILENAME_LENGTH];
sprintf_P(cmd, PSTR("M190 S%d"), ABS_PREHEAT_HPB_TEMP);
enquecommand(cmd);
//char cmd[LONG_FILENAME_LENGTH]; !!!!!!!!!!!!!!!!!!!!!!!AGUS
//sprintf_P(cmd, PSTR("M190 S%d"), ABS_PREHEAT_HPB_TEMP);
//enquecommand(cmd);
}
}
else if(PrintManager::single::instance().state() == SERIAL_CONTROL && card.isFileAtBegin() == false)
Expand Down
62 changes: 57 additions & 5 deletions Marlin/TemperatureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#include "ViewManager.h"
#include "FanManager.h"
#include "HeatedbedManager.h"
#else
#include "Serial.h"
#include "ultralcd.h"
#endif

namespace temp
Expand All @@ -59,6 +62,9 @@ namespace temp
, m_control()
#endif // DOGLCD
, m_blower_control(true)
, m_temp_protection_counter(0)
, m_check_temp_protection(false)
, m_force_disable_hotend(false)
{
setTargetTemperature(0);
SET_OUTPUT(HEATER_0_PIN);
Expand Down Expand Up @@ -237,6 +243,31 @@ namespace temp
notify();
}
fanControl();

if(m_check_temp_protection)
{
--m_temp_protection_counter;
if(m_temp_protection_counter == 0)
{
if(temp < THERMISTOR_PROTECTION_MIN_TARGET_TEMP)
{
setTargetTemperature(0);
#ifdef DOGLCD
lcd_disable_button();
ui::ViewManager::getInstance().activeView(ui::screen_error_temperature);
#else
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS);
LCD_MESSAGEPGM("thermistor error");
m_force_disable_hotend = true;
#endif // DOGLCD
}
else
{
m_check_temp_protection = false;
}
}
}
}

void TemperatureManager::updateCurrentTemperatureRaw(uint16_t temp)
Expand All @@ -253,20 +284,37 @@ namespace temp
void TemperatureManager::setTargetTemperature(uint16_t target)
{
m_target_temperature = target;
#ifdef DOGLCD

if(target > HEATER_0_MINTEMP)
{
#ifdef DOGLCD
TCCR2A |= 0x20;
#endif // DOGLCD
// enable temperature check if starting temperature
// is lower than mintemp
if(getCurrentTemperature() < THERMISTOR_PROTECTION_MAX_ENABLE_TEMP
&& target > THERMISTOR_PROTECTION_MIN_TARGET_TEMP)
{
m_check_temp_protection = true;
m_temp_protection_counter = THERMISTOR_PROTECTION_WAIT_CYCLES;
}
}
else
{
#ifdef DOGLCD
TCCR2A &= 0xDF;
#endif // DOGLCD
m_check_temp_protection = false;
m_temp_protection_counter = 0;
}
#ifdef DOGLCD
m_control->setTargetControl(target);
#else
target_temperature[0] = target;
#endif // DOGLCD
#else
if(!m_force_disable_hotend)
{
target_temperature[0] = target;
}
#endif // DOGLCD
}

uint16_t const & TemperatureManager::getTargetTemperature() const
Expand Down Expand Up @@ -433,6 +481,10 @@ namespace temp
}
#endif // MB(BQ_ZUM_MEGA_3D)
#else
if(m_force_disable_hotend)
{
target_temperature[0] = 0;
}
manage_heater();
#endif
}
Expand Down
4 changes: 4 additions & 0 deletions Marlin/TemperatureManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ namespace temp

LookUpTableEntry m_bed_cache[4];
uint16_t m_bed_round_temperature;

uint16_t m_temp_protection_counter;
bool m_check_temp_protection;
bool m_force_disable_hotend;
};
}

Expand Down
2 changes: 1 addition & 1 deletion Marlin/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
#define BOARD_99 99 // This is in pins.h but...?

#define MB(board) (MOTHERBOARD == BOARD_##board)
#define IS_RAMPS (MB(RAMPS_OLD) || MB(RAMPS_13_EFB) || MB(RAMPS_13_EEB) || MB(RAMPS_13_EFF) || MB(RAMPS_13_EEF) || MB(BQCNC))
#define IS_RAMPS (MB(RAMPS_OLD) || MB(RAMPS_13_EFB) || MB(RAMPS_13_EEB) || MB(RAMPS_13_EFF) || MB(RAMPS_13_EEF) || MB(BQCNC) || MB(BQ_ZUM_MEGA_3D))

#endif //__BOARDS_H
Loading