Commit eb09f322 authored by MagoKimbra's avatar MagoKimbra

Add progress bar & Bowden easy load

parent 678d4f90
...@@ -3,10 +3,12 @@ ...@@ -3,10 +3,12 @@
#include "boards.h" #include "boards.h"
// This configuration file contains the basic settings.
// Advanced settings can be found in Configuration_adv.h
// User-specified version info of this build to display in [Pronterface, etc] terminal window during // User-specified version info of this build to display in [Pronterface, etc] terminal window during
// startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
// build by the user have been successfully uploaded into firmware. // build by the user have been successfully uploaded into firmware.
#define STRING_VERSION_CONFIG_H __DATE__ " 21/12/2014 " __TIME__ // build date and time #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time
#define STRING_CONFIG_H_AUTHOR "(MagoKimbra: magokimbra@hotmail.com, Version 4.0)" // Who made the changes. #define STRING_CONFIG_H_AUTHOR "(MagoKimbra: magokimbra@hotmail.com, Version 4.0)" // Who made the changes.
// SERIAL_PORT selects which serial port should be used for communication with the host. // SERIAL_PORT selects which serial port should be used for communication with the host.
...@@ -188,21 +190,20 @@ ...@@ -188,21 +190,20 @@
// Comment the following line to disable PID and enable bang-bang. // Comment the following line to disable PID and enable bang-bang.
#define PIDTEMP #define PIDTEMP
#define BANG_MAX 255 // limits current to nozzle while in bang-bang mode; 255=full current #define BANG_MAX 255 // limits current to nozzle while in bang-bang mode; 255=full current
#define PID_MAX 255 // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current #define PID_MAX BANG_MAX // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
#ifdef PIDTEMP #ifdef PIDTEMP
//#define PID_DEBUG // Sends debug data to the serial port. //#define PID_DEBUG // Sends debug data to the serial port.
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX //#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
#define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
// is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. // is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
#define PID_INTEGRAL_DRIVE_MAX 255 //limit for the integral term #define PID_INTEGRAL_DRIVE_MAX PID_MAX //limit for the integral term
#define K1 0.95 //smoothing factor within the PID #define K1 0.95 //smoothing factor within the PID
#define PID_dT ((OVERSAMPLENR * 10.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the temperature routine #define PID_dT ((OVERSAMPLENR * 10.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the temperature routine
// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
// HotEnd{HE0,HE1,HE2,HE3} // HotEnd{HE0,HE1,HE2,HE3}
#define DEFAULT_Kp {40,41,41,41} // Kp for E0, E1, E2, E3 #define DEFAULT_Kp {40,41,41,41} // Kp for E0, E1, E2, E3
#define DEFAULT_Ki {7,7,7,7} // Ki for E0, E1, E2, E3 #define DEFAULT_Ki {7,7,7,7} // Ki for E0, E1, E2, E3
#define DEFAULT_Kd {59,59,59,59} // Kd for E0, E1, E2, E3 #define DEFAULT_Kd {59,59,59,59} // Kd for E0, E1, E2, E3
#endif // PIDTEMP #endif // PIDTEMP
...@@ -229,9 +230,9 @@ ...@@ -229,9 +230,9 @@
#ifdef PIDTEMPBED #ifdef PIDTEMPBED
//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
#define DEFAULT_bedKp 10.00 #define DEFAULT_bedKp 10.00
#define DEFAULT_bedKi .023 #define DEFAULT_bedKi .023
#define DEFAULT_bedKd 305.4 #define DEFAULT_bedKd 305.4
//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
//from pidautotune //from pidautotune
...@@ -427,10 +428,12 @@ ...@@ -427,10 +428,12 @@
// --------------------- // ---------------------
// 2 wire Non-latching LCD SR from: // 2 wire Non-latching LCD SR from:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection // https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
//#define SR_LCD
#ifdef SR_LCD //#define SAV_3DLCD
#define SR_LCD_2W_NL // Non latching 2 wire shift register #ifdef SAV_3DLCD
//#define NEWPANEL #define SR_LCD_2W_NL // Non latching 2 wire shiftregister
#define NEWPANEL
#define ULTIPANEL
#endif #endif
...@@ -459,9 +462,9 @@ ...@@ -459,9 +462,9 @@
// default LCD contrast for dogm-like LCD displays // default LCD contrast for dogm-like LCD displays
#ifdef DOGLCD #ifdef DOGLCD
# ifndef DEFAULT_LCD_CONTRAST #ifndef DEFAULT_LCD_CONTRAST
# define DEFAULT_LCD_CONTRAST 32 #define DEFAULT_LCD_CONTRAST 32
# endif #endif
#endif #endif
// option for invert rotary switch // option for invert rotary switch
...@@ -500,6 +503,32 @@ ...@@ -500,6 +503,32 @@
// please keep turned on if you can. // please keep turned on if you can.
//#define EEPROM_CHITCHAT //#define EEPROM_CHITCHAT
//Bowden Filament management
//#define EASY_LOAD
#ifdef EASY_LOAD
#define BOWDEN_LENGTH 560 // mm
#define LCD_PURGE_LENGTH 3 // mm
#define LCD_RETRACT_LENGTH 3 // mm
#define LCD_PURGE_FEEDRATE 3 // mm/s
#define LCD_RETRACT_FEEDRATE 10 // mm/s
#define LCD_LOAD_FEEDRATE 8 // mm/s
#define LCD_UNLOAD_FEEDRATE 8 // mm/s
#endif
// Show a progress bar on the LCD when printing from SD?
//#define LCD_PROGRESS_BAR
#ifdef LCD_PROGRESS_BAR
// Amount of time (ms) to show the bar
#define PROGRESS_BAR_BAR_TIME 2000
// Amount of time (ms) to show the status message
#define PROGRESS_BAR_MSG_TIME 3000
// Amount of time (ms) to retain the status message (0=forever)
#define PROGRESS_BAR_MSG_EXPIRE 0
// Enable this to show messages for MSG_TIME then hide them
//#define PROGRESS_BAR_MSG_ONCE
#endif
// Preheat Constants // Preheat Constants
#define PLA_PREHEAT_HOTEND_TEMP 190 #define PLA_PREHEAT_HOTEND_TEMP 190
#define PLA_PREHEAT_HPB_TEMP 60 #define PLA_PREHEAT_HPB_TEMP 60
...@@ -607,9 +636,6 @@ ...@@ -607,9 +636,6 @@
#include "Configuration_adv.h" #include "Configuration_adv.h"
#include "thermistortables.h" #include "thermistortables.h"
......
...@@ -36,14 +36,12 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) ...@@ -36,14 +36,12 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size)
// wrong data being written to the variables. // wrong data being written to the variables.
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order. // ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
#if defined(CARTESIAN)
#define EEPROM_VERSION "V10" #define EEPROM_VERSION "V10"
#elif defined(COREXY) #ifdef DELTA
#define EEPROM_VERSION "V11" #define EEPROM_VERSION "V11"
#elif defined(DELTA) #endif
#define EEPROM_VERSION "V12" #ifdef SCARA
#elif defined(SCARA) #define EEPROM_VERSION "V12"
#define EEPROM_VERSION "V13"
#endif #endif
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
...@@ -126,9 +124,9 @@ void Config_PrintSettings() ...@@ -126,9 +124,9 @@ void Config_PrintSettings()
SERIAL_ECHOLN(""); SERIAL_ECHOLN("");
SERIAL_ECHOLNPGM("Steps per unit:"); SERIAL_ECHOLNPGM("Steps per unit:");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M92 X",axis_steps_per_unit[0]); SERIAL_ECHOPAIR(" M92 X",axis_steps_per_unit[X_AXIS]);
SERIAL_ECHOPAIR(" Y",axis_steps_per_unit[1]); SERIAL_ECHOPAIR(" Y",axis_steps_per_unit[Y_AXIS]);
SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[2]); SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[Z_AXIS]);
SERIAL_ECHOPAIR(" E0 ",axis_steps_per_unit[3]); SERIAL_ECHOPAIR(" E0 ",axis_steps_per_unit[3]);
SERIAL_ECHOPAIR(" E1 ",axis_steps_per_unit[4]); SERIAL_ECHOPAIR(" E1 ",axis_steps_per_unit[4]);
SERIAL_ECHOPAIR(" E2 ",axis_steps_per_unit[5]); SERIAL_ECHOPAIR(" E2 ",axis_steps_per_unit[5]);
...@@ -139,17 +137,18 @@ void Config_PrintSettings() ...@@ -139,17 +137,18 @@ void Config_PrintSettings()
#ifdef SCARA #ifdef SCARA
SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOLNPGM("Scaling factors:");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M365 X",axis_scaling[0]); SERIAL_ECHOPAIR(" M365 X",axis_scaling[X_AXIS]);
SERIAL_ECHOPAIR(" Y",axis_scaling[1]); SERIAL_ECHOPAIR(" Y",axis_scaling[Y_AXIS]);
SERIAL_ECHOPAIR(" Z",axis_scaling[2]); SERIAL_ECHOPAIR(" Z",axis_scaling[Z_AXIS]);
SERIAL_ECHOLN(""); SERIAL_ECHOLN("");
SERIAL_ECHO_START; SERIAL_ECHO_START;
#endif #endif
SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):"); SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M203 X ",max_feedrate[0]); SERIAL_ECHOPAIR(" M203 X ",max_feedrate[X_AXIS]);
SERIAL_ECHOPAIR(" Y ",max_feedrate[1] ); SERIAL_ECHOPAIR(" Y ",max_feedrate[Y_AXIS] );
SERIAL_ECHOPAIR(" Z ", max_feedrate[2] ); SERIAL_ECHOPAIR(" Z ", max_feedrate[Z_AXIS] );
SERIAL_ECHOPAIR(" E0 ", max_feedrate[3]); SERIAL_ECHOPAIR(" E0 ", max_feedrate[3]);
SERIAL_ECHOPAIR(" E1 ", max_feedrate[4]); SERIAL_ECHOPAIR(" E1 ", max_feedrate[4]);
SERIAL_ECHOPAIR(" E2 ", max_feedrate[5]); SERIAL_ECHOPAIR(" E2 ", max_feedrate[5]);
...@@ -164,19 +163,17 @@ void Config_PrintSettings() ...@@ -164,19 +163,17 @@ void Config_PrintSettings()
SERIAL_ECHOPAIR(" E2 ",max_retraction_feedrate[2]); SERIAL_ECHOPAIR(" E2 ",max_retraction_feedrate[2]);
SERIAL_ECHOPAIR(" E3 ",max_retraction_feedrate[3]); SERIAL_ECHOPAIR(" E3 ",max_retraction_feedrate[3]);
SERIAL_ECHOLN(""); SERIAL_ECHOLN("");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):"); SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M201 X " ,max_acceleration_units_per_sq_second[0] ); SERIAL_ECHOPAIR(" M201 X " ,max_acceleration_units_per_sq_second[X_AXIS] );
SERIAL_ECHOPAIR(" Y " , max_acceleration_units_per_sq_second[1] ); SERIAL_ECHOPAIR(" Y " , max_acceleration_units_per_sq_second[Y_AXIS] );
SERIAL_ECHOPAIR(" Z " ,max_acceleration_units_per_sq_second[2] ); SERIAL_ECHOPAIR(" Z " ,max_acceleration_units_per_sq_second[Z_AXIS] );
SERIAL_ECHOPAIR(" E0 " ,max_acceleration_units_per_sq_second[3]); SERIAL_ECHOPAIR(" E0 " ,max_acceleration_units_per_sq_second[3]);
SERIAL_ECHOPAIR(" E1 " ,max_acceleration_units_per_sq_second[4]); SERIAL_ECHOPAIR(" E1 " ,max_acceleration_units_per_sq_second[4]);
SERIAL_ECHOPAIR(" E2 " ,max_acceleration_units_per_sq_second[5]); SERIAL_ECHOPAIR(" E2 " ,max_acceleration_units_per_sq_second[5]);
SERIAL_ECHOPAIR(" E3 " ,max_acceleration_units_per_sq_second[6]); SERIAL_ECHOPAIR(" E3 " ,max_acceleration_units_per_sq_second[6]);
SERIAL_ECHOLN(""); SERIAL_ECHOLN("");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration"); SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration");
SERIAL_ECHO_START; SERIAL_ECHO_START;
...@@ -198,11 +195,10 @@ void Config_PrintSettings() ...@@ -198,11 +195,10 @@ void Config_PrintSettings()
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Home offset (mm):"); SERIAL_ECHOLNPGM("Home offset (mm):");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M206 X",add_homing[0] ); SERIAL_ECHOPAIR(" M206 X",add_homing[X_AXIS] );
SERIAL_ECHOPAIR(" Y" ,add_homing[1] ); SERIAL_ECHOPAIR(" Y" ,add_homing[Y_AXIS] );
SERIAL_ECHOPAIR(" Z" ,add_homing[2] ); SERIAL_ECHOPAIR(" Z" ,add_homing[Z_AXIS] );
SERIAL_ECHOLN(""); SERIAL_ECHOLN("");
#ifdef DELTA #ifdef DELTA
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Endstop adjustment (mm):"); SERIAL_ECHOLNPGM("Endstop adjustment (mm):");
...@@ -254,9 +250,25 @@ void Config_PrintSettings() ...@@ -254,9 +250,25 @@ void Config_PrintSettings()
SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd[active_extruder])); SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd[active_extruder]));
SERIAL_ECHOLN(""); SERIAL_ECHOLN("");
#endif #endif
#ifdef FWRETRACT
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M207 S",retract_length);
SERIAL_ECHOPAIR(" F" ,retract_feedrate*60);
SERIAL_ECHOPAIR(" Z" ,retract_zlift);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M208 S",retract_recover_length);
SERIAL_ECHOPAIR(" F" ,retract_recover_feedrate*60);
SERIAL_ECHOLN("");
#endif
} }
#endif #endif
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
void Config_RetrieveSettings() void Config_RetrieveSettings()
{ {
......
// Define this to set a custom name for your generic Mendel, // Define this to set a custom name for your generic Mendel,
#define CUSTOM_MENDEL_NAME "Prusa I3" #define CUSTOM_MENDEL_NAME "Prusa"
// Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
// You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
...@@ -172,10 +172,41 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo ...@@ -172,10 +172,41 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo
// - Block Z homing only when the probe is outside bed area. // - Block Z homing only when the probe is outside bed area.
#ifdef Z_SAFE_HOMING #ifdef Z_SAFE_HOMING
#define Z_SAFE_HOMING_X_POINT (X_MAX_LENGTH/2) // X point for Z homing when homing all axis (G28)
#define Z_SAFE_HOMING_Y_POINT (Y_MAX_LENGTH/2) // Y point for Z homing when homing all axis (G28)
#endif
#ifdef AUTO_BED_LEVELING_GRID // Check if Probe_Offset * Grid Points is greater than Probing Range
#if X_PROBE_OFFSET_FROM_EXTRUDER < 0
#if (-(X_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION))
#error "The X axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
#endif
#else
#if ((X_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION))
#error "The X axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
#endif
#endif
#if Y_PROBE_OFFSET_FROM_EXTRUDER < 0
#if (-(Y_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION))
#error "The Y axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
#endif
#else
#if ((Y_PROBE_OFFSET_FROM_EXTRUDER * AUTO_BED_LEVELING_GRID_POINTS) >= (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION))
#define Z_SAFE_HOMING_X_POINT (X_MAX_LENGTH/2) // X point for Z homing when homing all axis (G28) #error "The Y axis probing range is not enough to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS"
#define Z_SAFE_HOMING_Y_POINT (Y_MAX_LENGTH/2) // Y point for Z homing when homing all axis (G28)
#endif
#endif
#endif #endif
#endif // ENABLE_AUTO_BED_LEVELING #endif // ENABLE_AUTO_BED_LEVELING
......
...@@ -134,7 +134,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o ...@@ -134,7 +134,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o
// delta speeds must be the same on xyz // delta speeds must be the same on xyz
#define DEFAULT_AXIS_STEPS_PER_UNIT {80,80,80,451,625,625,625} // X, Y, Z, E0, E1, E2, E3 #define DEFAULT_AXIS_STEPS_PER_UNIT {80,80,80,451,625,625,625} // X, Y, Z, E0, E1, E2, E3
#define DEFAULT_MAX_FEEDRATE {300,300,300,45,100,100,100} // X, Y, Z, E0, E1, E2, E3 (mm/sec) #define DEFAULT_MAX_FEEDRATE {300,300,300,45,100,100,100} // X, Y, Z, E0, E1, E2, E3 (mm/sec)
#define DEFAULT_RETRACTION_MAX_FEEDRATE {80,150,150,150} // E0, E1, E2, E3 (mm/sec) #define DEFAULT_RETRACTION_MAX_FEEDRATE {150,150,150,150} // E0, E1, E2, E3 (mm/sec)
#define DEFAULT_MAX_ACCELERATION {2000,2000,2000,1000,1000,1000,1000} // X, Y, Z, E0, E1, E2, E3 maximum start speed for accelerated moves. #define DEFAULT_MAX_ACCELERATION {2000,2000,2000,1000,1000,1000,1000} // X, Y, Z, E0, E1, E2, E3 maximum start speed for accelerated moves.
#define DEFAULT_ACCELERATION 1000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves #define DEFAULT_ACCELERATION 1000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
......
...@@ -348,7 +348,7 @@ ...@@ -348,7 +348,7 @@
// extruder advance constant (s2/mm3) // extruder advance constant (s2/mm3)
// //
// advance (steps) = STEPS_PER_CUBIC_MM_E * EXTUDER_ADVANCE_K * cubic mm per second ^ 2 // advance (steps) = STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K * cubic mm per second ^ 2
// //
// Hooke's law says: force = k * distance // Hooke's law says: force = k * distance
// Bernoulli's principle says: v ^ 2 / 2 + g . h + pressure / density = constant // Bernoulli's principle says: v ^ 2 / 2 + g . h + pressure / density = constant
......
...@@ -66,8 +66,9 @@ ...@@ -66,8 +66,9 @@
#define SERIAL_PROTOCOLLNPGM(x) (serialprintPGM(PSTR(x)),MYSERIAL.write('\n')) #define SERIAL_PROTOCOLLNPGM(x) (serialprintPGM(PSTR(x)),MYSERIAL.write('\n'))
const char errormagic[] PROGMEM ="Error:"; extern const char errormagic[] PROGMEM;
const char echomagic[] PROGMEM ="echo:"; extern const char echomagic[] PROGMEM;
#define SERIAL_ERROR_START (serialprintPGM(errormagic)) #define SERIAL_ERROR_START (serialprintPGM(errormagic))
#define SERIAL_ERROR(x) SERIAL_PROTOCOL(x) #define SERIAL_ERROR(x) SERIAL_PROTOCOL(x)
#define SERIAL_ERRORPGM(x) SERIAL_PROTOCOLPGM(x) #define SERIAL_ERRORPGM(x) SERIAL_PROTOCOLPGM(x)
...@@ -151,31 +152,29 @@ void manage_inactivity(); ...@@ -151,31 +152,29 @@ void manage_inactivity();
#endif #endif
#if (DRIVER_EXTRUDERS > 1) && defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1) #if (DRIVER_EXTRUDERS > 1) && defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
#define enable_e1() WRITE(E1_ENABLE_PIN, E_ENABLE_ON) #define enable_e1() WRITE(E1_ENABLE_PIN, E_ENABLE_ON)
#define disable_e1() WRITE(E1_ENABLE_PIN,!E_ENABLE_ON) #define disable_e1() WRITE(E1_ENABLE_PIN,!E_ENABLE_ON)
#else #else
#define enable_e1() /* nothing */ #define enable_e1() /* nothing */
#define disable_e1() /* nothing */ #define disable_e1() /* nothing */
#endif #endif
#if (DRIVER_EXTRUDERS > 2) && defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1) #if (DRIVER_EXTRUDERS > 2) && defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
#define enable_e2() WRITE(E2_ENABLE_PIN, E_ENABLE_ON) #define enable_e2() WRITE(E2_ENABLE_PIN, E_ENABLE_ON)
#define disable_e2() WRITE(E2_ENABLE_PIN,!E_ENABLE_ON) #define disable_e2() WRITE(E2_ENABLE_PIN,!E_ENABLE_ON)
#else #else
#define enable_e2() /* nothing */ #define enable_e2() /* nothing */
#define disable_e2() /* nothing */ #define disable_e2() /* nothing */
#endif #endif
#if (DRIVER_EXTRUDERS > 3) && defined(E3_ENABLE_PIN) && (E3_ENABLE_PIN > -1) #if (DRIVER_EXTRUDERS > 3) && defined(E3_ENABLE_PIN) && (E3_ENABLE_PIN > -1)
#define enable_e3() WRITE(E3_ENABLE_PIN, E_ENABLE_ON) #define enable_e3() WRITE(E3_ENABLE_PIN, E_ENABLE_ON)
#define disable_e3() WRITE(E3_ENABLE_PIN,!E_ENABLE_ON) #define disable_e3() WRITE(E3_ENABLE_PIN,!E_ENABLE_ON)
#else #else
#define enable_e3() /* nothing */ #define enable_e3() /* nothing */
#define disable_e3() /* nothing */ #define disable_e3() /* nothing */
#endif #endif
enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3}; enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3};
...@@ -183,7 +182,6 @@ void FlushSerialRequestResend(); ...@@ -183,7 +182,6 @@ void FlushSerialRequestResend();
void ClearToSend(); void ClearToSend();
void get_coordinates(); void get_coordinates();
#ifdef DELTA #ifdef DELTA
float probe_bed(float x, float y); float probe_bed(float x, float y);
void set_delta_constants(); void set_delta_constants();
...@@ -202,7 +200,6 @@ extern float delta_tower1_x,delta_tower1_y; ...@@ -202,7 +200,6 @@ extern float delta_tower1_x,delta_tower1_y;
extern float delta_tower2_x,delta_tower2_y; extern float delta_tower2_x,delta_tower2_y;
extern float delta_tower3_x,delta_tower3_y; extern float delta_tower3_x,delta_tower3_y;
#endif #endif
#ifdef SCARA #ifdef SCARA
void calculate_delta(float cartesian[3]); void calculate_delta(float cartesian[3]);
void calculate_SCARA_forward_Transform(float f_scara[3]); void calculate_SCARA_forward_Transform(float f_scara[3]);
...@@ -290,6 +287,10 @@ extern float retract_length, retract_length_swap, retract_feedrate, retract_zlif ...@@ -290,6 +287,10 @@ extern float retract_length, retract_length_swap, retract_feedrate, retract_zlif
extern float retract_recover_length, retract_recover_length_swap, retract_recover_feedrate; extern float retract_recover_length, retract_recover_length_swap, retract_recover_feedrate;
#endif #endif
#ifdef EASY_LOAD
extern bool allow_lengthy_extrude_once; // for load/unload
#endif
#ifdef LASERBEAM #ifdef LASERBEAM
extern int laser_ttl_modulation; extern int laser_ttl_modulation;
#endif #endif
......
...@@ -377,21 +377,24 @@ float axis_scaling[3]={1,1,1}; // Build size scaling, default to 1 ...@@ -377,21 +377,24 @@ float axis_scaling[3]={1,1,1}; // Build size scaling, default to 1
bool cancel_heatup = false ; bool cancel_heatup = false ;
#ifdef FILAMENT_SENSOR #ifdef FILAMENT_SENSOR
//Variables for Filament Sensor input //Variables for Filament Sensor input
float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404
bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off
float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter
signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100
int delay_index1=0; //index into ring buffer int delay_index1=0; //index into ring buffer
int delay_index2=-1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized int delay_index2=-1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized
float delay_dist=0; //delay distance counter float delay_dist=0; //delay distance counter
int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting
#endif #endif
#ifdef LASERBEAM #ifdef LASERBEAM
int laser_ttl_modulation = 0; int laser_ttl_modulation = 0;
#endif #endif
const char errormagic[] PROGMEM = "Error:";
const char echomagic[] PROGMEM = "echo:";
//=========================================================================== //===========================================================================
//=============================Private Variables============================= //=============================Private Variables=============================
//=========================================================================== //===========================================================================
...@@ -456,13 +459,17 @@ static float color_position[] = COLOR_STEP; //variabile per la scelta del color ...@@ -456,13 +459,17 @@ static float color_position[] = COLOR_STEP; //variabile per la scelta del color
static float color_step_moltiplicator = (DRIVER_MICROSTEP / MOTOR_ANGLE) * CARTER_MOLTIPLICATOR; static float color_step_moltiplicator = (DRIVER_MICROSTEP / MOTOR_ANGLE) * CARTER_MOLTIPLICATOR;
#endif // NPR2 #endif // NPR2
#ifdef EASY_LOAD
bool allow_lengthy_extrude_once; // for load/unload
#endif
bool Stopped=false; bool Stopped=false;
#if defined(PAUSE_PIN) && PAUSE_PIN > -1 #if defined(PAUSE_PIN) && PAUSE_PIN > -1
bool paused=false; bool paused=false;
#endif #endif
#if NUM_SERVOS > 0 #if NUM_SERVOS > 0
Servo servos[NUM_SERVOS]; Servo servos[NUM_SERVOS];
#endif #endif
bool CooldownNoWait = true; bool CooldownNoWait = true;
...@@ -515,7 +522,8 @@ void serial_echopair_P(const char *s_P, unsigned long v) ...@@ -515,7 +522,8 @@ void serial_echopair_P(const char *s_P, unsigned long v)
//needs overworking someday //needs overworking someday
void enquecommand(const char *cmd) void enquecommand(const char *cmd)
{ {
if(buflen < BUFSIZE) { if(buflen < BUFSIZE)
{
//this is dangerous if a mixing of serial and this happens //this is dangerous if a mixing of serial and this happens
strcpy(&(cmdbuffer[bufindw][0]),cmd); strcpy(&(cmdbuffer[bufindw][0]),cmd);
SERIAL_ECHO_START; SERIAL_ECHO_START;
...@@ -529,7 +537,8 @@ void enquecommand(const char *cmd) ...@@ -529,7 +537,8 @@ void enquecommand(const char *cmd)
void enquecommand_P(const char *cmd) void enquecommand_P(const char *cmd)
{ {
if(buflen < BUFSIZE) { if(buflen < BUFSIZE)
{
//this is dangerous if a mixing of serial and this happens //this is dangerous if a mixing of serial and this happens
strcpy_P(&(cmdbuffer[bufindw][0]),cmd); strcpy_P(&(cmdbuffer[bufindw][0]),cmd);
SERIAL_ECHO_START; SERIAL_ECHO_START;
...@@ -541,97 +550,101 @@ void enquecommand_P(const char *cmd) ...@@ -541,97 +550,101 @@ void enquecommand_P(const char *cmd)
} }
} }
#if defined(KILL_PIN) && KILL_PIN > -1
void setup_killpin() void setup_killpin()
{ {
pinMode(KILL_PIN,INPUT); #if defined(KILL_PIN) && KILL_PIN > -1
SET_INPUT(KILL_PIN);
WRITE(KILL_PIN,HIGH); WRITE(KILL_PIN,HIGH);
#endif
} }
// Set home pin
void setup_homepin(void)
{
#if defined(HOME_PIN) && HOME_PIN > -1
SET_INPUT(HOME_PIN);
WRITE(HOME_PIN,HIGH);
#endif #endif
}
#if defined(PAUSE_PIN) && PAUSE_PIN > -1
void setup_pausepin() void setup_pausepin()
{ {
pinMode(PAUSE_PIN,INPUT); #if defined(PAUSE_PIN) && PAUSE_PIN > -1
SET_INPUT(PAUSE_PIN);
WRITE(PAUSE_PIN,HIGH); WRITE(PAUSE_PIN,HIGH);
#endif
} }
#endif
#if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
void setup_photpin() void setup_photpin()
{ {
#if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
SET_OUTPUT(PHOTOGRAPH_PIN); SET_OUTPUT(PHOTOGRAPH_PIN);
WRITE(PHOTOGRAPH_PIN, LOW); WRITE(PHOTOGRAPH_PIN, LOW);
#endif
} }
#endif
void setup_powerhold() void setup_powerhold()
{ {
#if defined(SUICIDE_PIN) && SUICIDE_PIN > -1 #if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
SET_OUTPUT(SUICIDE_PIN); SET_OUTPUT(SUICIDE_PIN);
WRITE(SUICIDE_PIN, HIGH); WRITE(SUICIDE_PIN, HIGH);
#endif #endif
#if defined(PS_ON_PIN) && PS_ON_PIN > -1 #if defined(PS_ON_PIN) && PS_ON_PIN > -1
SET_OUTPUT(PS_ON_PIN); SET_OUTPUT(PS_ON_PIN);
#if defined(PS_DEFAULT_OFF) #if defined(PS_DEFAULT_OFF)
WRITE(PS_ON_PIN, PS_ON_ASLEEP); WRITE(PS_ON_PIN, PS_ON_ASLEEP);
#else #else
WRITE(PS_ON_PIN, PS_ON_AWAKE); WRITE(PS_ON_PIN, PS_ON_AWAKE);
#endif // PS_DEFAULT_OFF #endif
#endif // PS_ON_PIN #endif
} }
void suicide() void suicide()
{ {
#if defined(SUICIDE_PIN) && SUICIDE_PIN > -1 #if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
SET_OUTPUT(SUICIDE_PIN); SET_OUTPUT(SUICIDE_PIN);
WRITE(SUICIDE_PIN, LOW); WRITE(SUICIDE_PIN, LOW);
#endif #endif
} }
#if NUM_SERVOS > 0
void servo_init() void servo_init()
{ {
#if (NUM_SERVOS >= 1) && defined(SERVO0_PIN) && (SERVO0_PIN > -1) #if (NUM_SERVOS >= 1) && defined(SERVO0_PIN) && (SERVO0_PIN > -1)
servos[0].attach(SERVO0_PIN); servos[0].attach(SERVO0_PIN);
#endif #endif
#if (NUM_SERVOS >= 2) && defined(SERVO1_PIN) && (SERVO1_PIN > -1) #if (NUM_SERVOS >= 2) && defined(SERVO1_PIN) && (SERVO1_PIN > -1)
servos[1].attach(SERVO1_PIN); servos[1].attach(SERVO1_PIN);
#endif #endif
#if (NUM_SERVOS >= 3) && defined(SERVO2_PIN) && (SERVO2_PIN > -1) #if (NUM_SERVOS >= 3) && defined(SERVO2_PIN) && (SERVO2_PIN > -1)
servos[2].attach(SERVO2_PIN); servos[2].attach(SERVO2_PIN);
#endif #endif
#if (NUM_SERVOS >= 4) && defined(SERVO3_PIN) && (SERVO3_PIN > -1) #if (NUM_SERVOS >= 4) && defined(SERVO3_PIN) && (SERVO3_PIN > -1)
servos[3].attach(SERVO3_PIN); servos[3].attach(SERVO3_PIN);
#endif #endif
#if (NUM_SERVOS >= 5) #if (NUM_SERVOS >= 5)
#error "TODO: enter initalisation code for more servos" #error "TODO: enter initalisation code for more servos"
#endif #endif
// Set position of Servo Endstops that are defined // Set position of Servo Endstops that are defined
#if defined(SERVO_ENDSTOPS) && (NUM_SERVOS > 0) #if (NUM_SERVOS > 0)
for(int8_t i = 0; i < 3; i++) { for(int8_t i = 0; i < 3; i++)
{
if(servo_endstops[i] > -1) { if(servo_endstops[i] > -1) {
servos[servo_endstops[i]].write(servo_endstop_angles[i * 2 + 1]); servos[servo_endstops[i]].write(servo_endstop_angles[i * 2 + 1]);
} }
} }
#endif // SERVO_ENDSTOPS #endif // NUM_SERVOS
#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0) #if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
delay(PROBE_SERVO_DEACTIVATION_DELAY); delay(PROBE_SERVO_DEACTIVATION_DELAY);
servos[servo_endstops[Z_AXIS]].detach(); servos[servo_endstops[Z_AXIS]].detach();
#endif #endif
} }
#endif // NUM_SERVOS
void setup() void setup()
{ {
#if defined(KILL_PIN) && KILL_PIN > -1
setup_killpin(); setup_killpin();
#endif
#if defined(PAUSE_PIN) && PAUSE_PIN > -1
setup_pausepin(); setup_pausepin();
#endif
// loads data from EEPROM if available else uses defaults (and resets step acceleration rate) // loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
Config_RetrieveSettings(); Config_RetrieveSettings();
...@@ -652,8 +665,8 @@ void setup() ...@@ -652,8 +665,8 @@ void setup()
SERIAL_ECHOPGM(MSG_MARLIN); SERIAL_ECHOPGM(MSG_MARLIN);
SERIAL_ECHOLNPGM(VERSION_STRING); SERIAL_ECHOLNPGM(VERSION_STRING);
#ifdef STRING_VERSION_CONFIG_H #ifdef STRING_VERSION_CONFIG_H
#ifdef STRING_CONFIG_H_AUTHOR #ifdef STRING_CONFIG_H_AUTHOR
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_CONFIGURATION_VER); SERIAL_ECHOPGM(MSG_CONFIGURATION_VER);
SERIAL_ECHOPGM(STRING_VERSION_CONFIG_H); SERIAL_ECHOPGM(STRING_VERSION_CONFIG_H);
...@@ -661,8 +674,8 @@ void setup() ...@@ -661,8 +674,8 @@ void setup()
SERIAL_ECHOLNPGM(STRING_CONFIG_H_AUTHOR); SERIAL_ECHOLNPGM(STRING_CONFIG_H_AUTHOR);
SERIAL_ECHOPGM("Compiled: "); SERIAL_ECHOPGM("Compiled: ");
SERIAL_ECHOLNPGM(__DATE__); SERIAL_ECHOLNPGM(__DATE__);
#endif // STRING_CONFIG_H_AUTHOR #endif // STRING_CONFIG_H_AUTHOR
#endif // STRING_VERSION_CONFIG_H #endif // STRING_VERSION_CONFIG_H
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_FREE_MEMORY); SERIAL_ECHOPGM(MSG_FREE_MEMORY);
SERIAL_ECHO(freeMemory()); SERIAL_ECHO(freeMemory());
...@@ -677,33 +690,31 @@ void setup() ...@@ -677,33 +690,31 @@ void setup()
plan_init(); // Initialize planner; plan_init(); // Initialize planner;
watchdog_init(); watchdog_init();
st_init(); // Initialize stepper, this enables interrupts! st_init(); // Initialize stepper, this enables interrupts!
#if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
setup_photpin(); setup_photpin();
#endif
#ifdef LASERBEAM // Initialize Laser beam #ifdef LASERBEAM // Initialize Laser beam
SET_OUTPUT(LASER_PWR_PIN); SET_OUTPUT(LASER_PWR_PIN);
digitalWrite(LASER_PWR_PIN, LOW); digitalWrite(LASER_PWR_PIN, LOW);
SET_OUTPUT(LASER_TTL_PIN); SET_OUTPUT(LASER_TTL_PIN);
digitalWrite(LASER_TTL_PIN, LOW); digitalWrite(LASER_TTL_PIN, LOW);
#endif #endif
#if NUM_SERVOS > 0
servo_init(); servo_init();
#endif
lcd_init(); lcd_init();
_delay_ms(1000); // wait 1sec to display the splash screen _delay_ms(1000); // wait 1sec to display the splash screen
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
#endif #endif
#ifdef DIGIPOT_I2C #ifdef DIGIPOT_I2C
digipot_i2c_init(); digipot_i2c_init();
#endif #endif
#ifdef Z_PROBE_SLED #ifdef Z_PROBE_SLED
pinMode(SERVO0_PIN, OUTPUT); pinMode(SERVO0_PIN, OUTPUT);
digitalWrite(SERVO0_PIN, LOW); // turn it off digitalWrite(SERVO0_PIN, LOW); // turn it off
#endif // Z_PROBE_SLED #endif // Z_PROBE_SLED
setup_homepin();
#ifdef FIRMWARE_TEST #ifdef FIRMWARE_TEST
FirmwareTest(); FirmwareTest();
#endif // FIRMWARE_TEST #endif // FIRMWARE_TEST
...@@ -714,12 +725,12 @@ void loop() ...@@ -714,12 +725,12 @@ void loop()
{ {
if(buflen < (BUFSIZE-1)) if(buflen < (BUFSIZE-1))
get_command(); get_command();
#ifdef SDSUPPORT #ifdef SDSUPPORT
card.checkautostart(false); card.checkautostart(false);
#endif #endif
if(buflen) if(buflen)
{ {
#ifdef SDSUPPORT #ifdef SDSUPPORT
if(card.saving) if(card.saving)
{ {
if(strstr_P(cmdbuffer[bufindr], PSTR("M29")) == NULL) if(strstr_P(cmdbuffer[bufindr], PSTR("M29")) == NULL)
...@@ -744,10 +755,9 @@ void loop() ...@@ -744,10 +755,9 @@ void loop()
{ {
process_commands(); process_commands();
} }
#else // no SDSUPPORT #else
process_commands(); process_commands();
#endif //SDSUPPORT #endif //SDSUPPORT
buflen = (buflen-1); buflen = (buflen-1);
bufindr = (bufindr + 1)%BUFSIZE; bufindr = (bufindr + 1)%BUFSIZE;
} }
...@@ -765,7 +775,7 @@ void get_command() ...@@ -765,7 +775,7 @@ void get_command()
if(serial_char == '\n' || if(serial_char == '\n' ||
serial_char == '\r' || serial_char == '\r' ||
(serial_char == ':' && comment_mode == false) || (serial_char == ':' && comment_mode == false) ||
serial_count >= (MAX_CMD_SIZE - 1)) serial_count >= (MAX_CMD_SIZE - 1) )
{ {
if(!serial_count) { //if empty line if(!serial_count) { //if empty line
comment_mode = false; //for new command comment_mode = false; //for new command
...@@ -779,7 +789,7 @@ void get_command() ...@@ -779,7 +789,7 @@ void get_command()
{ {
strchr_pointer = strchr(cmdbuffer[bufindw], 'N'); strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10)); gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
if(gcode_N != gcode_LastN+1 && (strstr_P(cmdbuffer[bufindw], PSTR("M110")) == NULL)) { if(gcode_N != gcode_LastN+1 && (strstr_P(cmdbuffer[bufindw], PSTR("M110")) == NULL) ) {
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORPGM(MSG_ERR_LINE_NO); SERIAL_ERRORPGM(MSG_ERR_LINE_NO);
SERIAL_ERRORLN(gcode_LastN); SERIAL_ERRORLN(gcode_LastN);
...@@ -789,7 +799,8 @@ void get_command() ...@@ -789,7 +799,8 @@ void get_command()
return; return;
} }
if(strchr(cmdbuffer[bufindw], '*') != NULL) { if(strchr(cmdbuffer[bufindw], '*') != NULL)
{
byte checksum = 0; byte checksum = 0;
byte count = 0; byte count = 0;
while(cmdbuffer[bufindw][count] != '*') checksum = checksum^cmdbuffer[bufindw][count++]; while(cmdbuffer[bufindw][count] != '*') checksum = checksum^cmdbuffer[bufindw][count++];
...@@ -804,7 +815,9 @@ void get_command() ...@@ -804,7 +815,9 @@ void get_command()
return; return;
} }
//if no errors, continue parsing //if no errors, continue parsing
} else { }
else
{
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORPGM(MSG_ERR_NO_CHECKSUM); SERIAL_ERRORPGM(MSG_ERR_NO_CHECKSUM);
SERIAL_ERRORLN(gcode_LastN); SERIAL_ERRORLN(gcode_LastN);
...@@ -815,8 +828,11 @@ void get_command() ...@@ -815,8 +828,11 @@ void get_command()
gcode_LastN = gcode_N; gcode_LastN = gcode_N;
//if no errors, continue parsing //if no errors, continue parsing
} else { // if we don't receive 'N' but still see '*' }
if((strchr(cmdbuffer[bufindw], '*') != NULL)) { else // if we don't receive 'N' but still see '*'
{
if((strchr(cmdbuffer[bufindw], '*') != NULL))
{
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORPGM(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM); SERIAL_ERRORPGM(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM);
SERIAL_ERRORLN(gcode_LastN); SERIAL_ERRORLN(gcode_LastN);
...@@ -824,9 +840,9 @@ void get_command() ...@@ -824,9 +840,9 @@ void get_command()
return; return;
} }
} }
if((strchr(cmdbuffer[bufindw], 'G') != NULL)) { if((strchr(cmdbuffer[bufindw], 'G') != NULL)){
strchr_pointer = strchr(cmdbuffer[bufindw], 'G'); strchr_pointer = strchr(cmdbuffer[bufindw], 'G');
switch((int)((strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)))) { switch((int)((strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)))){
case 0: case 0:
case 1: case 1:
case 2: case 2:
...@@ -857,7 +873,7 @@ void get_command() ...@@ -857,7 +873,7 @@ void get_command()
if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char; if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
} }
} }
#ifdef SDSUPPORT #ifdef SDSUPPORT
if(!card.sdprinting || serial_count!=0){ if(!card.sdprinting || serial_count!=0){
return; return;
} }
...@@ -917,7 +933,9 @@ void get_command() ...@@ -917,7 +933,9 @@ void get_command()
if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char; if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
} }
} }
#endif //SDSUPPORT
#endif //SDSUPPORT
} }
...@@ -974,6 +992,7 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR); ...@@ -974,6 +992,7 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
#define DXC_AUTO_PARK_MODE 1 #define DXC_AUTO_PARK_MODE 1
#define DXC_DUPLICATION_MODE 2 #define DXC_DUPLICATION_MODE 2
static int dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE; static int dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
static float x_home_pos(int extruder) { static float x_home_pos(int extruder) {
if (extruder == 0) if (extruder == 0)
return base_home_pos(X_AXIS) + add_homing[X_AXIS]; return base_home_pos(X_AXIS) + add_homing[X_AXIS];
...@@ -2190,7 +2209,7 @@ void process_commands() ...@@ -2190,7 +2209,7 @@ void process_commands()
destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER); destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER);
destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER); destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER);
destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed
feedrate = XY_TRAVEL_SPEED; feedrate = XY_TRAVEL_SPEED/60;
current_position[Z_AXIS] = 0; current_position[Z_AXIS] = 0;
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]);
...@@ -5351,7 +5370,14 @@ void clamp_to_software_endstops(float target[3]) ...@@ -5351,7 +5370,14 @@ void clamp_to_software_endstops(float target[3])
if (min_software_endstops) { if (min_software_endstops) {
if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS]; if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS];
if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS]; if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS];
if (target[Z_AXIS] < min_pos[Z_AXIS]) target[Z_AXIS] = min_pos[Z_AXIS];
float negative_z_offset = 0;
#ifdef ENABLE_AUTO_BED_LEVELING
if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER;
if (add_homing[Z_AXIS] < 0) negative_z_offset = negative_z_offset + add_homing[Z_AXIS];
#endif
if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset;
} }
if (max_software_endstops) { if (max_software_endstops) {
...@@ -5755,6 +5781,18 @@ void handle_status_leds(void) ...@@ -5755,6 +5781,18 @@ void handle_status_leds(void)
void manage_inactivity() void manage_inactivity()
{ {
#if defined(KILL_PIN) && KILL_PIN > -1
static int killCount = 0; // make the inactivity button a bit less responsive
const int KILL_DELAY = 10000;
#endif
#if defined(HOME_PIN) && HOME_PIN > -1
static int homeDebounceCount = 0; // poor man's debouncing count
const int HOME_DEBOUNCE_DELAY = 10000;
#endif
if(buflen < (BUFSIZE-1)) if(buflen < (BUFSIZE-1))
get_command(); get_command();
...@@ -5780,26 +5818,62 @@ void manage_inactivity() ...@@ -5780,26 +5818,62 @@ void manage_inactivity()
if (beeptemponoff) temptone(); if (beeptemponoff) temptone();
#endif #endif
#ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH
if (chdkActive && (millis() - chdkHigh > CHDK_DELAY)) if (chdkActive && (millis() - chdkHigh > CHDK_DELAY))
{ {
chdkActive = false; chdkActive = false;
WRITE(CHDK, LOW); WRITE(CHDK, LOW);
} }
#endif #endif
#if defined(KILL_PIN) && KILL_PIN > -1 #if defined(KILL_PIN) && KILL_PIN > -1
if(0 == READ(KILL_PIN)) kill();
#endif
#if defined(PAUSE_PIN) && PAUSE_PIN > -1 // Check if the kill button was pressed and wait just in case it was an accidental
if(0 == READ(PAUSE_PIN) && !paused) pause(); // key kill key press
#endif // -------------------------------------------------------------------------------
if( 0 == READ(KILL_PIN) )
{
killCount++;
}
else if (killCount > 0)
{
killCount--;
}
// Exceeded threshold and we can confirm that it was not accidental
// KILL the machine
// ----------------------------------------------------------------
if ( killCount >= KILL_DELAY)
{
kill();
}
#endif
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 #if defined(HOME_PIN) && HOME_PIN > -1
// Check to see if we have to home, use poor man's debouncer
// ---------------------------------------------------------
if ( 0 == READ(HOME_PIN) )
{
if (homeDebounceCount == 0)
{
enquecommand_P((PSTR("G28")));
homeDebounceCount++;
LCD_ALERTMESSAGEPGM(MSG_AUTO_HOME);
}
else if (homeDebounceCount < HOME_DEBOUNCE_DELAY)
{
homeDebounceCount++;
}
else
{
homeDebounceCount = 0;
}
}
#endif
#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 EXTRUDER_RUNOUT_PREVENT #ifdef EXTRUDER_RUNOUT_PREVENT
if( (millis() - previous_millis_cmd) > EXTRUDER_RUNOUT_SECONDS*1000 ) if( (millis() - previous_millis_cmd) > EXTRUDER_RUNOUT_SECONDS*1000 )
if(degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP) if(degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP)
{ {
...@@ -5836,9 +5910,9 @@ void manage_inactivity() ...@@ -5836,9 +5910,9 @@ void manage_inactivity()
void kill() void kill()
{ {
#if defined(KILL_PIN) && KILL_PIN > -1
cli(); // Stop interrupts cli(); // Stop interrupts
disable_heater(); disable_heater();
disable_x(); disable_x();
disable_y(); disable_y();
disable_z(); disable_z();
...@@ -5853,9 +5927,16 @@ void kill() ...@@ -5853,9 +5927,16 @@ void kill()
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_ERR_KILLED); SERIAL_ERRORLNPGM(MSG_ERR_KILLED);
LCD_ALERTMESSAGEPGM(MSG_KILLED); LCD_ALERTMESSAGEPGM(MSG_KILLED);
// FMC small patch to update the LCD before ending
sei(); // enable interrupts
for ( int i=5; i--; lcd_update())
{
delay(200);
}
cli(); // disable interrupts
suicide(); suicide();
while(1) { /* Intentionally left empty */ } // Wait for reset while(1) { /* Intentionally left empty */ } // Wait for reset
#endif
} }
#if (LARGE_FLASH == true && ( BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER))) #if (LARGE_FLASH == true && ( BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)))
...@@ -5901,16 +5982,17 @@ void temptone() ...@@ -5901,16 +5982,17 @@ void temptone()
} }
#endif // (LARGE_FLASH == true && ( BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER))) #endif // (LARGE_FLASH == true && ( BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)))
#if defined(PAUSE_PIN) && PAUSE_PIN > -1
void pause() void pause()
{ {
#if defined(PAUSE_PIN) && PAUSE_PIN > -1
paused=true; paused=true;
enquecommand("M600 X0 Z+5"); enquecommand("M600 X0 Z+5");
enquecommand("G4 P0"); enquecommand("G4 P0");
enquecommand("G4 P0"); enquecommand("G4 P0");
enquecommand("G4 P0"); enquecommand("G4 P0");
#endif // defined(PAUSE_PIN) && PAUSE_PIN > -1
} }
#endif // defined(PAUSE_PIN) && PAUSE_PIN > -1
void Stop() void Stop()
{ {
...@@ -5930,77 +6012,79 @@ bool IsStopped() { return Stopped; }; ...@@ -5930,77 +6012,79 @@ bool IsStopped() { return Stopped; };
void setPwmFrequency(uint8_t pin, int val) void setPwmFrequency(uint8_t pin, int val)
{ {
val &= 0x07; val &= 0x07;
switch(digitalPinToTimer(pin)) { switch(digitalPinToTimer(pin))
#if defined(TCCR0A) {
#if defined(TCCR0A)
case TIMER0A: case TIMER0A:
case TIMER0B: case TIMER0B:
//TCCR0B &= ~(_BV(CS00) | _BV(CS01) | _BV(CS02)); // TCCR0B &= ~(_BV(CS00) | _BV(CS01) | _BV(CS02));
//TCCR0B |= val; // TCCR0B |= val;
break; break;
#endif #endif
#if defined(TCCR1A) #if defined(TCCR1A)
case TIMER1A: case TIMER1A:
case TIMER1B: case TIMER1B:
//TCCR1B &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12)); // TCCR1B &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12));
//TCCR1B |= val; // TCCR1B |= val;
break; break;
#endif #endif
#if defined(TCCR2) #if defined(TCCR2)
case TIMER2: case TIMER2:
case TIMER2: case TIMER2:
TCCR2 &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12)); TCCR2 &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12));
TCCR2 |= val; TCCR2 |= val;
break; break;
#endif #endif
#if defined(TCCR2A) #if defined(TCCR2A)
case TIMER2A: case TIMER2A:
case TIMER2B: case TIMER2B:
TCCR2B &= ~(_BV(CS20) | _BV(CS21) | _BV(CS22)); TCCR2B &= ~(_BV(CS20) | _BV(CS21) | _BV(CS22));
TCCR2B |= val; TCCR2B |= val;
break; break;
#endif #endif
#if defined(TCCR3A) #if defined(TCCR3A)
case TIMER3A: case TIMER3A:
case TIMER3B: case TIMER3B:
case TIMER3C: case TIMER3C:
TCCR3B &= ~(_BV(CS30) | _BV(CS31) | _BV(CS32)); TCCR3B &= ~(_BV(CS30) | _BV(CS31) | _BV(CS32));
TCCR3B |= val; TCCR3B |= val;
break; break;
#endif #endif
#if defined(TCCR4A) #if defined(TCCR4A)
case TIMER4A: case TIMER4A:
case TIMER4B: case TIMER4B:
case TIMER4C: case TIMER4C:
TCCR4B &= ~(_BV(CS40) | _BV(CS41) | _BV(CS42)); TCCR4B &= ~(_BV(CS40) | _BV(CS41) | _BV(CS42));
TCCR4B |= val; TCCR4B |= val;
break; break;
#endif #endif
#if defined(TCCR5A) #if defined(TCCR5A)
case TIMER5A: case TIMER5A:
case TIMER5B: case TIMER5B:
case TIMER5C: case TIMER5C:
TCCR5B &= ~(_BV(CS50) | _BV(CS51) | _BV(CS52)); TCCR5B &= ~(_BV(CS50) | _BV(CS51) | _BV(CS52));
TCCR5B |= val; TCCR5B |= val;
break; break;
#endif #endif
} }
} }
#endif //FAST_PWM_FAN #endif //FAST_PWM_FAN
bool setTargetedHotend(int code) { bool setTargetedHotend(int code){
tmp_extruder = active_extruder; tmp_extruder = active_extruder;
if(code_seen('T')) { if(code_seen('T')) {
tmp_extruder = code_value(); tmp_extruder = code_value();
if(tmp_extruder >= EXTRUDERS) { if(tmp_extruder >= EXTRUDERS) {
SERIAL_ECHO_START; SERIAL_ECHO_START;
switch(code) { switch(code){
case 104: case 104:
SERIAL_ECHO(MSG_M104_INVALID_EXTRUDER); SERIAL_ECHO(MSG_M104_INVALID_EXTRUDER);
break; break;
......
...@@ -32,21 +32,24 @@ ...@@ -32,21 +32,24 @@
#define FIRMWARE_URL "http://firmware.ultimaker.com" #define FIRMWARE_URL "http://firmware.ultimaker.com"
#elif MB(RUMBA) #elif MB(RUMBA)
#define MACHINE_NAME "Rumba" #define MACHINE_NAME "Rumba"
#define FIRMWARE_URL "https://github.com/ErikZalm/Marlin/" #define FIRMWARE_URL "https://github.com/MagoKimbra/MarlinKimbra"
#elif MB(3DRAG) #elif MB(3DRAG)
#define MACHINE_NAME "3Drag" #define MACHINE_NAME "3Drag"
#define FIRMWARE_URL "http://3dprint.elettronicain.it/" #define FIRMWARE_URL "http://3dprint.elettronicain.it/"
#elif MB(5DPRINT) #elif MB(5DPRINT)
#define MACHINE_NAME "Makibox" #define MACHINE_NAME "Makibox"
#define FIRMWARE_URL "https://github.com/ErikZalm/Marlin/" #define FIRMWARE_URL "https://github.com/MagoKimbra/MarlinKimbra"
#elif MB(SAV_MKI)
#define MACHINE_NAME "SAV MkI"
#define FIRMWARE_URL "https://github.com/fmalpartida/Marlin/tree/SAV-MkI-config"
#else #else
#ifdef CUSTOM_MENDEL_NAME #ifdef CUSTOM_MENDEL_NAME
#define MACHINE_NAME CUSTOM_MENDEL_NAME #define MACHINE_NAME CUSTOM_MENDEL_NAME
#else #else
#define MACHINE_NAME "Mendel" #define MACHINE_NAME "Prusa"
#endif #endif
// Default firmware set to Mendel // Default firmware set to Prusa/Mendel
#define FIRMWARE_URL "https://github.com/MagoKimbra/MarlinKimbra" #define FIRMWARE_URL "https://github.com/MagoKimbra/MarlinKimbra"
#endif #endif
......
...@@ -143,6 +143,10 @@ ...@@ -143,6 +143,10 @@
#define MSG_CONFIG "Configuration" #define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate" #define MSG_BAUDRATE "Baudrate"
#define MSG_RECTRACT "Rectract" #define MSG_RECTRACT "Rectract"
#define MSG_E_BOWDEN_LENGTH "Extrude " STRINGIFY(BOWDEN_LENGTH) "mm"
#define MSG_R_BOWDEN_LENGTH "Retract " STRINGIFY(BOWDEN_LENGTH) "mm"
#define MSG_PURGE_XMM "Purge " STRINGIFY(LCD_PURGE_LENGTH) "mm"
#define MSG_RETRACT_XMM "Retract " STRINGIFY(LCD_RETRACT_LENGTH) "mm"
#ifdef FIRMWARE_TEST #ifdef FIRMWARE_TEST
#define MSG_FWTEST_YES "Put the Y command to go next" #define MSG_FWTEST_YES "Put the Y command to go next"
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// the direction of helical travel, radius == circle radius, isclockwise boolean. Used // the direction of helical travel, radius == circle radius, isclockwise boolean. Used
// for vector transformation direction. // for vector transformation direction.
void mc_arc(float *position, float *target, float *offset, unsigned char axis_0, unsigned char axis_1, void mc_arc(float *position, float *target, float *offset, unsigned char axis_0, unsigned char axis_1,
unsigned char axis_linear, float feed_rate, float radius, unsigned char isclockwise, uint8_t extruder, uint8_t driver); unsigned char axis_linear, float feed_rate, float radius, unsigned char isclockwise, uint8_t extruder, uint8_t driver);
#endif #endif
...@@ -1900,12 +1900,13 @@ ...@@ -1900,12 +1900,13 @@
#define ORIG_HEATER_BED_PIN 20 // Bed #define ORIG_HEATER_BED_PIN 20 // Bed
#define ORIG_FAN_PIN 16 // Fan -- from Teensyduino environment. #define ORIG_FAN_PIN 16 // Fan -- from Teensyduino environment.
// For the fan and Teensyduino uses a different pin mapping. // For the fan and Teensyduino uses a different pin mapping.
#define X_STOP_PIN 13
#define Y_STOP_PIN 14
#define Z_STOP_PIN 15
//#define Z_STOP_PIN 36 // For inductive sensor.
#define X_STOP_PIN 13 #define ORIG_TEMP_0_PIN 7 // Extruder / Analog pin numbering
#define Y_STOP_PIN 14 #define ORIG_TEMP_BED_PIN 6 // Bed / Analog pin numbering
#define Z_STOP_PIN 15
#define ORIG_TEMP_0_PIN 7 // Extruder / Analog pin numbering
#define ORIG_TEMP_BED_PIN 6 // Bed / Analog pin numbering
#define ORIG_TEMP_1_PIN -1 #define ORIG_TEMP_1_PIN -1
#define ORIG_TEMP_2_PIN -1 #define ORIG_TEMP_2_PIN -1
...@@ -1914,7 +1915,6 @@ ...@@ -1914,7 +1915,6 @@
#define SDSS 20 // PB0 - 8 in marlin env. #define SDSS 20 // PB0 - 8 in marlin env.
#define LED_PIN -1 #define LED_PIN -1
#define PS_ON_PIN -1 #define PS_ON_PIN -1
#define KILL_PIN -1
#define ALARM_PIN -1 #define ALARM_PIN -1
#define SDCARDDETECT -1 #define SDCARDDETECT -1
...@@ -1933,13 +1933,24 @@ ...@@ -1933,13 +1933,24 @@
#define LCD_PINS_D5 -1 #define LCD_PINS_D5 -1
#define LCD_PINS_D6 -1 #define LCD_PINS_D6 -1
#define LCD_PINS_D7 -1 #define LCD_PINS_D7 -1
#define BTN_EN1 -1
#define BTN_EN2 -1
#define BTN_ENC -1
#ifdef SAV_3DLCD
// For LCD SHIFT register LCD // For LCD SHIFT register LCD
#define SR_DATA_PIN 0 #define SR_DATA_PIN 1
#define SR_CLK_PIN 1 #define SR_CLK_PIN 0
#define BTN_EN1 41
#define BTN_EN2 40
#define BTN_ENC 12
#define KILL_PIN 42 // A2 = 42 - teensy = 40
#define HOME_PIN -1 // A4 = marlin 44 - teensy = 42
#ifdef NUM_SERVOS
#define SERVO0_PIN 41 // In teensy's pin definition for pinMode (in Servo.cpp)
#endif
#endif
#endif // SAV_MKI #endif // SAV_MKI
......
...@@ -601,9 +601,16 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa ...@@ -601,9 +601,16 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
#ifdef PREVENT_LENGTHY_EXTRUDE #ifdef PREVENT_LENGTHY_EXTRUDE
if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[active_extruder+3]*EXTRUDE_MAXLENGTH) if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[active_extruder+3]*EXTRUDE_MAXLENGTH)
{ {
#ifdef EASY_LOAD
if (!allow_lengthy_extrude_once) {
#endif
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP); SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
#ifdef EASY_LOAD
}
allow_lengthy_extrude_once = false;
#endif
} }
#endif // PREVENT_LENGTHY_EXTRUDE #endif // PREVENT_LENGTHY_EXTRUDE
} }
......
...@@ -72,8 +72,7 @@ typedef struct { ...@@ -72,8 +72,7 @@ typedef struct {
unsigned long laser_ttlmodulation; unsigned long laser_ttlmodulation;
#endif #endif
volatile char busy; volatile char busy;
} } block_t;
block_t;
#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
......
...@@ -78,7 +78,6 @@ static volatile bool endstop_z_hit=false; ...@@ -78,7 +78,6 @@ static volatile bool endstop_z_hit=false;
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
bool abort_on_endstop_hit = false; bool abort_on_endstop_hit = false;
#endif #endif
#ifdef MOTOR_CURRENT_PWM_XY_PIN #ifdef MOTOR_CURRENT_PWM_XY_PIN
int motor_current_setting[3] = DEFAULT_PWM_MOTOR_CURRENT; int motor_current_setting[3] = DEFAULT_PWM_MOTOR_CURRENT;
#endif #endif
......
...@@ -232,6 +232,13 @@ void PID_autotune(float temp, int extruder, int ncycles) ...@@ -232,6 +232,13 @@ void PID_autotune(float temp, int extruder, int ncycles)
float Kp, Ki, Kd; float Kp, Ki, Kd;
float max = 0, min = 10000; float max = 0, min = 10000;
#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
(defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) || \
(defined(EXTRUDER_3_AUTO_FAN_PIN) && EXTRUDER_3_AUTO_FAN_PIN > -1)
unsigned long extruder_autofan_last_check = millis();
#endif
if ((extruder >= EXTRUDERS) if ((extruder >= EXTRUDERS)
#if (TEMP_BED_PIN <= -1) #if (TEMP_BED_PIN <= -1)
||(extruder < 0) ||(extruder < 0)
...@@ -268,6 +275,17 @@ void PID_autotune(float temp, int extruder, int ncycles) ...@@ -268,6 +275,17 @@ void PID_autotune(float temp, int extruder, int ncycles)
max=max(max,input); max=max(max,input);
min=min(min,input); min=min(min,input);
#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
(defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) || \
(defined(EXTRUDER_3_AUTO_FAN_PIN) && EXTRUDER_3_AUTO_FAN_PIN > -1)
if(millis() - extruder_autofan_last_check > 2500) {
checkExtruderAutoFans();
extruder_autofan_last_check = millis();
}
#endif
if(heating == true && input > temp) { if(heating == true && input > temp) {
if(millis() - t2 > 5000) { if(millis() - t2 > 5000) {
heating=false; heating=false;
...@@ -424,6 +442,8 @@ void checkExtruderAutoFans() ...@@ -424,6 +442,8 @@ void checkExtruderAutoFans()
if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE)
fanState |= 1; fanState |= 1;
#endif #endif
#ifndef SINGLENOZZLE
#if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1
if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE)
{ {
...@@ -444,11 +464,27 @@ void checkExtruderAutoFans() ...@@ -444,11 +464,27 @@ void checkExtruderAutoFans()
fanState |= 4; fanState |= 4;
} }
#endif #endif
#if defined(EXTRUDER_3_AUTO_FAN_PIN) && EXTRUDER_3_AUTO_FAN_PIN > -1
if (current_temperature[3] > EXTRUDER_AUTO_FAN_TEMPERATURE)
{
if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
fanState |= 1;
else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN)
fanState |= 2;
else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_2_AUTO_FAN_PIN)
fanState |= 4;
else
fanState |= 8;
}
#endif
#endif // !SINLGENOZZE
// update extruder auto fan states // update extruder auto fan states
#if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1
setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0); setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0);
#endif #endif
#ifndef SINGLENOZZLE
#if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1
if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0); setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0);
...@@ -458,6 +494,13 @@ void checkExtruderAutoFans() ...@@ -458,6 +494,13 @@ void checkExtruderAutoFans()
&& EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0); setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0);
#endif #endif
#if defined(EXTRUDER_3_AUTO_FAN_PIN) && EXTRUDER_3_AUTO_FAN_PIN > -1
if (EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN
&& EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN)
&& EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_3_AUTO_FAN_PIN, (fanState & 8) != 0);
#endif
#endif // !SINLGENOZZE
} }
#endif // any extruder auto fan pins set #endif // any extruder auto fan pins set
...@@ -477,9 +520,9 @@ void manage_heater() ...@@ -477,9 +520,9 @@ void manage_heater()
#else #else
for(int e = 0; e < 1; e++) for(int e = 0; e < 1; e++)
{ {
#endif #endif // !SINLGENOZZE
#ifdef THERMAL_RUNAWAY_PROTECTION_PERIOD && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 #if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_RUNAWAY_PROTECTION_PERIOD, THERMAL_RUNAWAY_PROTECTION_HYSTERESIS); thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_RUNAWAY_PROTECTION_PERIOD, THERMAL_RUNAWAY_PROTECTION_HYSTERESIS);
#endif #endif
...@@ -509,7 +552,14 @@ void manage_heater() ...@@ -509,7 +552,14 @@ void manage_heater()
//K1 defined in Configuration.h in the PID settings //K1 defined in Configuration.h in the PID settings
#define K2 (1.0-K1) #define K2 (1.0-K1)
dTerm[e] = (Kd[e] * (pid_input - temp_dState[e]))*K2 + (K1 * dTerm[e]); dTerm[e] = (Kd[e] * (pid_input - temp_dState[e]))*K2 + (K1 * dTerm[e]);
pid_output = constrain(pTerm[e] + iTerm[e] - dTerm[e], 0, PID_MAX); 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
pid_output=PID_MAX;
} else if (pid_output < 0){
if (pid_error[e] < 0 ) temp_iState[e] -= pid_error[e]; // conditional un-integration
pid_output=0;
}
} }
temp_dState[e] = pid_input; temp_dState[e] = pid_input;
#else #else
...@@ -612,7 +662,14 @@ void manage_heater() ...@@ -612,7 +662,14 @@ void manage_heater()
dTerm_bed= (bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed); dTerm_bed= (bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed);
temp_dState_bed = pid_input; temp_dState_bed = pid_input;
pid_output = constrain(pTerm_bed + iTerm_bed - dTerm_bed, 0, MAX_BED_POWER); pid_output = pTerm_bed + iTerm_bed - dTerm_bed;
if (pid_output > MAX_BED_PID) {
if (pid_error_bed > 0 ) temp_iState_bed -= pid_error_bed; // conditional un-integration
pid_output=PID_MAX;
} else if (pid_output < 0){
if (pid_error_bed < 0 ) temp_iState_bed -= pid_error_bed; // conditional un-integration
pid_output=0;
}
#else #else
pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER); pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER);
...@@ -777,14 +834,14 @@ static void updateTemperaturesFromRawValues() ...@@ -777,14 +834,14 @@ static void updateTemperaturesFromRawValues()
#else #else
for(uint8_t e=0;e<1;e++) for(uint8_t e=0;e<1;e++)
{ {
#endif //SINGLENOZZLE #endif // !SINGLENOZZLE
current_temperature[e] = analog2temp(current_temperature_raw[e], e); current_temperature[e] = analog2temp(current_temperature_raw[e], e);
} }
current_temperature_bed = analog2tempBed(current_temperature_bed_raw); current_temperature_bed = analog2tempBed(current_temperature_bed_raw);
#ifdef TEMP_SENSOR_1_AS_REDUNDANT #ifdef TEMP_SENSOR_1_AS_REDUNDANT
redundant_temperature = analog2temp(redundant_temperature_raw, 1); redundant_temperature = analog2temp(redundant_temperature_raw, 1);
#endif #endif
#ifdef FILAMENT_SENSOR && (FILWIDTH_PIN > -1) //check if a sensor is supported #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported
filament_width_meas = analog2widthFil(); filament_width_meas = analog2widthFil();
#endif #endif
//Reset the watchdog after we know we have a temperature measurement. //Reset the watchdog after we know we have a temperature measurement.
...@@ -827,7 +884,7 @@ return(filament_width_nominal/temp*100); ...@@ -827,7 +884,7 @@ return(filament_width_nominal/temp*100);
void tp_init() void tp_init()
{ {
#if (MOTHERBOARD == 80) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1))
//disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
MCUCR=(1<<JTD); MCUCR=(1<<JTD);
MCUCR=(1<<JTD); MCUCR=(1<<JTD);
...@@ -840,7 +897,7 @@ void tp_init() ...@@ -840,7 +897,7 @@ void tp_init()
#else #else
for (int e = 0; e < 1; e++) for (int e = 0; e < 1; e++)
{ {
#endif #endif // !SINGLENOZZLE
// populate with the first value // populate with the first value
maxttemp[e] = maxttemp[0]; maxttemp[e] = maxttemp[0];
#ifdef PIDTEMP #ifdef PIDTEMP
...@@ -866,7 +923,7 @@ void tp_init() ...@@ -866,7 +923,7 @@ void tp_init()
#if defined(HEATER_3_PIN) && (HEATER_3_PIN > -1) #if defined(HEATER_3_PIN) && (HEATER_3_PIN > -1)
SET_OUTPUT(HEATER_3_PIN); SET_OUTPUT(HEATER_3_PIN);
#endif #endif
#endif //END SINGLENOZZLE #endif // !SINGLENOZZLE
#if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1)
SET_OUTPUT(HEATER_BED_PIN); SET_OUTPUT(HEATER_BED_PIN);
...@@ -936,7 +993,7 @@ void tp_init() ...@@ -936,7 +993,7 @@ void tp_init()
DIDR2 |= 1<<(TEMP_3_PIN - 8); DIDR2 |= 1<<(TEMP_3_PIN - 8);
#endif #endif
#endif #endif
#endif //END SINGLENOZZLE #endif // !SINGLENOZZLE
#if defined(TEMP_BED_PIN) && (TEMP_BED_PIN > -1) #if defined(TEMP_BED_PIN) && (TEMP_BED_PIN > -1)
#if TEMP_BED_PIN < 8 #if TEMP_BED_PIN < 8
...@@ -1047,8 +1104,8 @@ void tp_init() ...@@ -1047,8 +1104,8 @@ void tp_init()
maxttemp_raw[3] += OVERSAMPLENR; maxttemp_raw[3] += OVERSAMPLENR;
#endif #endif
} }
#endif //MAXTEMP 3 #endif // MAXTEMP 3
#endif//SINGLENOZZLE #endif // !SINGLENOZZLE
#ifdef BED_MINTEMP #ifdef BED_MINTEMP
/* No bed MINTEMP error implemented?!? */ /* /* No bed MINTEMP error implemented?!? */ /*
...@@ -1081,7 +1138,7 @@ void setWatch() ...@@ -1081,7 +1138,7 @@ void setWatch()
#else #else
for (int e = 0; e < 1; e++) for (int e = 0; e < 1; e++)
{ {
#endif #endif // !SINGLENOZZLE
if(degHotend(e) < degTargetHotend(e) - (WATCH_TEMP_INCREASE * 2)) if(degHotend(e) < degTargetHotend(e) - (WATCH_TEMP_INCREASE * 2))
{ {
watch_start_temp[e] = degHotend(e); watch_start_temp[e] = degHotend(e);
...@@ -1091,7 +1148,7 @@ void setWatch() ...@@ -1091,7 +1148,7 @@ void setWatch()
#endif #endif
} }
#ifdef THERMAL_RUNAWAY_PROTECTION_PERIOD && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 #if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
void thermal_runaway_protection(int *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) void thermal_runaway_protection(int *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc)
{ {
/* /*
...@@ -1159,7 +1216,7 @@ void disable_heater() ...@@ -1159,7 +1216,7 @@ void disable_heater()
for(int i=0;i<EXTRUDERS;i++) for(int i=0;i<EXTRUDERS;i++)
#else #else
for(int i=0;i<1;i++) for(int i=0;i<1;i++)
#endif #endif // !SINGLENOZZLE
setTargetHotend(0,i); setTargetHotend(0,i);
setTargetBed(0); setTargetBed(0);
#if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1
...@@ -1194,7 +1251,7 @@ void disable_heater() ...@@ -1194,7 +1251,7 @@ void disable_heater()
WRITE(HEATER_3_PIN,LOW); WRITE(HEATER_3_PIN,LOW);
#endif #endif
#endif #endif
#endif // END SINGLENOZZLE #endif // !SINGLENOZZLE
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
target_temperature_bed=0; target_temperature_bed=0;
...@@ -1325,7 +1382,7 @@ ISR(TIMER0_COMPB_vect) ...@@ -1325,7 +1382,7 @@ ISR(TIMER0_COMPB_vect)
#if EXTRUDERS > 3 #if EXTRUDERS > 3
static unsigned char soft_pwm_3; static unsigned char soft_pwm_3;
#endif #endif
#endif #endif // !SINGLENOZZLE
#if HEATER_BED_PIN > -1 #if HEATER_BED_PIN > -1
static unsigned char soft_pwm_b; static unsigned char soft_pwm_b;
#endif #endif
...@@ -1355,13 +1412,12 @@ ISR(TIMER0_COMPB_vect) ...@@ -1355,13 +1412,12 @@ ISR(TIMER0_COMPB_vect)
soft_pwm_3 = soft_pwm[3]; soft_pwm_3 = soft_pwm[3];
if(soft_pwm_3 > 0) WRITE(HEATER_3_PIN,1); else WRITE(HEATER_3_PIN,0); if(soft_pwm_3 > 0) WRITE(HEATER_3_PIN,1); else WRITE(HEATER_3_PIN,0);
#endif #endif
#endif //SINGLENOZZLE #endif // !SINGLENOZZLE
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
soft_pwm_b = soft_pwm_bed; soft_pwm_b = soft_pwm_bed;
if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0); if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0);
#endif #endif
#ifdef FAN_SOFT_PWM #ifdef FAN_SOFT_PWM
soft_pwm_fan = fanSpeedSoftPwm / 2; soft_pwm_fan = fanSpeedSoftPwm / 2;
if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0); if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0);
...@@ -1383,7 +1439,7 @@ ISR(TIMER0_COMPB_vect) ...@@ -1383,7 +1439,7 @@ ISR(TIMER0_COMPB_vect)
#if EXTRUDERS > 3 #if EXTRUDERS > 3
if(soft_pwm_3 < pwm_count) WRITE(HEATER_3_PIN,0); if(soft_pwm_3 < pwm_count) WRITE(HEATER_3_PIN,0);
#endif #endif
#endif #endif // !SINGLENOZZLE
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
if(soft_pwm_b < pwm_count) WRITE(HEATER_BED_PIN,0); if(soft_pwm_b < pwm_count) WRITE(HEATER_BED_PIN,0);
#endif #endif
...@@ -1531,7 +1587,7 @@ ISR(TIMER0_COMPB_vect) ...@@ -1531,7 +1587,7 @@ ISR(TIMER0_COMPB_vect)
// break; // break;
} }
if(temp_count >= OVERSAMPLENR) // 12 * 16 * 1/(16000000/64/256) = 197ms. if(temp_count >= OVERSAMPLENR) // 10 * 16 * 1/(16000000/64/256) = 164ms.
{ {
if (!temp_meas_ready) //Only update the raw values if they have been read. Else we could be updating them during reading. if (!temp_meas_ready) //Only update the raw values if they have been read. Else we could be updating them during reading.
{ {
...@@ -1549,7 +1605,7 @@ ISR(TIMER0_COMPB_vect) ...@@ -1549,7 +1605,7 @@ ISR(TIMER0_COMPB_vect)
#if EXTRUDERS > 3 #if EXTRUDERS > 3
current_temperature_raw[3] = raw_temp_3_value; current_temperature_raw[3] = raw_temp_3_value;
#endif #endif
#endif #endif // !SINGLENOZZLE
current_temperature_bed_raw = raw_temp_bed_value; current_temperature_bed_raw = raw_temp_bed_value;
} }
...@@ -1631,7 +1687,7 @@ ISR(TIMER0_COMPB_vect) ...@@ -1631,7 +1687,7 @@ ISR(TIMER0_COMPB_vect)
min_temp_error(3); min_temp_error(3);
} }
#endif #endif
#endif //SINGLENOZZLE #endif // !SINGLENOZZLE
/* No bed MINTEMP error? */ /* No bed MINTEMP error? */
#if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0) #if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0)
...@@ -1691,5 +1747,3 @@ float unscalePID_d(float d) ...@@ -1691,5 +1747,3 @@ float unscalePID_d(float d)
} }
#endif //PIDTEMP #endif //PIDTEMP
...@@ -60,28 +60,27 @@ extern int current_temperature_bed_raw; ...@@ -60,28 +60,27 @@ extern int current_temperature_bed_raw;
extern int target_temperature_bed; extern int target_temperature_bed;
extern float current_temperature_bed; extern float current_temperature_bed;
#ifdef TEMP_SENSOR_1_AS_REDUNDANT #ifdef TEMP_SENSOR_1_AS_REDUNDANT
extern float redundant_temperature; extern float redundant_temperature;
#endif #endif
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
extern unsigned char soft_pwm_bed; extern unsigned char soft_pwm_bed;
#endif #endif
#ifdef PIDTEMP #ifdef PIDTEMP
extern float Kp[4],Ki[4],Kd[4],Kc; extern float Kp[4],Ki[4],Kd[4],Kc;
float scalePID_i(float i); float scalePID_i(float i);
float scalePID_d(float d); float scalePID_d(float d);
float unscalePID_i(float i); float unscalePID_i(float i);
float unscalePID_d(float d); float unscalePID_d(float d);
#endif #endif
#ifdef PIDTEMPBED #ifdef PIDTEMPBED
extern float bedKp,bedKi,bedKd; extern float bedKp,bedKi,bedKd;
#endif #endif
#ifdef BABYSTEPPING #ifdef BABYSTEPPING
extern volatile int babystepsTodo[3]; extern volatile int babystepsTodo[3];
#endif #endif
//high level conversion routines, for use outside of temperature.cpp //high level conversion routines, for use outside of temperature.cpp
...@@ -205,7 +204,7 @@ void disable_heater(); ...@@ -205,7 +204,7 @@ void disable_heater();
void setWatch(); void setWatch();
void updatePID(); void updatePID();
#ifdef THERMAL_RUNAWAY_PROTECTION_PERIOD && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 #if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
void thermal_runaway_protection(int *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc); void thermal_runaway_protection(int *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc);
static int thermal_runaway_state_machine[4]; // = {0,0,0,0}; static int thermal_runaway_state_machine[4]; // = {0,0,0,0};
static unsigned long thermal_runaway_timer[4]; // = {0,0,0,0}; static unsigned long thermal_runaway_timer[4]; // = {0,0,0,0};
...@@ -229,4 +228,8 @@ FORCE_INLINE void autotempShutdown(){ ...@@ -229,4 +228,8 @@ FORCE_INLINE void autotempShutdown(){
void PID_autotune(float temp, int extruder, int ncycles); void PID_autotune(float temp, int extruder, int ncycles);
void setExtruderAutoFanState(int pin, bool state);
void checkExtruderAutoFans();
#endif #endif
...@@ -26,13 +26,11 @@ int gumPreheatFanSpeed; ...@@ -26,13 +26,11 @@ int gumPreheatFanSpeed;
const long baudrates[] = {9600,14400,19200,28800,38400,56000,115200,250000}; const long baudrates[] = {9600,14400,19200,28800,38400,56000,115200,250000};
int baudrate_position = -1; int baudrate_position = -1;
#ifdef FILAMENT_LCD_DISPLAY #ifdef FILAMENT_LCD_DISPLAY
unsigned long message_millis=0; unsigned long message_millis = 0;
#endif #endif
#ifdef ULTIPANEL #ifdef ULTIPANEL
static float manual_feedrate[] = MANUAL_FEEDRATE; static float manual_feedrate[] = MANUAL_FEEDRATE;
#endif // ULTIPANEL #endif // ULTIPANEL
/* !Configuration settings */ /* !Configuration settings */
...@@ -170,7 +168,7 @@ uint32_t encoderPosition; ...@@ -170,7 +168,7 @@ uint32_t encoderPosition;
#if (SDCARDDETECT > 0) #if (SDCARDDETECT > 0)
bool lcd_oldcardstatus; bool lcd_oldcardstatus;
#endif #endif
#endif//ULTIPANEL #endif //ULTIPANEL
menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */ menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */
uint32_t lcd_next_update_millis; uint32_t lcd_next_update_millis;
...@@ -191,9 +189,50 @@ menuFunc_t callbackFunc; ...@@ -191,9 +189,50 @@ menuFunc_t callbackFunc;
// place-holders for Ki and Kd edits // place-holders for Ki and Kd edits
float raw_Ki, raw_Kd; float raw_Ki, raw_Kd;
static void lcd_goto_menu(menuFunc_t menu, const uint32_t encoder=0, const bool feedback=true) {
if (currentMenu != menu) {
currentMenu = menu;
encoderPosition = encoder;
if (feedback) lcd_quick_feedback();
// For LCD_PROGRESS_BAR re-initialize the custom characters
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
lcd_set_custom_characters(menu == lcd_status_screen);
#endif
}
}
/* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */ /* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */
static void lcd_status_screen() static void lcd_status_screen()
{ {
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
uint16_t mil = millis();
#ifndef PROGRESS_BAR_MSG_ONCE
if (mil > progressBarTick + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME) {
progressBarTick = mil;
}
#endif
#if PROGRESS_BAR_MSG_EXPIRE > 0
// keep the message alive if paused, count down otherwise
if (messageTick > 0) {
if (card.isFileOpen()) {
if (IS_SD_PRINTING) {
if ((mil-messageTick) >= PROGRESS_BAR_MSG_EXPIRE) {
lcd_status_message[0] = '\0';
messageTick = 0;
}
}
else {
messageTick += LCD_UPDATE_INTERVAL;
}
}
else {
messageTick = 0;
}
}
#endif
#endif //LCD_PROGRESS_BAR
if (lcd_status_update_delay) if (lcd_status_update_delay)
lcd_status_update_delay--; lcd_status_update_delay--;
else else
...@@ -225,13 +264,15 @@ static void lcd_status_screen() ...@@ -225,13 +264,15 @@ static void lcd_status_screen()
if (current_click) if (current_click)
{ {
currentMenu = lcd_main_menu; lcd_goto_menu(lcd_main_menu);
encoderPosition = 0; lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
lcd_quick_feedback(); #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
lcd_implementation_init(); // to maybe revive the LCD if static electricity killed it. currentMenu == lcd_status_screen
#ifdef FILAMENT_LCD_DISPLAY #endif
message_millis=millis(); //get status message to show up for a while );
#endif #ifdef FILAMENT_LCD_DISPLAY
message_millis = millis(); // get status message to show up for a while
#endif
} }
#ifdef ULTIPANEL_FEEDMULTIPLY #ifdef ULTIPANEL_FEEDMULTIPLY
...@@ -258,30 +299,22 @@ static void lcd_status_screen() ...@@ -258,30 +299,22 @@ static void lcd_status_screen()
feedmultiply += int(encoderPosition); feedmultiply += int(encoderPosition);
encoderPosition = 0; encoderPosition = 0;
} }
#endif//ULTIPANEL_FEEDMULTIPLY #endif //ULTIPANEL_FEEDMULTIPLY
if (feedmultiply < 10) if (feedmultiply < 10)
feedmultiply = 10; feedmultiply = 10;
if (feedmultiply > 999) else if (feedmultiply > 999)
feedmultiply = 999; feedmultiply = 999;
#endif//ULTIPANEL #endif //ULTIPANEL
} }
#ifdef ULTIPANEL #ifdef ULTIPANEL
static void lcd_return_to_status()
{
encoderPosition = 0;
currentMenu = lcd_status_screen;
}
static void lcd_sdcard_pause() static void lcd_return_to_status() { lcd_goto_menu(lcd_status_screen, 0, false); }
{
card.pauseSDPrint(); static void lcd_sdcard_pause() { card.pauseSDPrint(); }
}
static void lcd_sdcard_resume() static void lcd_sdcard_resume() { card.startFileprint(); }
{
card.startFileprint();
}
static void lcd_sdcard_stop() static void lcd_sdcard_stop()
{ {
...@@ -365,65 +398,20 @@ void lcd_set_home_offsets() ...@@ -365,65 +398,20 @@ void lcd_set_home_offsets()
#ifdef BABYSTEPPING #ifdef BABYSTEPPING
static void lcd_babystep_x()
{
if (encoderPosition != 0)
{
babystepsTodo[X_AXIS]+=(int)encoderPosition;
encoderPosition=0;
lcdDrawUpdate = 1;
}
if (lcdDrawUpdate)
{
lcd_implementation_drawedit(PSTR(MSG_BABYSTEPPING_X),"");
}
if (LCD_CLICKED)
{
lcd_quick_feedback();
currentMenu = lcd_tune_menu;
encoderPosition = 0;
}
}
static void lcd_babystep_y() static void _lcd_babystep(int axis, const char *msg) {
{ if (encoderPosition != 0) {
if (encoderPosition != 0) babystepsTodo[axis] += (int)encoderPosition;
{
babystepsTodo[Y_AXIS]+=(int)encoderPosition;
encoderPosition=0;
lcdDrawUpdate = 1;
}
if (lcdDrawUpdate)
{
lcd_implementation_drawedit(PSTR(MSG_BABYSTEPPING_Y),"");
}
if (LCD_CLICKED)
{
lcd_quick_feedback();
currentMenu = lcd_tune_menu;
encoderPosition = 0; encoderPosition = 0;
}
}
static void lcd_babystep_z()
{
if (encoderPosition != 0)
{
babystepsTodo[Z_AXIS]+=BABYSTEP_Z_MULTIPLICATOR*(int)encoderPosition;
encoderPosition=0;
lcdDrawUpdate = 1; lcdDrawUpdate = 1;
} }
if (lcdDrawUpdate) if (lcdDrawUpdate) lcd_implementation_drawedit(msg, "");
{ if (LCD_CLICKED) lcd_goto_menu(lcd_tune_menu);
lcd_implementation_drawedit(PSTR(MSG_BABYSTEPPING_Z),"");
} }
if (LCD_CLICKED) static void lcd_babystep_x() { _lcd_babystep(X_AXIS, PSTR(MSG_BABYSTEPPING_X)); }
{ static void lcd_babystep_y() { _lcd_babystep(Y_AXIS, PSTR(MSG_BABYSTEPPING_Y)); }
lcd_quick_feedback(); static void lcd_babystep_z() { _lcd_babystep(Z_AXIS, PSTR(MSG_BABYSTEPPING_Z)); }
currentMenu = lcd_tune_menu;
encoderPosition = 0;
}
}
#endif //BABYSTEPPING #endif //BABYSTEPPING
static void lcd_tune_menu() static void lcd_tune_menu()
...@@ -445,7 +433,7 @@ static void lcd_tune_menu() ...@@ -445,7 +433,7 @@ static void lcd_tune_menu()
#if TEMP_SENSOR_3 != 0 #if TEMP_SENSOR_3 != 0
MENU_ITEM_EDIT(int3, MSG_NOZZLE3, &target_temperature[3], 0, HEATER_3_MAXTEMP - 15); MENU_ITEM_EDIT(int3, MSG_NOZZLE3, &target_temperature[3], 0, HEATER_3_MAXTEMP - 15);
#endif #endif
#endif // SINGLENOZZLE #endif // !SINGLENOZZLE
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
MENU_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); MENU_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
...@@ -464,7 +452,7 @@ static void lcd_tune_menu() ...@@ -464,7 +452,7 @@ static void lcd_tune_menu()
#if TEMP_SENSOR_3 != 0 #if TEMP_SENSOR_3 != 0
MENU_ITEM_EDIT(int3, MSG_FLOW3, &extruder_multiply[3], 10, 999); MENU_ITEM_EDIT(int3, MSG_FLOW3, &extruder_multiply[3], 10, 999);
#endif #endif
#endif // SINGLENOZZLE #endif // !SINGLENOZZLE
#ifdef BABYSTEPPING #ifdef BABYSTEPPING
#ifdef BABYSTEP_XY #ifdef BABYSTEP_XY
...@@ -479,6 +467,31 @@ static void lcd_tune_menu() ...@@ -479,6 +467,31 @@ static void lcd_tune_menu()
END_MENU(); END_MENU();
} }
#if defined(EASY_LOAD)
static void lcd_extrude(float length, float feedrate) {
current_position[E_AXIS] += length;
#ifdef DELTA
calculate_delta(current_position);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], feedrate, active_extruder, active_driver);
#else
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate, active_extruder, active_driver);
#endif
}
static void lcd_purge() {lcd_extrude(LCD_PURGE_LENGTH, LCD_PURGE_FEEDRATE);}
static void lcd_retract() {lcd_extrude(-LCD_RETRACT_LENGTH, LCD_RETRACT_FEEDRATE);}
static void lcd_easy_load() {
allow_lengthy_extrude_once = true;
lcd_extrude(BOWDEN_LENGTH, LCD_LOAD_FEEDRATE);
lcd_return_to_status();
}
static void lcd_easy_unload() {
allow_lengthy_extrude_once = true;
lcd_extrude(-BOWDEN_LENGTH, LCD_UNLOAD_FEEDRATE);
lcd_return_to_status();
}
#endif // EASY_LOAD
void lcd_preheat_pla0() void lcd_preheat_pla0()
{ {
setTargetHotend0(plaPreheatHotendTemp); setTargetHotend0(plaPreheatHotendTemp);
...@@ -593,9 +606,8 @@ void lcd_preheat_gum3() ...@@ -593,9 +606,8 @@ void lcd_preheat_gum3()
setWatch(); // heater sanity check timer setWatch(); // heater sanity check timer
} }
#endif //4 extruder preheat #endif //4 extruder preheat
#endif // SINGLENOZZLE
#if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || !defined(SINGLENOZZLE) //more than one extruder present #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 //more than one extruder present
void lcd_preheat_pla0123() void lcd_preheat_pla0123()
{ {
setTargetHotend0(plaPreheatHotendTemp); setTargetHotend0(plaPreheatHotendTemp);
...@@ -620,6 +632,7 @@ void lcd_preheat_abs0123() ...@@ -620,6 +632,7 @@ void lcd_preheat_abs0123()
setWatch(); // heater sanity check timer setWatch(); // heater sanity check timer
} }
#endif //more than one extruder present #endif //more than one extruder present
#endif // !SINGLENOZZLE
void lcd_preheat_pla_bedonly() void lcd_preheat_pla_bedonly()
{ {
...@@ -664,7 +677,7 @@ static void lcd_preheat_pla_menu() ...@@ -664,7 +677,7 @@ static void lcd_preheat_pla_menu()
#if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 //all extruder preheat #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 //all extruder preheat
MENU_ITEM(function, MSG_PREHEAT_PLA0123, lcd_preheat_pla0123); MENU_ITEM(function, MSG_PREHEAT_PLA0123, lcd_preheat_pla0123);
#endif //all extruder preheat #endif //all extruder preheat
#endif // SINGLENOZZLE #endif // !SINGLENOZZLE
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
MENU_ITEM(function, MSG_PREHEAT_PLA_BEDONLY, lcd_preheat_pla_bedonly); MENU_ITEM(function, MSG_PREHEAT_PLA_BEDONLY, lcd_preheat_pla_bedonly);
...@@ -691,7 +704,7 @@ static void lcd_preheat_abs_menu() ...@@ -691,7 +704,7 @@ static void lcd_preheat_abs_menu()
#if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 //all extruder preheat #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 //all extruder preheat
MENU_ITEM(function, MSG_PREHEAT_ABS0123, lcd_preheat_abs0123); MENU_ITEM(function, MSG_PREHEAT_ABS0123, lcd_preheat_abs0123);
#endif //all extruder preheat #endif //all extruder preheat
#endif // SINGLENOZZLE #endif // !SINGLENOZZLE
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
MENU_ITEM(function, MSG_PREHEAT_ABS_BEDONLY, lcd_preheat_abs_bedonly); MENU_ITEM(function, MSG_PREHEAT_ABS_BEDONLY, lcd_preheat_abs_bedonly);
...@@ -715,7 +728,7 @@ static void lcd_preheat_gum_menu() ...@@ -715,7 +728,7 @@ static void lcd_preheat_gum_menu()
#if TEMP_SENSOR_3 != 0 //4 extruder preheat #if TEMP_SENSOR_3 != 0 //4 extruder preheat
MENU_ITEM(function, MSG_PREHEAT_GUM3, lcd_preheat_gum3); MENU_ITEM(function, MSG_PREHEAT_GUM3, lcd_preheat_gum3);
#endif //3 extruder preheat #endif //3 extruder preheat
#endif // SINGLENOZZLE #endif // !SINGLENOZZLE
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
MENU_ITEM(function, MSG_PREHEAT_GUM_BEDONLY, lcd_preheat_gum_bedonly); MENU_ITEM(function, MSG_PREHEAT_GUM_BEDONLY, lcd_preheat_gum_bedonly);
...@@ -731,7 +744,7 @@ void lcd_cooldown() ...@@ -731,7 +744,7 @@ void lcd_cooldown()
setTargetHotend1(0); setTargetHotend1(0);
setTargetHotend2(0); setTargetHotend2(0);
setTargetHotend3(0); setTargetHotend3(0);
#endif // SINGLENOZZLE #endif // !SINGLENOZZLE
setTargetBed(0); setTargetBed(0);
fanSpeed = 0; fanSpeed = 0;
...@@ -773,6 +786,12 @@ static void lcd_prepare_menu() ...@@ -773,6 +786,12 @@ static void lcd_prepare_menu()
#endif #endif
#endif #endif
MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown); MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
#if defined(EASY_LOAD)
MENU_ITEM(function, MSG_E_BOWDEN_LENGTH, lcd_easy_load);
MENU_ITEM(function, MSG_R_BOWDEN_LENGTH, lcd_easy_unload);
MENU_ITEM(function, MSG_PURGE_XMM, lcd_purge);
MENU_ITEM(function, MSG_RETRACT_XMM, lcd_retract);
#endif // EASY_LOAD
#if defined(POWER_SUPPLY) && POWER_SUPPLY > 0 && defined(PS_ON_PIN) && PS_ON_PIN > -1 #if defined(POWER_SUPPLY) && POWER_SUPPLY > 0 && defined(PS_ON_PIN) && PS_ON_PIN > -1
if (powersupply) if (powersupply)
{ {
...@@ -788,16 +807,12 @@ static void lcd_prepare_menu() ...@@ -788,16 +807,12 @@ static void lcd_prepare_menu()
float move_menu_scale; float move_menu_scale;
static void lcd_move_menu_axis(); static void lcd_move_menu_axis();
static void lcd_move_x() static void _lcd_move(const char *name, int axis, int min, int max) {
{ if (encoderPosition != 0) {
if (encoderPosition != 0)
{
refresh_cmd_timeout(); refresh_cmd_timeout();
current_position[X_AXIS] += float((int)encoderPosition) * move_menu_scale; current_position[axis] += float((int)encoderPosition) * move_menu_scale;
if (min_software_endstops && current_position[X_AXIS] < X_MIN_POS) if (min_software_endstops && current_position[axis] < min) current_position[axis] = min;
current_position[X_AXIS] = X_MIN_POS; if (max_software_endstops && current_position[axis] > max) current_position[axis] = max;
if (max_software_endstops && current_position[X_AXIS] > X_MAX_POS)
current_position[X_AXIS] = X_MAX_POS;
encoderPosition = 0; encoderPosition = 0;
#ifdef DELTA #ifdef DELTA
calculate_delta(current_position); calculate_delta(current_position);
...@@ -807,77 +822,13 @@ static void lcd_move_x() ...@@ -807,77 +822,13 @@ static void lcd_move_x()
#endif #endif
lcdDrawUpdate = 1; lcdDrawUpdate = 1;
} }
if (lcdDrawUpdate) if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
{ if (LCD_CLICKED) lcd_goto_menu(lcd_move_menu_axis);
lcd_implementation_drawedit(PSTR("X"), ftostr31(current_position[X_AXIS]));
}
if (LCD_CLICKED)
{
lcd_quick_feedback();
currentMenu = lcd_move_menu_axis;
encoderPosition = 0;
}
}
static void lcd_move_y()
{
if (encoderPosition != 0)
{
refresh_cmd_timeout();
current_position[Y_AXIS] += float((int)encoderPosition) * move_menu_scale;
if (min_software_endstops && current_position[Y_AXIS] < Y_MIN_POS)
current_position[Y_AXIS] = Y_MIN_POS;
if (max_software_endstops && current_position[Y_AXIS] > Y_MAX_POS)
current_position[Y_AXIS] = Y_MAX_POS;
encoderPosition = 0;
#ifdef DELTA
calculate_delta(current_position);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[Y_AXIS]/60, active_extruder, active_driver);
#else
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[Y_AXIS]/60, active_extruder, active_driver);
#endif
lcdDrawUpdate = 1;
}
if (lcdDrawUpdate)
{
lcd_implementation_drawedit(PSTR("Y"), ftostr31(current_position[Y_AXIS]));
}
if (LCD_CLICKED)
{
lcd_quick_feedback();
currentMenu = lcd_move_menu_axis;
encoderPosition = 0;
}
}
static void lcd_move_z()
{
if (encoderPosition != 0)
{
refresh_cmd_timeout();
current_position[Z_AXIS] += float((int)encoderPosition) * move_menu_scale;
if (min_software_endstops && current_position[Z_AXIS] < Z_MIN_POS)
current_position[Z_AXIS] = Z_MIN_POS;
if (max_software_endstops && current_position[Z_AXIS] > Z_MAX_POS)
current_position[Z_AXIS] = Z_MAX_POS;
encoderPosition = 0;
#ifdef DELTA
calculate_delta(current_position);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[Z_AXIS]/60, active_extruder, active_driver);
#else
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[Z_AXIS]/60, active_extruder, active_driver);
#endif
lcdDrawUpdate = 1;
}
if (lcdDrawUpdate)
{
lcd_implementation_drawedit(PSTR("Z"), ftostr31(current_position[Z_AXIS]));
}
if (LCD_CLICKED)
{
lcd_quick_feedback();
currentMenu = lcd_move_menu_axis;
encoderPosition = 0;
}
} }
static void lcd_move_x() { _lcd_move(PSTR("X"), X_AXIS, X_MIN_POS, X_MAX_POS); }
static void lcd_move_y() { _lcd_move(PSTR("Y"), Y_AXIS, Y_MIN_POS, Y_MAX_POS); }
static void lcd_move_z() { _lcd_move(PSTR("Z"), Z_AXIS, Z_MIN_POS, Z_MAX_POS); }
static void lcd_move_e() static void lcd_move_e()
{ {
if (encoderPosition != 0) if (encoderPosition != 0)
...@@ -896,12 +847,7 @@ static void lcd_move_e() ...@@ -896,12 +847,7 @@ static void lcd_move_e()
{ {
lcd_implementation_drawedit(PSTR("Extruder"), ftostr31(current_position[E_AXIS])); lcd_implementation_drawedit(PSTR("Extruder"), ftostr31(current_position[E_AXIS]));
} }
if (LCD_CLICKED) if (LCD_CLICKED) lcd_goto_menu(lcd_move_menu_axis);
{
lcd_quick_feedback();
currentMenu = lcd_move_menu_axis;
encoderPosition = 0;
}
} }
static void lcd_move_menu_axis() static void lcd_move_menu_axis()
...@@ -1027,7 +973,7 @@ static void lcd_control_temperature_menu() ...@@ -1027,7 +973,7 @@ static void lcd_control_temperature_menu()
#if TEMP_SENSOR_3 != 0 #if TEMP_SENSOR_3 != 0
MENU_ITEM_EDIT(int3, MSG_NOZZLE3, &target_temperature[3], 0, HEATER_3_MAXTEMP - 15); MENU_ITEM_EDIT(int3, MSG_NOZZLE3, &target_temperature[3], 0, HEATER_3_MAXTEMP - 15);
#endif #endif
#endif // SINGLENOZZLE #endif // !SINGLENOZZLE
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
MENU_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); MENU_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
...@@ -1164,12 +1110,7 @@ static void lcd_set_contrast() ...@@ -1164,12 +1110,7 @@ static void lcd_set_contrast()
{ {
lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr2(lcd_contrast)); lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr2(lcd_contrast));
} }
if (LCD_CLICKED) if (LCD_CLICKED) lcd_goto_menu(lcd_control_menu);
{
lcd_quick_feedback();
currentMenu = lcd_control_menu;
encoderPosition = 0;
}
} }
#endif #endif
...@@ -1192,7 +1133,7 @@ static void lcd_control_retract_menu() ...@@ -1192,7 +1133,7 @@ static void lcd_control_retract_menu()
MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &retract_recover_feedrate, 1, 999); MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &retract_recover_feedrate, 1, 999);
END_MENU(); END_MENU();
} }
#endif #endif //FWRETRACT
#if SDCARDDETECT == -1 #if SDCARDDETECT == -1
static void lcd_sd_refresh() static void lcd_sd_refresh()
...@@ -1217,9 +1158,9 @@ void lcd_sdcard_menu() ...@@ -1217,9 +1158,9 @@ void lcd_sdcard_menu()
card.getWorkDirName(); card.getWorkDirName();
if(card.filename[0]=='/') if(card.filename[0]=='/')
{ {
#if SDCARDDETECT == -1 #if SDCARDDETECT == -1
MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh); MENU_ITEM(function, LCD_STR_REFRESH MSG_REFRESH, lcd_sd_refresh);
#endif #endif
}else{ }else{
MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir); MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
} }
...@@ -1228,22 +1169,15 @@ void lcd_sdcard_menu() ...@@ -1228,22 +1169,15 @@ void lcd_sdcard_menu()
{ {
if (_menuItemNr == _lineNr) if (_menuItemNr == _lineNr)
{ {
#if defined(SDCARD_RATHERRECENTFIRST) && !defined(SDCARD_SORT_ALPHA) #ifndef SDCARD_RATHERRECENTFIRST
int nr = fileCnt-1-i; card.getfilename(i);
#else #else
int nr = i; card.getfilename(fileCnt-1-i);
#endif #endif
if (card.filenameIsDir)
#ifdef SDCARD_SORT_ALPHA {
card.getfilename_sorted(nr);
#else
card.getfilename(nr);
#endif
if (card.filenameIsDir) {
MENU_ITEM(sddirectory, MSG_CARD_MENU, card.filename, card.longFilename); MENU_ITEM(sddirectory, MSG_CARD_MENU, card.filename, card.longFilename);
} }else{
else {
MENU_ITEM(sdfile, MSG_CARD_MENU, card.filename, card.longFilename); MENU_ITEM(sdfile, MSG_CARD_MENU, card.filename, card.longFilename);
} }
}else{ }else{
...@@ -1256,36 +1190,19 @@ void lcd_sdcard_menu() ...@@ -1256,36 +1190,19 @@ void lcd_sdcard_menu()
#define menu_edit_type(_type, _name, _strFunc, scale) \ #define menu_edit_type(_type, _name, _strFunc, scale) \
void menu_edit_ ## _name () \ void menu_edit_ ## _name () \
{ \ { \
if ((int32_t)encoderPosition < 0) \ if ((int32_t)encoderPosition < 0) encoderPosition = 0; \
encoderPosition = 0; \ if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue; \
if ((int32_t)encoderPosition > maxEditValue) \
encoderPosition = maxEditValue; \
if (lcdDrawUpdate) \ if (lcdDrawUpdate) \
lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \ lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \
if (LCD_CLICKED) \ if (LCD_CLICKED) \
{ \ { \
*((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) / scale; \ *((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) / scale; \
lcd_quick_feedback(); \ lcd_goto_menu(prevMenu, prevEncoderPosition); \
currentMenu = prevMenu; \
encoderPosition = prevEncoderPosition; \
} \
} \ } \
void menu_edit_callback_ ## _name () \
{ \
if ((int32_t)encoderPosition < 0) \
encoderPosition = 0; \
if ((int32_t)encoderPosition > maxEditValue) \
encoderPosition = maxEditValue; \
if (lcdDrawUpdate) \
lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \
if (LCD_CLICKED) \
{ \
*((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) / scale; \
lcd_quick_feedback(); \
currentMenu = prevMenu; \
encoderPosition = prevEncoderPosition; \
(*callbackFunc)();\
} \ } \
void menu_edit_callback_ ## _name () { \
menu_edit_ ## _name (); \
if (LCD_CLICKED) (*callbackFunc)(); \
} \ } \
static void menu_action_setting_edit_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue) \ static void menu_action_setting_edit_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue) \
{ \ { \
...@@ -1370,24 +1287,10 @@ static void lcd_quick_feedback() ...@@ -1370,24 +1287,10 @@ static void lcd_quick_feedback()
} }
/** Menu action functions **/ /** Menu action functions **/
static void menu_action_back(menuFunc_t data) static void menu_action_back(menuFunc_t data) { lcd_goto_menu(data); }
{ static void menu_action_submenu(menuFunc_t data) { lcd_goto_menu(data); }
currentMenu = data; static void menu_action_gcode(const char* pgcode) { enquecommand_P(pgcode); }
encoderPosition = 0; static void menu_action_function(menuFunc_t data) { (*data)(); }
}
static void menu_action_submenu(menuFunc_t data)
{
currentMenu = data;
encoderPosition = 0;
}
static void menu_action_gcode(const char* pgcode)
{
enquecommand_P(pgcode);
}
static void menu_action_function(menuFunc_t data)
{
(*data)();
}
static void menu_action_sdfile(const char* filename, char* longFilename) static void menu_action_sdfile(const char* filename, char* longFilename)
{ {
char cmd[30]; char cmd[30];
...@@ -1414,32 +1317,33 @@ static void menu_action_setting_edit_bool(const char* pstr, bool* ptr) ...@@ -1414,32 +1317,33 @@ static void menu_action_setting_edit_bool(const char* pstr, bool* ptr)
void lcd_init() void lcd_init()
{ {
lcd_implementation_init(); lcd_implementation_init();
lcd_message_init();
#ifdef NEWPANEL #ifdef NEWPANEL
pinMode(BTN_EN1,INPUT); SET_INPUT(BTN_EN1);
pinMode(BTN_EN2,INPUT); SET_INPUT(BTN_EN2);
WRITE(BTN_EN1,HIGH); WRITE(BTN_EN1,HIGH);
WRITE(BTN_EN2,HIGH); WRITE(BTN_EN2,HIGH);
#if BTN_ENC > 0 #if BTN_ENC > 0
pinMode(BTN_ENC,INPUT); SET_INPUT(BTN_ENC);
WRITE(BTN_ENC,HIGH); WRITE(BTN_ENC,HIGH);
#endif #endif
#ifdef REPRAPWORLD_KEYPAD #ifdef REPRAPWORLD_KEYPAD
pinMode(SHIFT_CLK,OUTPUT); SET_OUTPUT(SHIFT_CLK);
pinMode(SHIFT_LD,OUTPUT); SET_OUTPUT(SHIFT_LD);
pinMode(SHIFT_OUT,INPUT); SET_INPUT(SHIFT_OUT);
WRITE(SHIFT_OUT,HIGH); WRITE(SHIFT_OUT,HIGH);
WRITE(SHIFT_LD,HIGH); WRITE(SHIFT_LD,HIGH);
#endif #endif
#else // Not NEWPANEL #else // Not NEWPANEL
#ifdef SR_LCD_2W_NL // Non latching 2 wire shift register #ifdef SR_LCD_2W_NL // Non latching 2 wire shift register
pinMode (SR_DATA_PIN, OUTPUT); SET_OUTPUT(SR_DATA_PIN);
pinMode (SR_CLK_PIN, OUTPUT); SET_OUTPUT(SR_CLK_PIN);
#elif defined(SHIFT_CLK) #elif defined(SHIFT_CLK)
pinMode(SHIFT_CLK,OUTPUT); SET_OUTPUT(SHIFT_CLK);
pinMode(SHIFT_LD,OUTPUT); SET_OUTPUT(SHIFT_LD);
pinMode(SHIFT_EN,OUTPUT); SET_OUTPUT(SHIFT_EN);
pinMode(SHIFT_OUT,INPUT); SET_INPUT(SHIFT_OUT);
WRITE(SHIFT_OUT,HIGH); WRITE(SHIFT_OUT,HIGH);
WRITE(SHIFT_LD,HIGH); WRITE(SHIFT_LD,HIGH);
WRITE(SHIFT_EN,LOW); WRITE(SHIFT_EN,LOW);
...@@ -1450,8 +1354,8 @@ void lcd_init() ...@@ -1450,8 +1354,8 @@ void lcd_init()
#endif // SR_LCD_2W_NL #endif // SR_LCD_2W_NL
#endif//!NEWPANEL #endif//!NEWPANEL
#if defined(SDSUPPORT) && defined(SDCARDDETECT) && (SDCARDDETECT > 0) #if defined (SDSUPPORT) && defined(SDCARDDETECT) && (SDCARDDETECT > 0)
pinMode(SDCARDDETECT,INPUT); SET_INPUT(SDCARDDETECT);
WRITE(SDCARDDETECT, HIGH); WRITE(SDCARDDETECT, HIGH);
lcd_oldcardstatus = IS_SD_INSERTED; lcd_oldcardstatus = IS_SD_INSERTED;
#endif//(SDCARDDETECT > 0) #endif//(SDCARDDETECT > 0)
...@@ -1479,7 +1383,11 @@ void lcd_update() ...@@ -1479,7 +1383,11 @@ void lcd_update()
{ {
lcdDrawUpdate = 2; lcdDrawUpdate = 2;
lcd_oldcardstatus = IS_SD_INSERTED; lcd_oldcardstatus = IS_SD_INSERTED;
lcd_implementation_init(); // to maybe revive the LCD if static electricity killed it. lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
currentMenu == lcd_status_screen
#endif
);
if(lcd_oldcardstatus) if(lcd_oldcardstatus)
{ {
...@@ -1559,11 +1467,9 @@ void lcd_update() ...@@ -1559,11 +1467,9 @@ void lcd_update()
lcdDrawUpdate = 2; lcdDrawUpdate = 2;
} }
#endif//ULTIPANEL #endif//ULTIPANEL
if (lcdDrawUpdate == 2) if (lcdDrawUpdate == 2) lcd_implementation_clear();
lcd_implementation_clear(); if (lcdDrawUpdate) lcdDrawUpdate--;
if (lcdDrawUpdate) lcd_next_update_millis = millis() + LCD_UPDATE_INTERVAL;
lcdDrawUpdate--;
lcd_next_update_millis = millis() + 100;
} }
} }
...@@ -1573,35 +1479,39 @@ void lcd_ignore_click(bool b) ...@@ -1573,35 +1479,39 @@ void lcd_ignore_click(bool b)
wait_for_unclick = false; wait_for_unclick = false;
} }
void lcd_finishstatus() {
int len = strlen(lcd_status_message);
if (len > 0) {
while (len < LCD_WIDTH) {
lcd_status_message[len++] = ' ';
}
}
lcd_status_message[LCD_WIDTH] = '\0';
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
#if PROGRESS_BAR_MSG_EXPIRE > 0
messageTick =
#endif
progressBarTick = millis();
#endif
lcdDrawUpdate = 2;
#ifdef FILAMENT_LCD_DISPLAY
message_millis = millis(); //get status message to show up for a while
#endif
}
void lcd_setstatus(const char* message) void lcd_setstatus(const char* message)
{ {
if (lcd_status_message_level > 0) if (lcd_status_message_level > 0)
return; return;
strncpy(lcd_status_message, message, LCD_WIDTH); strncpy(lcd_status_message, message, LCD_WIDTH);
lcd_finishstatus();
size_t i = strlen(lcd_status_message);
memset(lcd_status_message + i, ' ', LCD_WIDTH - i);
lcd_status_message[LCD_WIDTH] = '\0';
lcdDrawUpdate = 2;
#ifdef FILAMENT_LCD_DISPLAY
message_millis=millis(); //get status message to show up for a while
#endif
} }
void lcd_setstatuspgm(const char* message) void lcd_setstatuspgm(const char* message)
{ {
if (lcd_status_message_level > 0) if (lcd_status_message_level > 0)
return; return;
strncpy_P(lcd_status_message, message, LCD_WIDTH); strncpy_P(lcd_status_message, message, LCD_WIDTH);
lcd_finishstatus();
size_t i = strlen(lcd_status_message);
memset(lcd_status_message + i, ' ', LCD_WIDTH - i);
lcd_status_message[LCD_WIDTH] = '\0';
lcdDrawUpdate = 2;
#ifdef FILAMENT_LCD_DISPLAY
message_millis=millis(); //get status message to show up for a while
#endif
} }
void lcd_setalertstatuspgm(const char* message) void lcd_setalertstatuspgm(const char* message)
{ {
...@@ -1677,10 +1587,8 @@ void lcd_buttons_update() ...@@ -1677,10 +1587,8 @@ void lcd_buttons_update()
//manage encoder rotation //manage encoder rotation
uint8_t enc=0; uint8_t enc=0;
if(buttons&EN_A) if (buttons & EN_A) enc |= B01;
enc|=(1<<0); if (buttons & EN_B) enc |= B10;
if(buttons&EN_B)
enc|=(1<<1);
if(enc != lastEncoderBits) if(enc != lastEncoderBits)
{ {
switch(enc) switch(enc)
...@@ -1756,7 +1664,7 @@ char *itostr2(const uint8_t &x) ...@@ -1756,7 +1664,7 @@ char *itostr2(const uint8_t &x)
return conv; return conv;
} }
// convert float to string with +123.4 format // Convert float to string with 123.4 format, dropping sign
char *ftostr31(const float &x) char *ftostr31(const float &x)
{ {
int xx=x*10; int xx=x*10;
...@@ -1771,7 +1679,7 @@ char *ftostr31(const float &x) ...@@ -1771,7 +1679,7 @@ char *ftostr31(const float &x)
return conv; return conv;
} }
// convert float to string with 123.4 format // Convert float to string with 123.4 format
char *ftostr31ns(const float &x) char *ftostr31ns(const float &x)
{ {
int xx=x*10; int xx=x*10;
...@@ -1803,7 +1711,7 @@ char *ftostr32(const float &x) ...@@ -1803,7 +1711,7 @@ char *ftostr32(const float &x)
return conv; return conv;
} }
//Float to string with 1.23 format // Convert float to string with 1.23 format
char *ftostr12ns(const float &x) char *ftostr12ns(const float &x)
{ {
long xx=x*100; long xx=x*100;
...@@ -1817,21 +1725,7 @@ char *ftostr12ns(const float &x) ...@@ -1817,21 +1725,7 @@ char *ftostr12ns(const float &x)
return conv; return conv;
} }
// convert float to space-padded string with -_23.4_ format // Convert int to lj string with +123.0 format
char *ftostr32np(const float &x)
{
char *c = ftostr32(x);
if (c[0] == '0' || c[0] == '-') {
if (c[0] == '0') c[0] = ' ';
if (c[1] == '0') c[1] = ' ';
}
if (c[5] == '0') {
c[5] = ' ';
if (c[4] == '0') c[4] = c[3] = ' ';
}
return c;
}
char *itostr31(const int &xx) char *itostr31(const int &xx)
{ {
conv[0]=(xx>=0)?'+':'-'; conv[0]=(xx>=0)?'+':'-';
...@@ -1844,6 +1738,7 @@ char *itostr31(const int &xx) ...@@ -1844,6 +1738,7 @@ char *itostr31(const int &xx)
return conv; return conv;
} }
// Convert int to rj string with 123 or -12 format
char *itostr3(const int &x) char *itostr3(const int &x)
{ {
int xx = x; int xx = x;
...@@ -1863,6 +1758,7 @@ char *itostr3(const int &x) ...@@ -1863,6 +1758,7 @@ char *itostr3(const int &x)
return conv; return conv;
} }
// Convert int to lj string with 123 format
char *itostr3left(const int &xx) char *itostr3left(const int &xx)
{ {
if (xx >= 100) if (xx >= 100)
...@@ -1886,22 +1782,13 @@ char *itostr3left(const int &xx) ...@@ -1886,22 +1782,13 @@ char *itostr3left(const int &xx)
return conv; return conv;
} }
char *itostr4(const int &xx) // Convert int to rj string with 1234 format
{ char *itostr4(const int &xx) {
if (xx >= 1000) conv[0] = xx >= 1000 ? (xx / 1000) % 10 + '0' : ' ';
conv[0]=(xx/1000)%10+'0'; conv[1] = xx >= 100 ? (xx / 100) % 10 + '0' : ' ';
else conv[2] = xx >= 10 ? (xx / 10) % 10 + '0' : ' ';
conv[0]=' '; conv[3] = xx % 10 + '0';
if (xx >= 100) conv[4] = 0;
conv[1]=(xx/100)%10+'0';
else
conv[1]=' ';
if (xx >= 10)
conv[2]=(xx/10)%10+'0';
else
conv[2]=' ';
conv[3]=(xx)%10+'0';
conv[4]=0;
return conv; return conv;
} }
...@@ -1949,32 +1836,19 @@ char *ftostr30(const float &x) ...@@ -1949,32 +1836,19 @@ char *ftostr30(const float &x)
return conv; return conv;
} }
// convert float to string with 12345 format // Convert float to rj string with 12345 format
char *ftostr5(const float &x) char *ftostr5(const float &x) {
{ long xx = abs(x);
long xx=abs(x); conv[0] = xx >= 10000 ? (xx / 10000) % 10 + '0' : ' ';
if (xx >= 10000) conv[1] = xx >= 1000 ? (xx / 1000) % 10 + '0' : ' ';
conv[0]=(xx/10000)%10+'0'; conv[2] = xx >= 100 ? (xx / 100) % 10 + '0' : ' ';
else conv[3] = xx >= 10 ? (xx / 10) % 10 + '0' : ' ';
conv[0]=' '; conv[4] = xx % 10 + '0';
if (xx >= 1000) conv[5] = 0;
conv[1]=(xx/1000)%10+'0';
else
conv[1]=' ';
if (xx >= 100)
conv[2]=(xx/100)%10+'0';
else
conv[2]=' ';
if (xx >= 10)
conv[3]=(xx/10)%10+'0';
else
conv[3]=' ';
conv[4]=(xx)%10+'0';
conv[5]=0;
return conv; return conv;
} }
// convert float to string with +1234.5 format // Convert float to string with +1234.5 format
char *ftostr51(const float &x) char *ftostr51(const float &x)
{ {
long xx=x*10; long xx=x*10;
...@@ -1990,7 +1864,7 @@ char *ftostr51(const float &x) ...@@ -1990,7 +1864,7 @@ char *ftostr51(const float &x)
return conv; return conv;
} }
// convert float to string with +123.45 format // Convert float to string with +123.45 format
char *ftostr52(const float &x) char *ftostr52(const float &x)
{ {
long xx=x*100; long xx=x*100;
......
...@@ -50,9 +50,9 @@ ...@@ -50,9 +50,9 @@
extern bool cancel_heatup; extern bool cancel_heatup;
#ifdef FILAMENT_LCD_DISPLAY #ifdef FILAMENT_LCD_DISPLAY
extern unsigned long message_millis; extern unsigned long message_millis;
#endif #endif
void lcd_buzz(long duration,uint16_t freq); void lcd_buzz(long duration,uint16_t freq);
bool lcd_clicked(); bool lcd_clicked();
...@@ -125,7 +125,6 @@ char *ftostr30(const float &x); ...@@ -125,7 +125,6 @@ char *ftostr30(const float &x);
char *ftostr31ns(const float &x); // float to string without sign character char *ftostr31ns(const float &x); // float to string without sign character
char *ftostr31(const float &x); char *ftostr31(const float &x);
char *ftostr32(const float &x); char *ftostr32(const float &x);
char *ftostr32np(const float &x); // remove zero-padding from ftostr32
char *ftostr12ns(const float &x); char *ftostr12ns(const float &x);
char *ftostr5(const float &x); char *ftostr5(const float &x);
char *ftostr51(const float &x); char *ftostr51(const float &x);
......
...@@ -191,6 +191,7 @@ extern volatile uint16_t buttons; //an extended version of the last checked but ...@@ -191,6 +191,7 @@ extern volatile uint16_t buttons; //an extended version of the last checked but
// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection // https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
#elif defined(SR_LCD_2W_NL) #elif defined(SR_LCD_2W_NL)
extern "C" void __cxa_pure_virtual() { while (1); }
#include <LCD.h> #include <LCD.h>
#include <LiquidCrystal_SR.h> #include <LiquidCrystal_SR.h>
#define LCD_CLASS LiquidCrystal_SR #define LCD_CLASS LiquidCrystal_SR
...@@ -208,6 +209,14 @@ extern volatile uint16_t buttons; //an extended version of the last checked but ...@@ -208,6 +209,14 @@ extern volatile uint16_t buttons; //an extended version of the last checked but
LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
#endif #endif
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
static uint16_t progressBarTick = 0;
#if PROGRESS_BAR_MSG_EXPIRE > 0
static uint16_t messageTick = 0;
#endif
#define LCD_STR_PROGRESS "\x03\x04\x05"
#endif
/* Custom characters defined in the first 8 characters of the LCD */ /* Custom characters defined in the first 8 characters of the LCD */
#define LCD_STR_BEDTEMP "\x00" #define LCD_STR_BEDTEMP "\x00"
#define LCD_STR_DEGREE "\x01" #define LCD_STR_DEGREE "\x01"
...@@ -219,8 +228,11 @@ extern volatile uint16_t buttons; //an extended version of the last checked but ...@@ -219,8 +228,11 @@ extern volatile uint16_t buttons; //an extended version of the last checked but
#define LCD_STR_CLOCK "\x07" #define LCD_STR_CLOCK "\x07"
#define LCD_STR_ARROW_RIGHT "\x7E" /* from the default character set */ #define LCD_STR_ARROW_RIGHT "\x7E" /* from the default character set */
static void lcd_implementation_init() static void lcd_set_custom_characters(
{ #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
bool progress_bar_set=true
#endif
) {
#ifdef DELTA #ifdef DELTA
byte bedTemp[8] = byte bedTemp[8] =
{ {
...@@ -319,6 +331,72 @@ static void lcd_implementation_init() ...@@ -319,6 +331,72 @@ static void lcd_implementation_init()
B00000 B00000
}; //thanks Sonny Mounicou }; //thanks Sonny Mounicou
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
static bool char_mode = false;
byte progress[3][8] = { {
B00000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B00000
}, {
B00000,
B10100,
B10100,
B10100,
B10100,
B10100,
B10100,
B00000
}, {
B00000,
B10101,
B10101,
B10101,
B10101,
B10101,
B10101,
B00000
} };
if (progress_bar_set != char_mode) {
char_mode = progress_bar_set;
lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
lcd.createChar(LCD_STR_DEGREE[0], degree);
lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);
lcd.createChar(LCD_STR_FEEDRATE[0], feedrate);
lcd.createChar(LCD_STR_CLOCK[0], clock);
if (progress_bar_set) {
// Progress bar characters for info screen
for (int i=3; i--;) lcd.createChar(LCD_STR_PROGRESS[i], progress[i]);
}
else {
// Custom characters for submenus
lcd.createChar(LCD_STR_UPLEVEL[0], uplevel);
lcd.createChar(LCD_STR_REFRESH[0], refresh);
lcd.createChar(LCD_STR_FOLDER[0], folder);
}
}
#else
lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
lcd.createChar(LCD_STR_DEGREE[0], degree);
lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);
lcd.createChar(LCD_STR_UPLEVEL[0], uplevel);
lcd.createChar(LCD_STR_REFRESH[0], refresh);
lcd.createChar(LCD_STR_FOLDER[0], folder);
lcd.createChar(LCD_STR_FEEDRATE[0], feedrate);
lcd.createChar(LCD_STR_CLOCK[0], clock);
#endif
}
static void lcd_implementation_init(
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
bool progress_bar_set=true
#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
...@@ -343,14 +421,12 @@ static void lcd_implementation_init() ...@@ -343,14 +421,12 @@ static void lcd_implementation_init()
lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.begin(LCD_WIDTH, LCD_HEIGHT);
#endif #endif
lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp); lcd_set_custom_characters(
lcd.createChar(LCD_STR_DEGREE[0], degree); #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
lcd.createChar(LCD_STR_THERMOMETER[0], thermometer); progress_bar_set
lcd.createChar(LCD_STR_UPLEVEL[0], uplevel); #endif
lcd.createChar(LCD_STR_REFRESH[0], refresh); );
lcd.createChar(LCD_STR_FOLDER[0], folder);
lcd.createChar(LCD_STR_FEEDRATE[0], feedrate);
lcd.createChar(LCD_STR_CLOCK[0], clock);
lcd.clear(); lcd.clear();
} }
static void lcd_implementation_clear() static void lcd_implementation_clear()
...@@ -405,7 +481,7 @@ static void lcd_implementation_status_screen() ...@@ -405,7 +481,7 @@ static void lcd_implementation_status_screen()
lcd.print('/'); lcd.print('/');
lcd.print(itostr3left(tTarget)); lcd.print(itostr3left(tTarget));
# if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 && !defined(SINGLENOZZLE) # 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)
...@@ -420,7 +496,7 @@ static void lcd_implementation_status_screen() ...@@ -420,7 +496,7 @@ static void lcd_implementation_status_screen()
lcd.print(itostr3(tHotend)); lcd.print(itostr3(tHotend));
lcd.print('/'); lcd.print('/');
lcd.print(itostr3left(tTarget)); lcd.print(itostr3left(tTarget));
# endif//EXTRUDERS > 1 || 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);
...@@ -432,7 +508,7 @@ static void lcd_implementation_status_screen() ...@@ -432,7 +508,7 @@ static void lcd_implementation_status_screen()
if (tTarget < 10) if (tTarget < 10)
lcd.print(' '); lcd.print(' ');
# if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 && !defined(SINGLENOZZLE) # 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)
...@@ -450,8 +526,8 @@ static void lcd_implementation_status_screen() ...@@ -450,8 +526,8 @@ static void lcd_implementation_status_screen()
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 || 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
...@@ -496,7 +572,7 @@ static void lcd_implementation_status_screen() ...@@ -496,7 +572,7 @@ static void lcd_implementation_status_screen()
# endif//LCD_WIDTH > 19 # endif//LCD_WIDTH > 19
lcd.setCursor(LCD_WIDTH - 8, 1); lcd.setCursor(LCD_WIDTH - 8, 1);
lcd.print('Z'); lcd.print('Z');
lcd.print(ftostr32np(current_position[Z_AXIS] + 0.00001)); lcd.print(ftostr32(current_position[Z_AXIS] + 0.00001));
#endif//LCD_HEIGHT > 2 #endif//LCD_HEIGHT > 2
#if LCD_HEIGHT > 3 #if LCD_HEIGHT > 3
...@@ -528,23 +604,46 @@ static void lcd_implementation_status_screen() ...@@ -528,23 +604,46 @@ static void lcd_implementation_status_screen()
} }
#endif #endif
// Status message line at the bottom
lcd.setCursor(0, LCD_HEIGHT - 1);
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
if (card.isFileOpen()) {
uint16_t mil = millis(), diff = mil - progressBarTick;
if (diff >= PROGRESS_BAR_MSG_TIME || !lcd_status_message[0]) {
// draw the progress bar
int tix = (int)(card.percentDone() * LCD_WIDTH * 3) / 100,
cel = tix / 3, rem = tix % 3, i = LCD_WIDTH;
char msg[LCD_WIDTH+1], b = ' ';
msg[i] = '\0';
while (i--) {
if (i == cel - 1)
b = LCD_STR_PROGRESS[2];
else if (i == cel && rem != 0)
b = LCD_STR_PROGRESS[rem-1];
msg[i] = b;
}
lcd.print(msg);
return;
}
} //card.isFileOpen
#endif //LCD_PROGRESS_BAR
//Display both Status message line and Filament display on the last line //Display both Status message line and Filament display on the last line
#ifdef FILAMENT_LCD_DISPLAY #ifdef FILAMENT_LCD_DISPLAY
if(message_millis+5000>millis()){ //display any status for the first 5 sec after screen is initiated if (message_millis + 5000 <= millis()) { //display any status for the first 5 sec after screen is initiated
lcd.setCursor(0, LCD_HEIGHT - 1);
lcd.print(lcd_status_message);
} else {
lcd.setCursor(0,LCD_HEIGHT - 1);
lcd_printPGM(PSTR("Dia ")); lcd_printPGM(PSTR("Dia "));
lcd.print(ftostr12ns(filament_width_meas)); lcd.print(ftostr12ns(filament_width_meas));
lcd_printPGM(PSTR(" V")); lcd_printPGM(PSTR(" V"));
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 #endif //FILAMENT_LCD_DISPLAY
lcd.setCursor(0, LCD_HEIGHT - 1);
lcd.print(lcd_status_message); lcd.print(lcd_status_message);
#endif
} }
static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char)
{ {
...@@ -824,4 +923,22 @@ static uint8_t lcd_implementation_read_slow_buttons() ...@@ -824,4 +923,22 @@ static uint8_t lcd_implementation_read_slow_buttons()
} }
#endif #endif
static void lcd_message_init()
{
static String message[4];
message[0] = "MARLINKIMBRA V4.0";
message[1] = "By MagoKimbra";
message[2] = "magokimbra@hotmail";
message[3] = ".com";
lcd.clear();
for(int8_t i=0;i<4;i++){
lcd.setCursor(0,i);
lcd.print(message[i]);
}
delay(5000);
lcd.clear();
}
#endif//ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H #endif//ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H
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