Commit 3223901a authored by MagoKimbra's avatar MagoKimbra

Fix Power Consumation

parent 782fb5e0
...@@ -75,6 +75,11 @@ ...@@ -75,6 +75,11 @@
// This is used for single nozzle and multiple extrusion configuration // This is used for single nozzle and multiple extrusion configuration
// Uncomment below to enable (One Hotend) // Uncomment below to enable (One Hotend)
//#define SINGLENOZZLE //#define SINGLENOZZLE
#ifdef SINGLENOZZLE
#define HOTENDS 1
#else
#define HOTENDS EXTRUDERS
#endif
/*********************************************************************** /***********************************************************************
*********************** Multiextruder MKR4 *************************** *********************** Multiextruder MKR4 ***************************
...@@ -646,6 +651,7 @@ your extruder heater takes 2 minutes to hit the target on heating. ...@@ -646,6 +651,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
//When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. //When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec.
//#define FILAMENT_LCD_DISPLAY //#define FILAMENT_LCD_DISPLAY
/**********************************************************************\ /**********************************************************************\
* Support for a current sensor (Hall effect sensor like ACS712) for measure the power consumption * Support for a current sensor (Hall effect sensor like ACS712) for measure the power consumption
* Since it's more simple to deal with, we measure the DC current and we assume that POWER_VOLTAGE that comes from your power supply it's almost stable. * Since it's more simple to deal with, we measure the DC current and we assume that POWER_VOLTAGE that comes from your power supply it's almost stable.
...@@ -653,7 +659,7 @@ your extruder heater takes 2 minutes to hit the target on heating. ...@@ -653,7 +659,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
* With this module we measure the Printer power consumption ignoring the Power Supply power consumption, so we consider the EFFICIENCY of our supply to be 100% so without * With this module we measure the Printer power consumption ignoring the Power Supply power consumption, so we consider the EFFICIENCY of our supply to be 100% so without
* any power dispersion. If you want to approximately add the supply consumption you can decrease the EFFICIENCY to a value less than 100. Eg: 85 is a good value. * any power dispersion. If you want to approximately add the supply consumption you can decrease the EFFICIENCY to a value less than 100. Eg: 85 is a good value.
* You can find a better value measuring the AC current with a good multimeter and moltiple it with the mains voltage. * You can find a better value measuring the AC current with a good multimeter and moltiple it with the mains voltage.
* MULTIMETER_WATT := MULTIMETER_CURRENT*MAINS_VOLTAGE * MULTIMETER_WATT := MULTIMETER_CURRENT * MAINS_VOLTAGE
* Now you have a Wattage value that you can compare with the one measured from ACS712. * Now you have a Wattage value that you can compare with the one measured from ACS712.
* NEW_EFFICENCY := (SENSOR_WATT*EFFICIENCY)/MULTIMETER_WATT * NEW_EFFICENCY := (SENSOR_WATT*EFFICIENCY)/MULTIMETER_WATT
* For now this feature is to be consider BETA as i'll have to do some accurate test to see the affidability * For now this feature is to be consider BETA as i'll have to do some accurate test to see the affidability
...@@ -668,6 +674,7 @@ your extruder heater takes 2 minutes to hit the target on heating. ...@@ -668,6 +674,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
//When using an LCD, uncomment the line below to display the Power consumption sensor data on the last line instead of status. Status will appear for 5 sec. //When using an LCD, uncomment the line below to display the Power consumption sensor data on the last line instead of status. Status will appear for 5 sec.
//#define POWER_CONSUMPTION_LCD_DISPLAY //#define POWER_CONSUMPTION_LCD_DISPLAY
//=================================== Misc ================================= //=================================== Misc =================================
// Temperature status LEDs that display the hotend and bet temperature. // Temperature status LEDs that display the hotend and bet temperature.
......
...@@ -44,35 +44,15 @@ ...@@ -44,35 +44,15 @@
//The M105 command return, besides traditional information, the ADC value read from temperature sensors. //The M105 command return, besides traditional information, the ADC value read from temperature sensors.
//#define SHOW_TEMP_ADC_VALUES //#define SHOW_TEMP_ADC_VALUES
// extruder idle oozing prevention
//if the extruder motor is idle for more than SECONDS, and the temperature over MINTEMP, some filament is retracted. The filament retracted is re-added before the next extrusion
//#define IDLE_OOZING_PREVENT
#define IDLE_OOZING_MINTEMP 170
#define IDLE_OOZING_FEEDRATE 45 //default feedrate for retracting (mm/s)
#define IDLE_OOZING_SECONDS 10
#define IDLE_OOZING_LENGTH 15 //default retract length (positive mm)
#define IDLE_OOZING_RECOVER_LENGTH 0 //default additional recover length (mm, added to retract length when recovering)
#define IDLE_OOZING_RECOVER_FEEDRATE 50 //default feedrate for recovering from retraction (mm/s)
#if defined(IDLE_OOZING_PREVENT) && IDLE_OOZING_MINTEMP < EXTRUDE_MINTEMP
#error IDLE_OOZING_MINTEMP have to be greater than EXTRUDE_MINTEMP
#endif
// extruder run-out prevention. // extruder run-out prevention.
//if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded //if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded
//#define EXTRUDER_RUNOUT_PREVENT //#define EXTRUDER_RUNOUT_PREVENT
#define EXTRUDER_RUNOUT_MINTEMP 190 #define EXTRUDER_RUNOUT_MINTEMP 190
#define EXTRUDER_RUNOUT_SECONDS 30 #define EXTRUDER_RUNOUT_SECONDS 30.
#define EXTRUDER_RUNOUT_ESTEPS 14 //mm filament #define EXTRUDER_RUNOUT_ESTEPS 14. //mm filament
#define EXTRUDER_RUNOUT_SPEED 1500 //extrusion speed #define EXTRUDER_RUNOUT_SPEED 1500. //extrusion speed
#define EXTRUDER_RUNOUT_EXTRUDE 100 #define EXTRUDER_RUNOUT_EXTRUDE 100
#if defined(EXTRUDER_RUNOUT_PREVENT) && EXTRUDER_RUNOUT_MINTEMP < EXTRUDE_MINTEMP
#error EXTRUDER_RUNOUT_MINTEMP have to be greater than EXTRUDE_MINTEMP
#endif
#if defined(EXTRUDER_RUNOUT_PREVENT) && defined(IDLE_OOZING_PREVENT)
#error EXTRUDER_RUNOUT_PREVENT and IDLE_OOZING_PREVENT are incopatible. Please comment one of them.
#endif
//These defines help to calibrate the AD595 sensor in case you get wrong temperature measurements. //These defines help to calibrate the AD595 sensor in case you get wrong temperature measurements.
//The measured temperature is defined as "actualTemp = (measuredTemp * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET" //The measured temperature is defined as "actualTemp = (measuredTemp * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET"
#define TEMP_SENSOR_AD595_OFFSET 0.0 #define TEMP_SENSOR_AD595_OFFSET 0.0
...@@ -486,6 +466,12 @@ const unsigned int dropsegments=5; //everything with less than this number of st ...@@ -486,6 +466,12 @@ const unsigned int dropsegments=5; //everything with less than this number of st
#endif #endif
#endif #endif
#ifdef FILAMENTCHANGEENABLE
#ifdef EXTRUDER_RUNOUT_PREVENT
#error EXTRUDER_RUNOUT_PREVENT currently incompatible with FILAMENTCHANGE
#endif
#endif
/******************************************************************************\ /******************************************************************************\
* enable this section if you have TMC26X motor drivers. * enable this section if you have TMC26X motor drivers.
......
...@@ -314,6 +314,7 @@ extern unsigned char fanSpeedSoftPwm; ...@@ -314,6 +314,7 @@ extern unsigned char fanSpeedSoftPwm;
extern unsigned int power_consumption_meas; //holds the power consumption as accurately measured extern unsigned int power_consumption_meas; //holds the power consumption as accurately measured
extern unsigned long power_consumption_hour; //holds the power consumption per hour as accurately measured extern unsigned long power_consumption_hour; //holds the power consumption per hour as accurately measured
#endif #endif
#ifdef FWRETRACT #ifdef FWRETRACT
extern bool autoretract_enabled; extern bool autoretract_enabled;
extern bool retracted[EXTRUDERS]; extern bool retracted[EXTRUDERS];
......
...@@ -336,23 +336,6 @@ uint8_t debugLevel = 0; ...@@ -336,23 +336,6 @@ uint8_t debugLevel = 0;
#ifdef FILAMENTCHANGEENABLE #ifdef FILAMENTCHANGEENABLE
bool filament_changing = false; bool filament_changing = false;
#endif #endif
#ifdef IDLE_OOZING_PREVENT || EXTRUDER_RUNOUT_PREVENT
unsigned long axis_last_activity = 0;
bool axis_is_moving = false;
#endif
#ifdef IDLE_OOZING_PREVENT
bool IDLE_OOZING_retracted[EXTRUDERS] = { false
#if EXTRUDERS > 1
, false
#if EXTRUDERS > 2
, false
#if EXTRUDERS > 3
, false
#endif
#endif
#endif
};
#endif
#ifdef FWRETRACT #ifdef FWRETRACT
bool autoretract_enabled = false; bool autoretract_enabled = false;
...@@ -1958,40 +1941,6 @@ bool extruder_duplication_enabled = false; // used in mode 2 ...@@ -1958,40 +1941,6 @@ bool extruder_duplication_enabled = false; // used in mode 2
void refresh_cmd_timeout(void) { previous_millis_cmd = millis(); } void refresh_cmd_timeout(void) { previous_millis_cmd = millis(); }
#ifdef IDLE_OOZING_PREVENT
void IDLE_OOZING_retract(bool retracting)
{
if(retracting && !IDLE_OOZING_retracted[active_extruder]) {
//SERIAL_ECHOLN("RETRACT FOR OOZING PREVENT");
destination[X_AXIS]=current_position[X_AXIS];
destination[Y_AXIS]=current_position[Y_AXIS];
destination[Z_AXIS]=current_position[Z_AXIS];
destination[E_AXIS]=current_position[E_AXIS];
current_position[E_AXIS]+=IDLE_OOZING_LENGTH/volumetric_multiplier[active_extruder];
plan_set_e_position(current_position[E_AXIS]);
float oldFeedrate = feedrate;
feedrate=IDLE_OOZING_FEEDRATE*60;
IDLE_OOZING_retracted[active_extruder]=true;
prepare_move();
feedrate = oldFeedrate;
}
else if(!retracting && IDLE_OOZING_retracted[active_extruder]){
//SERIAL_ECHOLN("EXTRUDE FOR OOZING PREVENT");
destination[X_AXIS]=current_position[X_AXIS];
destination[Y_AXIS]=current_position[Y_AXIS];
destination[Z_AXIS]=current_position[Z_AXIS];
destination[E_AXIS]=current_position[E_AXIS];
current_position[E_AXIS]-=(IDLE_OOZING_LENGTH+IDLE_OOZING_RECOVER_LENGTH)/volumetric_multiplier[active_extruder];
plan_set_e_position(current_position[E_AXIS]);
float oldFeedrate = feedrate;
feedrate=IDLE_OOZING_RECOVER_FEEDRATE * 60;
IDLE_OOZING_retracted[active_extruder] = false;
prepare_move();
feedrate = oldFeedrate;
}
}
#endif
#ifdef FWRETRACT #ifdef FWRETRACT
void retract(bool retracting, bool swapretract = false) void retract(bool retracting, bool swapretract = false)
{ {
...@@ -2215,9 +2164,6 @@ inline void wait_bed() { ...@@ -2215,9 +2164,6 @@ inline void wait_bed() {
// G0-G1: Coordinated movement of X Y Z E axes // G0-G1: Coordinated movement of X Y Z E axes
inline void gcode_G0_G1() { inline void gcode_G0_G1() {
if (!Stopped) { if (!Stopped) {
#ifdef IDLE_OOZING_PREVENT
IDLE_OOZING_retract(false);
#endif
get_coordinates(); // For X Y Z E F get_coordinates(); // For X Y Z E F
#ifdef FWRETRACT #ifdef FWRETRACT
if (autoretract_enabled) { if (autoretract_enabled) {
...@@ -2337,6 +2283,11 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2337,6 +2283,11 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
#endif //DELTA #endif //DELTA
#ifdef SCARA
calculate_delta(current_position);
plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
#endif
#if defined(CARTESIAN) || defined(COREXY) || defined(SCARA) #if defined(CARTESIAN) || defined(COREXY) || defined(SCARA)
#if Z_HOME_DIR > 0 // If homing away from BED do Z first #if Z_HOME_DIR > 0 // If homing away from BED do Z first
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) { if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
...@@ -2787,8 +2738,8 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2787,8 +2738,8 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
current_position[Y_AXIS] = uncorrected_position.y; current_position[Y_AXIS] = uncorrected_position.y;
current_position[Z_AXIS] = uncorrected_position.z; current_position[Z_AXIS] = uncorrected_position.z;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
setup_for_endstop_move();
setup_for_endstop_move();
feedrate = homing_feedrate[Z_AXIS]; feedrate = homing_feedrate[Z_AXIS];
#ifdef AUTO_BED_LEVELING_GRID #ifdef AUTO_BED_LEVELING_GRID
...@@ -6184,9 +6135,6 @@ void clamp_to_software_endstops(float target[3]) ...@@ -6184,9 +6135,6 @@ void clamp_to_software_endstops(float target[3])
void prepare_move() void prepare_move()
{ {
#ifdef IDLE_OOZING_PREVENT || EXTRUDER_RUNOUT_PREVENT
axis_is_moving = true;
#endif
clamp_to_software_endstops(destination); clamp_to_software_endstops(destination);
refresh_cmd_timeout(); refresh_cmd_timeout();
...@@ -6206,7 +6154,6 @@ void prepare_move() ...@@ -6206,7 +6154,6 @@ void prepare_move()
return; return;
} }
float seconds = 6000 * cartesian_mm / feedrate / feedmultiply; float seconds = 6000 * cartesian_mm / feedrate / feedmultiply;
int steps = max(1, int(scara_segments_per_second * seconds)); int steps = max(1, int(scara_segments_per_second * seconds));
//SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm); //SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm);
//SERIAL_ECHOPGM(" seconds="); SERIAL_ECHO(seconds); //SERIAL_ECHOPGM(" seconds="); SERIAL_ECHO(seconds);
...@@ -6316,11 +6263,6 @@ void prepare_move() ...@@ -6316,11 +6263,6 @@ void prepare_move()
} }
#endif // !(DELTA || SCARA) #endif // !(DELTA || SCARA)
#ifdef IDLE_OOZING_PREVENT || EXTRUDER_RUNOUT_PREVENT
axis_last_activity = millis();
axis_is_moving = false;
#endif
for(int8_t i=0; i < NUM_AXIS; i++) { for(int8_t i=0; i < NUM_AXIS; i++) {
current_position[i] = destination[i]; current_position[i] = destination[i];
} }
...@@ -6585,11 +6527,6 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s ...@@ -6585,11 +6527,6 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
controllerFan(); //Check if fan should be turned on to cool stepper drivers down controllerFan(); //Check if fan should be turned on to cool stepper drivers down
#endif #endif
#ifdef IDLE_OOZING_PREVENT
if(!debugDryrun() && !axis_is_moving && !filament_changing && (millis() - axis_last_activity) > IDLE_OOZING_SECONDS*1000 && degHotend(active_extruder) > IDLE_OOZING_MINTEMP) {
IDLE_OOZING_retract(true);
}
#endif
#ifdef EXTRUDER_RUNOUT_PREVENT #ifdef EXTRUDER_RUNOUT_PREVENT
if(!debugDryrun() && !axis_is_moving && !filament_changing && (millis() - axis_last_activity) > EXTRUDER_RUNOUT_SECONDS*1000 && degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP) if(!debugDryrun() && !axis_is_moving && !filament_changing && (millis() - axis_last_activity) > EXTRUDER_RUNOUT_SECONDS*1000 && degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP)
{ {
......
...@@ -504,7 +504,6 @@ void CardReader::printingHasFinished() { ...@@ -504,7 +504,6 @@ void CardReader::printingHasFinished() {
startFileprint(); startFileprint();
} }
else { else {
quickStop();
file.close(); file.close();
sdprinting = false; sdprinting = false;
if (SD_FINISHED_STEPPERRELEASE) { if (SD_FINISHED_STEPPERRELEASE) {
......
...@@ -268,9 +268,6 @@ static void lcd_implementation_status_screen() { ...@@ -268,9 +268,6 @@ static void lcd_implementation_status_screen() {
u8g.setFont(FONT_STATUSMENU); u8g.setFont(FONT_STATUSMENU);
u8g.setPrintPos(0,63); u8g.setPrintPos(0,63);
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) || (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY) #if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) || (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY)
if (millis() < message_millis + 5000) { //Display both Status message line and Filament display on the last line if (millis() < message_millis + 5000) { //Display both Status message line and Filament display on the last line
u8g.print(lcd_status_message); u8g.print(lcd_status_message);
} }
......
...@@ -78,12 +78,12 @@ float mintravelfeedrate; ...@@ -78,12 +78,12 @@ float mintravelfeedrate;
unsigned long axis_steps_per_sqr_second[3 + EXTRUDERS]; unsigned long axis_steps_per_sqr_second[3 + EXTRUDERS];
#ifdef ENABLE_AUTO_BED_LEVELING #ifdef ENABLE_AUTO_BED_LEVELING
// this holds the required transform to compensate for bed level // this holds the required transform to compensate for bed level
matrix_3x3 plan_bed_level_matrix = { matrix_3x3 plan_bed_level_matrix = {
1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 1.0 0.0, 0.0, 1.0
}; };
#endif // #ifdef ENABLE_AUTO_BED_LEVELING #endif // #ifdef ENABLE_AUTO_BED_LEVELING
// The current position of the tool in absolute steps // The current position of the tool in absolute steps
...@@ -92,18 +92,18 @@ static float previous_speed[NUM_AXIS]; // Speed of previous path line segment ...@@ -92,18 +92,18 @@ static float previous_speed[NUM_AXIS]; // Speed of previous path line segment
static float previous_nominal_speed; // Nominal speed of previous path line segment static float previous_nominal_speed; // Nominal speed of previous path line segment
#ifdef AUTOTEMP #ifdef AUTOTEMP
float autotemp_max=250; float autotemp_max = 250;
float autotemp_min=210; float autotemp_min = 210;
float autotemp_factor=0.1; float autotemp_factor = 0.1;
bool autotemp_enabled=false; bool autotemp_enabled = false;
#endif #endif
unsigned char g_uc_extruder_last_move[4] = {0,0,0,0}; unsigned char g_uc_extruder_last_move[4] = {0,0,0,0};
//=========================================================================== //===========================================================================
//=================semi-private variables, used in inline functions ===== //=================semi-private variables, used in inline functions =========
//=========================================================================== //===========================================================================
block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions
volatile unsigned char block_buffer_head; // Index of the next block to be pushed volatile unsigned char block_buffer_head; // Index of the next block to be pushed
volatile unsigned char block_buffer_tail; // Index of the block to process now volatile unsigned char block_buffer_tail; // Index of the block to process now
...@@ -111,7 +111,7 @@ volatile unsigned char block_buffer_tail; // Index of the block to pro ...@@ -111,7 +111,7 @@ volatile unsigned char block_buffer_tail; // Index of the block to pro
//=============================private variables ============================ //=============================private variables ============================
//=========================================================================== //===========================================================================
#ifdef PREVENT_DANGEROUS_EXTRUDE #ifdef PREVENT_DANGEROUS_EXTRUDE
float extrude_min_temp=EXTRUDE_MINTEMP; float extrude_min_temp = EXTRUDE_MINTEMP;
#endif #endif
#ifdef XY_FREQUENCY_LIMIT #ifdef XY_FREQUENCY_LIMIT
#define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT) #define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT)
...@@ -151,15 +151,9 @@ static int8_t prev_block_index(int8_t block_index) { ...@@ -151,15 +151,9 @@ static int8_t prev_block_index(int8_t block_index) {
// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the // Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the
// given acceleration: // given acceleration:
FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) {
{ if (acceleration == 0) return 0; // acceleration was 0, set acceleration distance to 0
if (acceleration!=0) { return (target_rate * target_rate - initial_rate * initial_rate) / (acceleration * 2);
return((target_rate*target_rate-initial_rate*initial_rate)/
(2.0*acceleration));
}
else {
return 0.0; // acceleration was 0, set acceleration distance to 0
}
} }
// This function gives you the point at which you must start braking (at the rate of -acceleration) if // This function gives you the point at which you must start braking (at the rate of -acceleration) if
...@@ -167,54 +161,42 @@ FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float targ ...@@ -167,54 +161,42 @@ FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float targ
// a total travel of distance. This can be used to compute the intersection point between acceleration and // a total travel of distance. This can be used to compute the intersection point between acceleration and
// deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed) // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed)
FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) {
{ if (acceleration == 0) return 0; // acceleration was 0, set intersection distance to 0
if (acceleration!=0) { return (acceleration * 2 * distance - initial_rate * initial_rate + final_rate * final_rate) / (acceleration * 4);
return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/
(4.0*acceleration) );
}
else {
return 0.0; // acceleration was 0, set intersection distance to 0
}
} }
// Calculates trapezoid parameters so that the entry- and exit-speed is compensated by the provided factors. // Calculates trapezoid parameters so that the entry- and exit-speed is compensated by the provided factors.
void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exit_factor) { void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exit_factor) {
unsigned long initial_rate = ceil(block->nominal_rate*entry_factor); // (step/min) unsigned long initial_rate = ceil(block->nominal_rate * entry_factor); // (step/min)
unsigned long final_rate = ceil(block->nominal_rate*exit_factor); // (step/min) unsigned long final_rate = ceil(block->nominal_rate * exit_factor); // (step/min)
// Limit minimal step rate (Otherwise the timer will overflow.) // Limit minimal step rate (Otherwise the timer will overflow.)
if(initial_rate <120) { if (initial_rate < 120) initial_rate = 120;
initial_rate=120; if (final_rate < 120) final_rate = 120;
}
if(final_rate < 120) {
final_rate=120;
}
long acceleration = block->acceleration_st; long acceleration = block->acceleration_st;
int32_t accelerate_steps = int32_t accelerate_steps = ceil(estimate_acceleration_distance(initial_rate, block->nominal_rate, acceleration));
ceil(estimate_acceleration_distance(initial_rate, block->nominal_rate, acceleration)); int32_t decelerate_steps = floor(estimate_acceleration_distance(block->nominal_rate, final_rate, -acceleration));
int32_t decelerate_steps =
floor(estimate_acceleration_distance(block->nominal_rate, final_rate, -acceleration));
// Calculate the size of Plateau of Nominal Rate. // Calculate the size of Plateau of Nominal Rate.
int32_t plateau_steps = block->step_event_count-accelerate_steps-decelerate_steps; int32_t plateau_steps = block->step_event_count - accelerate_steps - decelerate_steps;
// Is the Plateau of Nominal Rate smaller than nothing? That means no cruising, and we will // Is the Plateau of Nominal Rate smaller than nothing? That means no cruising, and we will
// have to use intersection_distance() to calculate when to abort acceleration and start braking // have to use intersection_distance() to calculate when to abort acceleration and start braking
// in order to reach the final_rate exactly at the end of this block. // in order to reach the final_rate exactly at the end of this block.
if (plateau_steps < 0) { if (plateau_steps < 0) {
accelerate_steps = ceil(intersection_distance(initial_rate, final_rate, acceleration, block->step_event_count)); accelerate_steps = ceil(intersection_distance(initial_rate, final_rate, acceleration, block->step_event_count));
accelerate_steps = max(accelerate_steps,0); // Check limits due to numerical round-off accelerate_steps = max(accelerate_steps, 0); // Check limits due to numerical round-off
accelerate_steps = min((uint32_t)accelerate_steps,block->step_event_count);//(We can cast here to unsigned, because the above line ensures that we are above zero) accelerate_steps = min((uint32_t)accelerate_steps, block->step_event_count);//(We can cast here to unsigned, because the above line ensures that we are above zero)
plateau_steps = 0; plateau_steps = 0;
} }
#ifdef ADVANCE #ifdef ADVANCE
volatile long initial_advance = block->advance*entry_factor*entry_factor; volatile long initial_advance = block->advance * entry_factor * entry_factor;
volatile long final_advance = block->advance*exit_factor*exit_factor; volatile long final_advance = block->advance * exit_factor * exit_factor;
#endif // ADVANCE #endif // ADVANCE
// block->accelerate_until = accelerate_steps; // block->accelerate_until = accelerate_steps;
// block->decelerate_after = accelerate_steps+plateau_steps; // block->decelerate_after = accelerate_steps+plateau_steps;
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
#ifdef PID_dT #ifdef PID_dT
#undef PID_dT #undef PID_dT
#endif #endif
#define PID_dT ((OVERSAMPLENR * 12.0)/(F_CPU / 64.0 / 256.0)) #define PID_dT ((OVERSAMPLENR * 14.0)/(F_CPU / 64.0 / 256.0))
#ifndef SINGLENOZZLE #ifndef SINGLENOZZLE
int target_temperature[EXTRUDERS] = { 0 }; int target_temperature[EXTRUDERS] = { 0 };
...@@ -133,6 +133,7 @@ unsigned char soft_pwm_bed; ...@@ -133,6 +133,7 @@ unsigned char soft_pwm_bed;
#if HAS_POWER_CONSUMPTION_SENSOR #if HAS_POWER_CONSUMPTION_SENSOR
int current_raw_powconsumption = 0; //Holds measured power consumption int current_raw_powconsumption = 0; //Holds measured power consumption
#endif #endif
//=========================================================================== //===========================================================================
//=============================private variables============================ //=============================private variables============================
//=========================================================================== //===========================================================================
...@@ -858,7 +859,7 @@ static float analog2temp(int raw, uint8_t e) { ...@@ -858,7 +859,7 @@ static float analog2temp(int raw, uint8_t e) {
return celsius; return celsius;
} }
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET; return ((raw * ((5.0 * 100) / 1024) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
} }
// Derived from RepRap FiveD extruder::getTemperature() // Derived from RepRap FiveD extruder::getTemperature()
...@@ -885,7 +886,7 @@ static float analog2tempBed(int raw) { ...@@ -885,7 +886,7 @@ static float analog2tempBed(int raw) {
return celsius; return celsius;
#elif defined BED_USES_AD595 #elif defined BED_USES_AD595
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET; return ((raw * ((5.0 * 100) / 1024) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
#else //NO BED_USES_THERMISTOR #else //NO BED_USES_THERMISTOR
return 0; return 0;
#endif //BED_USES_THERMISTOR #endif //BED_USES_THERMISTOR
...@@ -936,10 +937,9 @@ static void updateTemperaturesFromRawValues() { ...@@ -936,10 +937,9 @@ static void updateTemperaturesFromRawValues() {
#if HAS_FILAMENT_SENSOR #if HAS_FILAMENT_SENSOR
// Convert raw Filament Width to millimeters // Convert raw Filament Width to millimeters
float analog2widthFil() { float analog2widthFil() {
return current_raw_filwidth / (1023.0 * OVERSAMPLENR) * 5.0; return current_raw_filwidth / (1024 * OVERSAMPLENR) * 5.0;
//return current_raw_filwidth; //return current_raw_filwidth;
} }
...@@ -954,12 +954,10 @@ static void updateTemperaturesFromRawValues() { ...@@ -954,12 +954,10 @@ static void updateTemperaturesFromRawValues() {
#endif #endif
#if HAS_POWER_CONSUMPTION_SENSOR #if HAS_POWER_CONSUMPTION_SENSOR
// Convert raw Power Consumption to watt // Convert raw Power Consumption to watt
float analog2power() { float analog2power() {
return (((((5.0 * current_raw_powconsumption) / (1023.0 * OVERSAMPLENR)) - POWER_ZERO) * (POWER_VOLTAGE * 100.0)) / (POWER_SENSITIVITY * POWER_EFFICIENCY)); return (((((5.0 * current_raw_powconsumption) / (1024.0 * OVERSAMPLENR)) - POWER_ZERO) * (POWER_VOLTAGE * 100.0)) / (POWER_SENSITIVITY * POWER_EFFICIENCY));
} }
#endif #endif
void tp_init() void tp_init()
...@@ -1657,7 +1655,7 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1657,7 +1655,7 @@ ISR(TIMER0_COMPB_vect) {
#if HAS_POWER_CONSUMPTION_SENSOR #if HAS_POWER_CONSUMPTION_SENSOR
// raw_powconsumption_value += ADC; //remove to use an IIR filter approach // raw_powconsumption_value += ADC; //remove to use an IIR filter approach
raw_powconsumption_value -= (raw_powconsumption_value>>7); //multiply raw_powconsumption_value by 127/128 raw_powconsumption_value -= (raw_powconsumption_value>>7); //multiply raw_powconsumption_value by 127/128
raw_powconsumption_value += ((unsigned long)((ADC < (POWER_ZERO*1023)/5.0) ? (1023 - ADC) : (ADC))<<7); //add new ADC reading raw_powconsumption_value += ((unsigned long)((ADC < (POWER_ZERO*1024)/5.0) ? (1024 - ADC) : (ADC))<<7); //add new ADC reading
#endif #endif
temp_state = PrepareTemp_0; temp_state = PrepareTemp_0;
temp_count++; temp_count++;
......
...@@ -31,15 +31,15 @@ void tp_init(); //initialize the heating ...@@ -31,15 +31,15 @@ void tp_init(); //initialize the heating
void manage_heater(); //it is critical that this is called periodically. void manage_heater(); //it is critical that this is called periodically.
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) #if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0)
// For converting raw Filament Width to milimeters // For converting raw Filament Width to milimeters
float analog2widthFil(); float analog2widthFil();
// For converting raw Filament Width to an extrusion ratio // For converting raw Filament Width to an extrusion ratio
int widthFil_to_size_ratio(); int widthFil_to_size_ratio();
#endif #endif
#if (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) #if (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0)
// For converting raw Power Consumption to watt // For converting raw Power Consumption to watt
float analog2power(); float analog2power();
#endif #endif
......
...@@ -310,15 +310,11 @@ static void lcd_status_screen() ...@@ -310,15 +310,11 @@ static void lcd_status_screen()
lcd_implementation_status_screen(); lcd_implementation_status_screen();
lcd_status_update_delay = 10; /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */ lcd_status_update_delay = 10; /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */
} }
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) || (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY) #if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) || (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY)
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) && (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY) if (millis() > message_millis + 15000) message_millis = millis();
if (millis() > message_millis + 15000)
#else #else
if (millis() > message_millis + 10000) if (millis() > message_millis + 10000) message_millis = millis();
#endif
{
message_millis = millis();
}
#endif #endif
#ifdef ULTIPANEL #ifdef ULTIPANEL
...@@ -693,12 +689,13 @@ void config_lcd_level_bed() ...@@ -693,12 +689,13 @@ void config_lcd_level_bed()
void lcd_level_bed() void lcd_level_bed()
{ {
if(ChangeScreen){ if(ChangeScreen) {
switch(pageShowInfo){ lcd.clear();
switch(pageShowInfo) {
case 0: case 0:
{ {
u8g.setPrintPos(0, 1); lcd.setCursor(0, 1);
lcd_printPGM(PSTR(MSG_LP_INTRO)); lcd_printPGM(PSTR(MSG_LP_INTRO));
currentMenu = lcd_level_bed; currentMenu = lcd_level_bed;
ChangeScreen=false; ChangeScreen=false;
...@@ -707,7 +704,7 @@ void lcd_level_bed() ...@@ -707,7 +704,7 @@ void lcd_level_bed()
case 1: case 1:
{ {
u8g.setPrintPos(0, 1); lcd.setCursor(0, 1);
lcd_printPGM(PSTR(MSG_LP_1)); lcd_printPGM(PSTR(MSG_LP_1));
currentMenu = lcd_level_bed; currentMenu = lcd_level_bed;
ChangeScreen=false; ChangeScreen=false;
...@@ -716,7 +713,7 @@ void lcd_level_bed() ...@@ -716,7 +713,7 @@ void lcd_level_bed()
break; break;
case 2: case 2:
{ {
u8g.setPrintPos(0, 1); lcd.setCursor(0, 1);
lcd_printPGM(PSTR(MSG_LP_2)); lcd_printPGM(PSTR(MSG_LP_2));
currentMenu = lcd_level_bed; currentMenu = lcd_level_bed;
ChangeScreen=false; ChangeScreen=false;
...@@ -725,7 +722,7 @@ void lcd_level_bed() ...@@ -725,7 +722,7 @@ void lcd_level_bed()
break; break;
case 3: case 3:
{ {
u8g.setPrintPos(0, 1); lcd.setCursor(0, 1);
lcd_printPGM(PSTR(MSG_LP_3)); lcd_printPGM(PSTR(MSG_LP_3));
currentMenu = lcd_level_bed; currentMenu = lcd_level_bed;
ChangeScreen=false; ChangeScreen=false;
...@@ -734,7 +731,7 @@ void lcd_level_bed() ...@@ -734,7 +731,7 @@ void lcd_level_bed()
break; break;
case 4: case 4:
{ {
u8g.setPrintPos(0, 1); lcd.setCursor(0, 1);
lcd_printPGM(PSTR(MSG_LP_4)); lcd_printPGM(PSTR(MSG_LP_4));
currentMenu = lcd_level_bed; currentMenu = lcd_level_bed;
ChangeScreen=false; ChangeScreen=false;
...@@ -744,7 +741,7 @@ void lcd_level_bed() ...@@ -744,7 +741,7 @@ void lcd_level_bed()
case 5: case 5:
{ {
u8g.setPrintPos(0, 1); lcd.setCursor(0, 1);
lcd_printPGM(PSTR(MSG_LP_5)); lcd_printPGM(PSTR(MSG_LP_5));
currentMenu = lcd_level_bed; currentMenu = lcd_level_bed;
ChangeScreen=false; ChangeScreen=false;
...@@ -754,13 +751,14 @@ void lcd_level_bed() ...@@ -754,13 +751,14 @@ void lcd_level_bed()
case 6: case 6:
{ {
u8g.setPrintPos(2, 2); lcd.setCursor(2, 2);
lcd_printPGM(PSTR(MSG_LP_6)); lcd_printPGM(PSTR(MSG_LP_6));
ChangeScreen=false; ChangeScreen=false;
delay(1200); delay(1200);
encoderPosition = 0; encoderPosition = 0;
lcd.clear();
currentMenu = lcd_status_screen; currentMenu = lcd_status_screen;
lcd_status_screen(); lcd_status_screen();
pageShowInfo=0; pageShowInfo=0;
......
...@@ -380,35 +380,32 @@ static void lcd_set_custom_characters( ...@@ -380,35 +380,32 @@ static void lcd_set_custom_characters(
#endif #endif
} }
static void lcd_implementation_init( static void lcd_implementation_init (
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
bool progress_bar_set=true bool progress_bar_set = true
#endif #endif
) { ){
#if defined(LCD_I2C_TYPE_PCF8575) #if defined(LCD_I2C_TYPE_PCF8575)
lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.begin(LCD_WIDTH, LCD_HEIGHT);
#ifdef LCD_I2C_PIN_BL #ifdef LCD_I2C_PIN_BL
lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE);
lcd.setBacklight(HIGH); lcd.setBacklight(HIGH);
#endif #endif
#elif defined(LCD_I2C_TYPE_MCP23017) #elif defined(LCD_I2C_TYPE_MCP23017)
lcd.setMCPType(LTI_TYPE_MCP23017); lcd.setMCPType(LTI_TYPE_MCP23017);
lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.begin(LCD_WIDTH, LCD_HEIGHT);
lcd.setBacklight(0); //set all the LEDs off to begin with lcd.setBacklight(0); //set all the LEDs off to begin with
#elif defined(LCD_I2C_TYPE_MCP23008)
#elif defined(LCD_I2C_TYPE_MCP23008)
lcd.setMCPType(LTI_TYPE_MCP23008); lcd.setMCPType(LTI_TYPE_MCP23008);
lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.begin(LCD_WIDTH, LCD_HEIGHT);
#elif defined(LCD_I2C_TYPE_PCA8574)
#elif defined(LCD_I2C_TYPE_PCA8574)
lcd.init(); lcd.init();
lcd.backlight(); lcd.backlight();
#else
#else
lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.begin(LCD_WIDTH, LCD_HEIGHT);
#endif #endif
lcd_set_custom_characters( lcd_set_custom_characters(
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
...@@ -418,19 +415,20 @@ static void lcd_implementation_init( ...@@ -418,19 +415,20 @@ static void lcd_implementation_init(
lcd.clear(); lcd.clear();
} }
static void lcd_implementation_clear()
{ static void lcd_implementation_clear() {
lcd.clear(); lcd.clear();
} }
/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */ /* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */
static void lcd_printPGM(const char* str) static void lcd_printPGM(const char* str) {
{
char c; char c;
while((c = pgm_read_byte(str++)) != '\0') while((c = pgm_read_byte(str++)) != '\0')
{ {
lcd.write(c); lcd.write(c);
} }
} }
/* /*
Possible status screens: Possible status screens:
16x2 |0123456789012345| 16x2 |0123456789012345|
...@@ -459,64 +457,62 @@ Possible status screens: ...@@ -459,64 +457,62 @@ Possible status screens:
|F100% SD100% T--:--| |F100% SD100% T--:--|
|Status line.........| |Status line.........|
*/ */
static void lcd_implementation_status_screen()
{ static void lcd_implementation_status_screen() {
int tHotend=int(degHotend(0) + 0.5); int tHotend=int(degHotend(0) + 0.5);
int tTarget=int(degTargetHotend(0) + 0.5); int tTarget=int(degTargetHotend(0) + 0.5);
#if LCD_WIDTH < 20 #if LCD_WIDTH < 20
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(itostr3(tHotend)); lcd.print(itostr3(tHotend));
lcd.print('/'); lcd.print('/');
lcd.print(itostr3left(tTarget)); lcd.print(itostr3left(tTarget));
# if (EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0 #if (EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0
//If we have an 2nd extruder or heated bed, show that in the top right corner //If we have an 2nd extruder or heated bed, show that in the top right corner
lcd.setCursor(8, 0); lcd.setCursor(8, 0);
# if EXTRUDERS > 1 && !defined(SINGLENOZZLE) #if EXTRUDERS > 1 && !defined(SINGLENOZZLE)
tHotend = int(degHotend(1) + 0.5); tHotend = int(degHotend(1) + 0.5);
tTarget = int(degTargetHotend(1) + 0.5); tTarget = int(degTargetHotend(1) + 0.5);
lcd.print(LCD_STR_THERMOMETER[0]); lcd.print(LCD_STR_THERMOMETER[0]);
# else//Heated bed #else//Heated bed
tHotend=int(degBed() + 0.5); tHotend=int(degBed() + 0.5);
tTarget=int(degTargetBed() + 0.5); tTarget=int(degTargetBed() + 0.5);
lcd.print(LCD_STR_BEDTEMP[0]); lcd.print(LCD_STR_BEDTEMP[0]);
# endif #endif
lcd.print(itostr3(tHotend)); lcd.print(itostr3(tHotend));
lcd.print('/'); lcd.print('/');
lcd.print(itostr3left(tTarget)); lcd.print(itostr3left(tTarget));
# endif (EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0 #endif //(EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0
#else//LCD_WIDTH > 19 #else//LCD_WIDTH > 19
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(LCD_STR_THERMOMETER[0]); lcd.print(LCD_STR_THERMOMETER[0]);
lcd.print(itostr3(tHotend)); lcd.print(itostr3(tHotend));
lcd.print('/'); lcd.print('/');
lcd.print(itostr3left(tTarget)); lcd.print(itostr3left(tTarget));
lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
if (tTarget < 10) if (tTarget < 10) lcd.print(' ');
lcd.print(' ');
# if (EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0 #if (EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0
//If we have an 2nd extruder or heated bed, show that in the top right corner //If we have an 2nd extruder or heated bed, show that in the top right corner
lcd.setCursor(10, 0); lcd.setCursor(10, 0);
# if EXTRUDERS > 1 && !defined(SINGLENOZZLE) #if EXTRUDERS > 1 && !defined(SINGLENOZZLE)
tHotend = int(degHotend(1) + 0.5); tHotend = int(degHotend(1) + 0.5);
tTarget = int(degTargetHotend(1) + 0.5); tTarget = int(degTargetHotend(1) + 0.5);
lcd.print(LCD_STR_THERMOMETER[0]); lcd.print(LCD_STR_THERMOMETER[0]);
# else//Heated bed #else//Heated bed
tHotend=int(degBed() + 0.5); tHotend=int(degBed() + 0.5);
tTarget=int(degTargetBed() + 0.5); tTarget=int(degTargetBed() + 0.5);
lcd.print(LCD_STR_BEDTEMP[0]); lcd.print(LCD_STR_BEDTEMP[0]);
# endif #endif
lcd.print(itostr3(tHotend)); lcd.print(itostr3(tHotend));
lcd.print('/'); lcd.print('/');
lcd.print(itostr3left(tTarget)); lcd.print(itostr3left(tTarget));
lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
if (tTarget < 10) if (tTarget < 10) lcd.print(' ');
lcd.print(' '); #endif//(EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0
# endif//(EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0 #endif//LCD_WIDTH > 19
#endif//LCD_WIDTH > 19
#if LCD_HEIGHT > 2 #if LCD_HEIGHT > 2
//Lines 2 for 4 line LCD //Lines 2 for 4 line LCD
...@@ -597,7 +593,6 @@ static void lcd_implementation_status_screen() ...@@ -597,7 +593,6 @@ static void lcd_implementation_status_screen()
lcd.setCursor(0, LCD_HEIGHT - 1); lcd.setCursor(0, LCD_HEIGHT - 1);
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
if (card.isFileOpen()) { if (card.isFileOpen()) {
uint16_t mil = millis(), diff = mil - progressBarTick; uint16_t mil = millis(), diff = mil - progressBarTick;
if (diff >= PROGRESS_BAR_MSG_TIME || !lcd_status_message[0]) { if (diff >= PROGRESS_BAR_MSG_TIME || !lcd_status_message[0]) {
...@@ -644,9 +639,9 @@ static void lcd_implementation_status_screen() ...@@ -644,9 +639,9 @@ static void lcd_implementation_status_screen()
lcd_printPGM(PSTR("D:")); lcd_printPGM(PSTR("D:"));
lcd.print(ftostr12ns(filament_width_meas)); lcd.print(ftostr12ns(filament_width_meas));
lcd_printPGM(PSTR("mm F:")); lcd_printPGM(PSTR("mm F:"));
lcd.print(itostr3(100.0*volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM])); lcd.print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
lcd.print('%'); lcd.print('%');
return;
} }
#else #else
lcd.print(lcd_status_message); lcd.print(lcd_status_message);
...@@ -667,6 +662,7 @@ static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const cha ...@@ -667,6 +662,7 @@ static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const cha
lcd.print(post_char); lcd.print(post_char);
lcd.print(' '); lcd.print(' ');
} }
static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char* data) { static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char* data) {
char c; char c;
uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2) - lcd_strlen(data); uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2) - lcd_strlen(data);
...@@ -681,6 +677,7 @@ static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t r ...@@ -681,6 +677,7 @@ static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t r
while (n--) lcd.print(' '); while (n--) lcd.print(' ');
lcd.print(data); lcd.print(data);
} }
static void lcd_implementation_drawmenu_setting_edit_generic_P(bool sel, uint8_t row, const char* pstr, char pre_char, const char* data) { static void lcd_implementation_drawmenu_setting_edit_generic_P(bool sel, uint8_t row, const char* pstr, char pre_char, const char* data) {
char c; char c;
uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2) - lcd_strlen_P(data); uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2) - lcd_strlen_P(data);
...@@ -695,6 +692,7 @@ static void lcd_implementation_drawmenu_setting_edit_generic_P(bool sel, uint8_t ...@@ -695,6 +692,7 @@ static void lcd_implementation_drawmenu_setting_edit_generic_P(bool sel, uint8_t
while (n--) lcd.print(' '); while (n--) lcd.print(' ');
lcd_printPGM(data); lcd_printPGM(data);
} }
#define lcd_implementation_drawmenu_setting_edit_int3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', itostr3(*(data))) #define lcd_implementation_drawmenu_setting_edit_int3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', itostr3(*(data)))
#define lcd_implementation_drawmenu_setting_edit_float3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr3(*(data))) #define lcd_implementation_drawmenu_setting_edit_float3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr3(*(data)))
#define lcd_implementation_drawmenu_setting_edit_float32(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr32(*(data))) #define lcd_implementation_drawmenu_setting_edit_float32(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr32(*(data)))
...@@ -723,6 +721,7 @@ void lcd_implementation_drawedit(const char* pstr, char* value) { ...@@ -723,6 +721,7 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
lcd.setCursor(LCD_WIDTH - (LCD_WIDTH < 20 ? 0 : 1) - lcd_strlen(value), 1); lcd.setCursor(LCD_WIDTH - (LCD_WIDTH < 20 ? 0 : 1) - lcd_strlen(value), 1);
lcd.print(value); lcd.print(value);
} }
static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename, uint8_t concat) { static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename, uint8_t concat) {
char c; char c;
uint8_t n = LCD_WIDTH - concat; uint8_t n = LCD_WIDTH - concat;
...@@ -743,9 +742,11 @@ static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* ps ...@@ -743,9 +742,11 @@ static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* ps
static void lcd_implementation_drawmenu_sdfile(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) { static void lcd_implementation_drawmenu_sdfile(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 1); lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 1);
} }
static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) { static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 2); lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 2);
} }
#define lcd_implementation_drawmenu_back(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]) #define lcd_implementation_drawmenu_back(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]) #define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ') #define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment