Commit df61c152 authored by MagoKimbra's avatar MagoKimbra

Update

parent 4af24b14
......@@ -2,7 +2,6 @@
#define CONFIGURATION_H
#include "boards.h"
#include "macros.h"
//===========================================================================
//============================= Getting Started =============================
......@@ -65,13 +64,13 @@
/***********************************************************************\
********************** Do not touch this section **********************
***********************************************************************/
#if ENABLED(CARTESIAN)
#if defined(CARTESIAN)
#include "Configuration_Cartesian.h"
#elif ENABLED(COREXY)
#elif defined(COREXY)
#include "Configuration_Corexy.h"
#elif ENABLED(DELTA)
#elif defined(DELTA)
#include "Configuration_Delta.h"
#elif ENABLED(SCARA)
#elif defined(SCARA)
#include "Configuration_Scara.h"
#endif
/***********************************************************************/
......@@ -603,7 +602,7 @@
//#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament
// It is assumed that when logic high = filament available
// when logic low = filament run out
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
#ifdef FILAMENT_RUNOUT_SENSOR
const bool FILRUNOUT_PIN_INVERTING = true; // Should be uncommented and true or false should assigned
#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined.
#define FILAMENT_RUNOUT_SCRIPT "M600" // Script execute when filament run out
......
......@@ -9,7 +9,7 @@
// coarse Endstop Settings
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
#if DISABLED(ENDSTOPPULLUPS)
#ifndef ENDSTOPPULLUPS
// fine endstop settings: Individual pullups. will be ignored if ENDSTOPPULLUPS is defined
// #define ENDSTOPPULLUP_XMAX
// #define ENDSTOPPULLUP_YMAX
......@@ -76,10 +76,10 @@
#define E_MIN_POS 0
//=====================================================================================
//============================= Bed Manual or Auto Leveling ===========================
//================ Manual Bed Leveling (MBL) or Auto Bed Leveling =====================
//=====================================================================================
// set the rectangle in which to probe in manual or automatic
// set the rectangle in which to probe in MBL or ABL
#define LEFT_PROBE_BED_POSITION 20
#define RIGHT_PROBE_BED_POSITION 180
#define FRONT_PROBE_BED_POSITION 20
......@@ -90,7 +90,7 @@
//If you have enabled the Auto Bed Levelling and are using the same Z Probe for Z Homing,
//it is highly recommended you let this Z_SAFE_HOMING enabled!!!
//#define Z_SAFE_HOMING
#if ENABLED(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) or homing Z
#define Z_SAFE_HOMING_Y_POINT (Y_MAX_LENGTH/2) // Y point for Z homing when homing all axis (G28) or homing Z
#endif
......@@ -98,7 +98,7 @@
//#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (ABL)
//#define Z_PROBE_REPEATABILITY_TEST // Delete the comment to enable
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
// There are 2 different ways to specify probing locations
//
......@@ -176,7 +176,7 @@
//#define BED_CENTER_AT_0_0 // If defined, the center of the bed is at (X=0, Y=0)
//Manual homing switch locations:
#if ENABLED(MANUAL_HOME_POSITIONS)
#ifdef MANUAL_HOME_POSITIONS
#define MANUAL_X_HOME_POS 0
#define MANUAL_Y_HOME_POS 0
#define MANUAL_Z_HOME_POS 0
......@@ -210,7 +210,7 @@
// Custom M code points
//#define CUSTOM_M_CODES
#if ENABLED(CUSTOM_M_CODES)
#ifdef CUSTOM_M_CODES
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
......
......@@ -9,7 +9,7 @@
// coarse Endstop Settings
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
#if DISABLED(ENDSTOPPULLUPS)
#ifndef ENDSTOPPULLUPS
// fine endstop settings: Individual pullups. will be ignored if ENDSTOPPULLUPS is defined
// #define ENDSTOPPULLUP_XMAX
// #define ENDSTOPPULLUP_YMAX
......@@ -90,7 +90,7 @@
//If you have enabled the Auto Bed Levelling and are using the same Z Probe for Z Homing,
//it is highly recommended you let this Z_SAFE_HOMING enabled!!!
//#define Z_SAFE_HOMING
#if ENABLED(Z_SAFE_HOMING)
#ifndef Z_SAFE_HOMING
#define Z_SAFE_HOMING_X_POINT (X_MAX_LENGTH/2) // X point for Z homing when homing all axis (G28) or homing Z
#define Z_SAFE_HOMING_Y_POINT (Y_MAX_LENGTH/2) // Y point for Z homing when homing all axis (G28) or homing Z
#endif
......@@ -98,7 +98,7 @@
//#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (ABL)
//#define Z_PROBE_REPEATABILITY_TEST // Delete the comment to enable
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
// There are 2 different ways to specify probing locations
//
......@@ -115,7 +115,7 @@
// Note: this feature generates 10KB extra code size
#define AUTO_BED_LEVELING_GRID
#if ENABLED(AUTO_BED_LEVELING_GRID)
#ifdef AUTO_BED_LEVELING_GRID
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
......@@ -176,7 +176,7 @@
//#define BED_CENTER_AT_0_0 // If defined, the center of the bed is at (X=0, Y=0)
//Manual homing switch locations:
#if ENABLED(MANUAL_HOME_POSITIONS)
#ifdef MANUAL_HOME_POSITIONS
#define MANUAL_X_HOME_POS 0
#define MANUAL_Y_HOME_POS 0
#define MANUAL_Z_HOME_POS 0
......@@ -210,7 +210,7 @@
// Custom M code points
//#define CUSTOM_M_CODES
#if ENABLED(CUSTOM_M_CODES)
#ifdef CUSTOM_M_CODES
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
......
......@@ -56,7 +56,7 @@
// coarse Endstop Settings
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
#if DISABLED(ENDSTOPPULLUPS)
#ifndef ENDSTOPPULLUPS
// fine endstop settings: Individual pullups. will be ignored if ENDSTOPPULLUPS is defined
// #define ENDSTOPPULLUP_XMAX
// #define ENDSTOPPULLUP_YMAX
......
......@@ -17,7 +17,7 @@
//=============================Thermal Settings ============================
//===========================================================================
#if ENABLED(BED_LIMIT_SWITCHING)
#ifdef BED_LIMIT_SWITCHING
#define BED_HYSTERESIS 2 //only disable heating if T>target+BED_HYSTERESIS and enable heating if T>target-BED_HYSTERESIS
#endif
#define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control
......@@ -25,7 +25,7 @@
/**
* Thermal Protection parameters
*/
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#ifdef THERMAL_PROTECTION_HOTENDS
#define THERMAL_PROTECTION_PERIOD 40 // Seconds
#define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius
......@@ -39,7 +39,7 @@
#define WATCH_TEMP_INCREASE 4 // Degrees Celsius
#endif
#if ENABLED(THERMAL_PROTECTION_BED)
#ifdef THERMAL_PROTECTION_BED
#define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds
#define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius
#endif
......@@ -56,7 +56,7 @@
* On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode
*/
#define AUTOTEMP
#if ENABLED(AUTOTEMP)
#ifdef AUTOTEMP
#define AUTOTEMP_OLDWEIGHT 0.98
#endif
......@@ -135,7 +135,7 @@
// On a RAMPS (or other 5 driver) motherboard, using this feature will limit you to using 1 extruder.
//#define Z_DUAL_STEPPER_DRIVERS
#if ENABLED(Z_DUAL_STEPPER_DRIVERS)
#ifdef Z_DUAL_STEPPER_DRIVERS
// Z_DUAL_ENDSTOPS is a feature to enable the use of 2 endstops for both Z steppers - Let's call them Z stepper and Z2 stepper.
// That way the machine is capable to align the bed during home, since both Z steppers are homed.
......@@ -148,7 +148,7 @@
#define Z_DUAL_ENDSTOPS
#if ENABLED(Z_DUAL_ENDSTOPS)
#ifdef Z_DUAL_ENDSTOPS
#define Z2_STEP_PIN E2_STEP_PIN // Stepper to be used to Z2 axis.
#define Z2_DIR_PIN E2_DIR_PIN
#define Z2_ENABLE_PIN E2_ENABLE_PIN
......@@ -170,7 +170,7 @@
// prevents hot-end ooze contaminating the print. It also reduces the weight of each x-carriage
// allowing faster printing speeds.
//#define DUAL_X_CARRIAGE
#if ENABLED(DUAL_X_CARRIAGE)
#ifdef DUAL_X_CARRIAGE
// Configuration for second X-carriage
// Note: the first x-carriage is defined as the x-carriage which homes to the minimum endstop;
// the second x-carriage always homes to the maximum endstop.
......@@ -236,7 +236,7 @@
#define DEFAULT_MINIMUMFEEDRATE 0.0 // minimum feedrate
#define DEFAULT_MINTRAVELFEEDRATE 0.0
#if ENABLED(ULTIPANEL)
#ifdef ULTIPANEL
#define MANUAL_FEEDRATE {50*60, 50*60, 4*60, 60} // Feedrates for manual moves along X, Y, Z, E from panel
#define ULTIPANEL_FEEDMULTIPLY // Comment to disable setting feedrate multiplier via encoder
#endif
......@@ -305,7 +305,7 @@
// Show a progress bar on HD44780 LCDs for SD printing
//#define LCD_PROGRESS_BAR
#if ENABLED(LCD_PROGRESS_BAR)
#ifdef LCD_PROGRESS_BAR
// Amount of time (ms) to show the bar
#define PROGRESS_BAR_BAR_TIME 5000
// Amount of time (ms) to show the status message
......@@ -322,7 +322,7 @@
#endif // SDSUPPORT
// for dogm lcd displays you can choose some additional fonts:
#if ENABLED(DOGLCD)
#ifdef DOGLCD
// save 3120 bytes of PROGMEM by commenting out #define USE_BIG_EDIT_FONT
// we don't have a big font for Cyrillic, Kana
//#define USE_BIG_EDIT_FONT
......@@ -335,7 +335,7 @@
// The hardware watchdog should reset the microcontroller disabling all outputs, in case the firmware gets stuck and doesn't do temperature regulation.
//#define USE_WATCHDOG
#if ENABLED(USE_WATCHDOG)
#ifdef USE_WATCHDOG
// If you have a watchdog reboot in an ArduinoMega2560 then the device will hang forever, as a watchdog reset will leave the watchdog on.
// The "WATCHDOG_RESET_MANUAL" goes around this by not using the hardware reset.
// However, THIS FEATURE IS UNSAFE!, as it will only work if interrupts are disabled. And the code could hang in an interrupt routine with interrupts disabled.
......@@ -349,7 +349,7 @@
// it can e.g. be used to change z-positions in the print startup phase in real-time
// does not respect endstops!
//#define BABYSTEPPING
#if ENABLED(BABYSTEPPING)
#ifdef BABYSTEPPING
#define BABYSTEP_XY //not only z, but also XY in the menu. more clutter, more functions
#define BABYSTEP_INVERT_Z false //true for inverse movements in Z
#define BABYSTEP_Z_MULTIPLICATOR 2 //faster z movements
......@@ -364,7 +364,7 @@
// so: v ^ 2 is proportional to number of steps we advance the extruder
//#define ADVANCE
#if ENABLED(ADVANCE)
#ifdef ADVANCE
#define EXTRUDER_ADVANCE_K .0
#define D_FILAMENT 2.85
#define STEPS_MM_E 836
......@@ -385,7 +385,7 @@ const unsigned int dropsegments = 5; // everything with less than this number of
// The number of linear motions that can be in the plan at any give time.
// THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ring-buffering.
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
#define BLOCK_BUFFER_SIZE 16 // SD,LCD,Buttons take more memory, block buffer needs to be smaller
#else
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
......@@ -412,7 +412,7 @@ const unsigned int dropsegments = 5; // everything with less than this number of
// the moves are than replaced by the firmware controlled ones.
//#define FWRETRACT //ONLY PARTIALLY TESTED
#if ENABLED(FWRETRACT)
#ifdef FWRETRACT
#define MIN_RETRACT 0.1 //minimum extruded mm to accept a automatic gcode retraction attempt
#define RETRACT_LENGTH 3 //default retract length (positive mm)
#define RETRACT_LENGTH_SWAP 13 //default swap retract length (positive mm), for extruder change
......@@ -424,9 +424,9 @@ const unsigned int dropsegments = 5; // everything with less than this number of
#endif
// Add support for filament exchange support M600; requires display
#if ENABLED(ULTIPANEL)
#ifdef ULTIPANEL
#define FILAMENTCHANGEENABLE
#if ENABLED(FILAMENTCHANGEENABLE)
#ifdef FILAMENTCHANGEENABLE
#define FILAMENTCHANGE_XPOS 3
#define FILAMENTCHANGE_YPOS 3
#define FILAMENTCHANGE_ZADD 10
......@@ -442,7 +442,7 @@ const unsigned int dropsegments = 5; // everything with less than this number of
******************************************************************************/
//#define HAVE_TMCDRIVER
#if ENABLED(HAVE_TMCDRIVER)
#ifdef HAVE_TMCDRIVER
// #define X_IS_TMC
#define X_MAX_CURRENT 1000 //in mA
......@@ -502,7 +502,7 @@ const unsigned int dropsegments = 5; // everything with less than this number of
******************************************************************************/
//#define HAVE_L6470DRIVER
#if ENABLED(HAVE_L6470DRIVER)
#ifdef HAVE_L6470DRIVER
// #define X_IS_L6470
#define X_MICROSTEPS 16 //number of microsteps
......
......@@ -35,6 +35,22 @@
#include "WProgram.h"
#endif
// Macros for bit masks
#define BIT(b) (1<<(b))
#define TEST(n,b) (((n)&BIT(b))!=0)
#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
// Macros for maths shortcuts
#define M_PI 3.1415926536
#define RADIANS(d) ((d)*M_PI/180.0)
#define DEGREES(r) ((r)*180.0/M_PI)
#define SIN_60 0.8660254037844386
#define COS_60 0.5
// Macros to contrain values
#define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
#define NOMORE(v,n) do{ if (v > n) v = n; }while(0)
typedef unsigned long millis_t;
// Arduino < 1.0.0 does not define this, so we need to do it ourselves
......@@ -50,7 +66,7 @@ void idle(bool ignore_stepper_queue = false);
void manage_inactivity(bool ignore_stepper_queue=false);
#if ENABLED(DUAL_X_CARRIAGE) && HAS_X_ENABLE && HAS_X2_ENABLE
#if defined(DUAL_X_CARRIAGE) && HAS_X_ENABLE && HAS_X2_ENABLE
#define enable_x() do { X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); } while (0)
#define disable_x() do { X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; } while (0)
#elif HAS_X_ENABLE
......@@ -62,7 +78,7 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#endif
#if HAS_Y_ENABLE
#if ENABLED(Y_DUAL_STEPPER_DRIVERS)
#ifdef Y_DUAL_STEPPER_DRIVERS
#define enable_y() { Y_ENABLE_WRITE( Y_ENABLE_ON); Y2_ENABLE_WRITE(Y_ENABLE_ON); }
#define disable_y() { Y_ENABLE_WRITE(!Y_ENABLE_ON); Y2_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
#else
......@@ -75,7 +91,7 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#endif
#if HAS_Z_ENABLE
#if ENABLED(Z_DUAL_STEPPER_DRIVERS)
#ifdef Z_DUAL_STEPPER_DRIVERS
#define enable_z() { Z_ENABLE_WRITE( Z_ENABLE_ON); Z2_ENABLE_WRITE(Z_ENABLE_ON); }
#define disable_z() { Z_ENABLE_WRITE(!Z_ENABLE_ON); Z2_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#else
......@@ -142,25 +158,25 @@ void disable_all_steppers();
void FlushSerialRequestResend();
void ok_to_send();
#if ENABLED(DELTA)
float probe_bed(float x, float y);
void set_delta_constants();
void home_delta_axis();
void calibration_report();
void bed_probe_all();
void set_default_z_probe_offset();
void set_delta_constants();
void save_carriage_positions(int position_num);
void calculate_delta(float cartesian[3]);
void adjust_delta(float cartesian[3]);
void prepare_move_raw();
extern float delta[3];
extern float delta_tmp[3];
extern float delta_tower1_x, delta_tower1_y;
extern float delta_tower2_x, delta_tower2_y;
extern float delta_tower3_x, delta_tower3_y;
#ifdef DELTA
float probe_bed(float x, float y);
void set_delta_constants();
void home_delta_axis();
void calibration_report();
void bed_probe_all();
void set_default_z_probe_offset();
void set_delta_constants();
void save_carriage_positions(int position_num);
void calculate_delta(float cartesian[3]);
void adjust_delta(float cartesian[3]);
void prepare_move_raw();
extern float delta[3];
extern float delta_tmp[3];
extern float delta_tower1_x, delta_tower1_y;
extern float delta_tower2_x, delta_tower2_y;
extern float delta_tower3_x, delta_tower3_y;
#endif
#if ENABLED(SCARA)
#ifdef SCARA
void calculate_delta(float cartesian[3]);
void calculate_SCARA_forward_Transform(float f_scara[3]);
#endif
......@@ -168,7 +184,7 @@ void prepare_move();
void kill(const char *);
void Stop();
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
#ifdef FILAMENT_RUNOUT_SENSOR
void filrunout();
#endif
......@@ -197,7 +213,7 @@ void clamp_to_software_endstops(float target[3]);
extern millis_t previous_cmd_ms;
inline void refresh_cmd_timeout() { previous_cmd_ms = millis(); }
#if ENABLED(FAST_PWM_FAN)
#ifdef FAST_PWM_FAN
void setPwmFrequency(uint8_t pin, int val);
#endif
......@@ -227,22 +243,22 @@ extern float home_offset[3];
extern float hotend_offset[NUM_HOTEND_OFFSETS][HOTENDS];
#endif // HOTENDS > 1
#if ENABLED(NPR2)
#ifdef NPR2
extern int old_color; // old color for system NPR2
#endif
#if ENABLED(DELTA)
#ifdef DELTA
extern float z_probe_offset[3];
extern float endstop_adj[3];
extern float tower_adj[6];
extern float delta_radius;
extern float delta_diagonal_rod;
extern float delta_segments_per_second;
#elif ENABLED(Z_DUAL_ENDSTOPS)
#elif defined(Z_DUAL_ENDSTOPS)
extern float z_endstop_adj;
#endif
#if ENABLED(SCARA)
#ifdef SCARA
extern float axis_scaling[3]; // Build size scaling
#endif
......@@ -255,18 +271,18 @@ extern float zprobe_zoffset;
// Lifetime stats
extern unsigned long printer_usage_seconds; //this can old about 136 year before go overflow. If you belive that you can live more than this please contact me.
#if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
#ifdef PREVENT_DANGEROUS_EXTRUDE
extern float extrude_min_temp;
#endif
extern int fanSpeed;
#if ENABLED(BARICUDA)
#ifdef BARICUDA
extern int ValvePressure;
extern int EtoPPressure;
#endif
#if ENABLED(FAN_SOFT_PWM)
#ifdef FAN_SOFT_PWM
extern unsigned char fanSpeedSoftPwm;
#endif
......@@ -287,26 +303,26 @@ extern int fanSpeed;
extern unsigned long stoppower;
#endif
#if ENABLED(IDLE_OOZING_PREVENT)
#ifdef IDLE_OOZING_PREVENT
extern bool idleoozing_enabled;
#endif
#if ENABLED(FWRETRACT)
#ifdef FWRETRACT
extern bool autoretract_enabled;
extern bool retracted[EXTRUDERS];
extern float retract_length, retract_length_swap, retract_feedrate, retract_zlift;
extern float retract_recover_length, retract_recover_length_swap, retract_recover_feedrate;
#endif
#if ENABLED(EASY_LOAD)
#ifdef EASY_LOAD
extern bool allow_lengthy_extrude_once; // for load/unload
#endif
#if ENABLED(LASERBEAM)
#ifdef LASERBEAM
extern int laser_ttl_modulation;
#endif
#if ENABLED(SDSUPPORT) && ENABLED(SD_SETTINGS)
#if defined(SDSUPPORT) && defined(SD_SETTINGS)
extern millis_t config_last_update;
extern bool config_readed;
#endif
......@@ -318,12 +334,12 @@ extern millis_t print_job_stop_ms;
extern uint8_t active_extruder;
extern uint8_t active_driver;
#if ENABLED(DIGIPOT_I2C)
#ifdef DIGIPOT_I2C
extern void digipot_i2c_set_current( int channel, float current );
extern void digipot_i2c_init();
#endif
#if ENABLED(FIRMWARE_TEST)
#ifdef FIRMWARE_TEST
void FirmwareTest();
#endif
......
......@@ -287,6 +287,6 @@ MarlinSerial MSerial;
#endif // !AT90USB
// For AT90USB targets use the UART for BT interfacing
#if defined(AT90USB) && ENABLED(BTENABLED)
#if defined(AT90USB) && defined(BTENABLED)
HardwareSerial bt;
#endif
......@@ -153,7 +153,7 @@ extern MarlinSerial MSerial;
#endif // !AT90USB
// Use the UART for BT in AT90USB configurations
#if defined(AT90USB) && ENABLED(BTENABLED)
#if defined(AT90USB) && defined(BTENABLED)
extern HardwareSerial bt;
#endif
......
......@@ -147,7 +147,7 @@
* M112 - Emergency stop
* M114 - Output current position to serial port, (V)erbose for user
* M115 - Capabilities string
* M117 - display message
* M117 - Display a message on the controller screen
* M119 - Output Endstop status to serial port
* M120 - Enable endstop detection
* M121 - Disable endstop detection
......@@ -231,7 +231,7 @@
bool Running = true;
uint8_t debugLevel = DEBUG_INFO|DEBUG_COMMUNICATION;
uint8_t debugLevel = DEBUG_INFO|DEBUG_ERRORS;
static float feedrate = 1500.0, saved_feedrate;
float current_position[NUM_AXIS] = { 0.0 };
......@@ -286,12 +286,12 @@ bool target_direction;
unsigned long printer_usage_seconds;
#if DISABLED(DELTA)
#ifndef DELTA
int xy_travel_speed = XY_TRAVEL_SPEED;
float zprobe_zoffset = 0;
#endif
#if ENABLED(Z_DUAL_ENDSTOPS) && DISABLED(DELTA)
#if defined(Z_DUAL_ENDSTOPS) && !defined(DELTA)
float z_endstop_adj = 0;
#endif
......@@ -305,7 +305,7 @@ unsigned long printer_usage_seconds;
float hotend_offset[NUM_HOTEND_OFFSETS][HOTENDS];
#endif
#if ENABLED(NPR2)
#ifdef NPR2
int old_color = 99;
#endif
......@@ -314,12 +314,13 @@ unsigned long printer_usage_seconds;
int servo_endstop_angles[] = SERVO_ENDSTOP_ANGLES;
#endif
#if ENABLED(BARICUDA)
#ifdef BARICUDA
int ValvePressure = 0;
int EtoPPressure = 0;
#endif
#if ENABLED(FWRETRACT)
#ifdef FWRETRACT
bool autoretract_enabled = false;
bool retracted[EXTRUDERS] = { false };
bool retracted_swap[EXTRUDERS] = { false };
......@@ -331,9 +332,10 @@ unsigned long printer_usage_seconds;
float retract_recover_length = RETRACT_RECOVER_LENGTH;
float retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
float retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
#endif // FWRETRACT
#if ENABLED(ULTIPANEL) && HAS_POWER_SWITCH
#if defined(ULTIPANEL) && HAS_POWER_SWITCH
bool powersupply =
#ifdef PS_DEFAULT_OFF
false
......@@ -343,7 +345,7 @@ unsigned long printer_usage_seconds;
;
#endif
#if ENABLED(DELTA)
#ifdef DELTA
float delta[3] = { 0.0 };
float tower_adj[6] = { 0, 0, 0, 0, 0, 0 };
float delta_radius; // = DEFAULT_delta_radius;
......@@ -396,7 +398,7 @@ unsigned long printer_usage_seconds;
static bool home_all_axis = true;
#endif // DELTA
#if ENABLED(SCARA)
#ifdef SCARA
float delta_segments_per_second = SCARA_SEGMENTS_PER_SECOND;
static float delta[3] = { 0 };
float axis_scaling[3] = { 1, 1, 1 }; // Build size scaling, default to 1
......@@ -419,7 +421,7 @@ unsigned long printer_usage_seconds;
bool printing = false;
#endif
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
static bool fromsd[BUFSIZE];
#ifdef SD_SETTINGS
millis_t config_last_update = 0;
......@@ -427,16 +429,16 @@ unsigned long printer_usage_seconds;
#endif
#endif
#if ENABLED(FILAMENTCHANGEENABLE)
#ifdef FILAMENTCHANGEENABLE
bool filament_changing = false;
#endif
#if ENABLED(IDLE_OOZING_PREVENT) || ENABLED(EXTRUDER_RUNOUT_PREVENT)
#if defined(IDLE_OOZING_PREVENT) || defined(EXTRUDER_RUNOUT_PREVENT)
unsigned long axis_last_activity = 0;
bool axis_is_moving = false;
#endif
#if ENABLED(IDLE_OOZING_PREVENT)
#ifdef IDLE_OOZING_PREVENT
bool idleoozing_enabled = true;
bool IDLE_OOZING_retracted[EXTRUDERS] = ARRAY_BY_EXTRUDERS(false, false, false, false);
#endif
......@@ -448,16 +450,16 @@ unsigned long printer_usage_seconds;
unsigned long stoppower = 0;
#endif
#if ENABLED(LASERBEAM)
#ifdef LASERBEAM
int laser_ttl_modulation = 0;
#endif
#if ENABLED(NPR2)
#ifdef NPR2
static float color_position[] = COLOR_STEP;
static float color_step_moltiplicator = (DRIVER_MICROSTEP / MOTOR_ANGLE) * CARTER_MOLTIPLICATOR;
#endif // NPR2
#if ENABLED(EASY_LOAD)
#ifdef EASY_LOAD
bool allow_lengthy_extrude_once; // for load/unload
#endif
......@@ -478,7 +480,7 @@ void process_next_command();
bool setTargetedHotend(int code);
#if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
#ifdef PREVENT_DANGEROUS_EXTRUDE
float extrude_min_temp = EXTRUDE_MINTEMP;
#endif
......@@ -555,7 +557,8 @@ bool enqueuecommand(const char *cmd) {
// This is dangerous if a mixing of serial and this happens
char *command = command_queue[cmd_queue_index_w];
strcpy(command, cmd);
ECHO_LMV(DB, MSG_ENQUEUEING, command);
ECHO_SMV(DB, MSG_ENQUEUEING, command);
ECHO_EM("\"");
cmd_queue_index_w = (cmd_queue_index_w + 1) % BUFSIZE;
commands_in_queue++;
return true;
......@@ -684,7 +687,7 @@ void setup() {
SERIAL_INIT(BAUDRATE);
ECHO_S(START);
ECHO_E;
ECHO_S(DB);
// Check startup - does nothing if bootloader sets MCUSR to 0
byte mcu = MCUSR;
......@@ -699,14 +702,15 @@ void setup() {
#ifdef STRING_VERSION_CONFIG_H
#ifdef STRING_CONFIG_H_AUTHOR
ECHO_LM(OK, MSG_CONFIGURATION_VER STRING_VERSION_CONFIG_H MSG_AUTHOR STRING_CONFIG_H_AUTHOR MSG_COMPILED __DATE__);
ECHO_LM(DB, MSG_CONFIGURATION_VER STRING_VERSION_CONFIG_H MSG_AUTHOR STRING_CONFIG_H_AUTHOR);
ECHO_EM(MSG_COMPILED __DATE__);
#endif // STRING_CONFIG_H_AUTHOR
#endif // STRING_VERSION_CONFIG_H
ECHO_SMV(DB, MSG_FREE_MEMORY, freeMemory());
ECHO_EMV(MSG_PLANNER_BUFFER_BYTES, (int)sizeof(block_t)*BLOCK_BUFFER_SIZE);
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
for (int8_t i = 0; i < BUFSIZE; i++) fromsd[i] = false;
#endif
......@@ -735,7 +739,7 @@ void setup() {
digipot_i2c_init();
#endif
#if ENABLED(Z_PROBE_SLED)
#ifdef Z_PROBE_SLED
OUT_WRITE(SERVO0_PIN, LOW); // turn it off
#endif // Z_PROBE_SLED
......@@ -751,7 +755,7 @@ void setup() {
digitalWrite(STAT_LED_BLUE, LOW); // turn it off
#endif
#if ENABLED(FIRMWARE_TEST)
#ifdef FIRMWARE_TEST
FirmwareTest();
#endif // FIRMWARE_TEST
}
......@@ -769,13 +773,13 @@ void setup() {
void loop() {
if (commands_in_queue < BUFSIZE - 1) get_command();
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
card.checkautostart(false);
#endif
if (commands_in_queue) {
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
if (card.saving) {
char *command = command_queue[cmd_queue_index_r];
......@@ -828,7 +832,7 @@ void get_command() {
if (drain_queued_commands_P()) return; // priority is given to non-serial commands
#if ENABLED(NO_TIMEOUTS)
#ifdef NO_TIMEOUTS
static millis_t last_command_time = 0;
millis_t ms = millis();
......@@ -843,7 +847,7 @@ void get_command() {
//
while (MYSERIAL.available() > 0 && commands_in_queue < BUFSIZE) {
#if ENABLED(NO_TIMEOUTS)
#ifdef NO_TIMEOUTS
last_command_time = ms;
#endif
......@@ -863,7 +867,7 @@ void get_command() {
command[serial_count] = 0; // terminate string
// this item in the queue is not from sd
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
fromsd[cmd_queue_index_w] = false;
#endif
......@@ -922,10 +926,6 @@ void get_command() {
// If command was e-stop process now
if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED));
#if ENABLED(FILAMENTCHANGEENABLE)
if (strcmp(command, "M601") == 0) filament_changing = false;
#endif //FILAMENTCHANGEENABL
cmd_queue_index_w = (cmd_queue_index_w + 1) % BUFSIZE;
commands_in_queue += 1;
......@@ -1051,7 +1051,7 @@ XYZ_CONSTS_FROM_CONFIG(float, base_min_pos, MIN_POS);
XYZ_CONSTS_FROM_CONFIG(float, home_bump_mm, HOME_BUMP_MM);
XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
#if ENABLED(DUAL_X_CARRIAGE)
#ifdef DUAL_X_CARRIAGE
#define DXC_FULL_CONTROL_MODE 0
#define DXC_AUTO_PARK_MODE 1
......@@ -1196,7 +1196,7 @@ inline void line_to_destination() {
inline void sync_plan_position() {
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
}
#if ENABLED(DELTA) || ENABLED(SCARA)
#if defined(DELTA) || defined(SCARA)
inline void sync_plan_position_delta() {
calculate_delta(current_position);
plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
......@@ -1213,7 +1213,7 @@ static void setup_for_endstop_move() {
enable_endstops(true);
}
#if ENABLED(CARTESIAN) || ENABLED(COREXY) || ENABLED(SCARA)
#if defined(CARTESIAN) || defined(COREXY) || defined(SCARA)
static void do_blocking_move_to(float x, float y, float z) {
float oldFeedRate = feedrate;
......@@ -1536,7 +1536,7 @@ static void setup_for_endstop_move() {
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
#endif // Cartesian || CoreXY || Scara
#if ENABLED(DELTA)
#ifdef DELTA
static void homeaxis(AxisEnum axis) {
#define HOMEAXIS_DO(LETTER) \
......@@ -2393,7 +2393,7 @@ static void setup_for_endstop_move() {
}
#endif //DELTA
#if ENABLED(IDLE_OOZING_PREVENT)
#ifdef IDLE_OOZING_PREVENT
void IDLE_OOZING_retract(bool retracting) {
if (retracting && !IDLE_OOZING_retracted[active_extruder]) {
set_destination_to_current();
......@@ -2418,7 +2418,7 @@ static void setup_for_endstop_move() {
}
#endif
#if ENABLED(FWRETRACT)
#ifdef FWRETRACT
void retract(bool retracting, bool swapping = false) {
if (retracting == retracted[active_extruder]) return;
......@@ -2469,7 +2469,7 @@ static void setup_for_endstop_move() {
} // retract()
#endif //FWRETRACT
#if ENABLED(Z_PROBE_SLED)
#ifdef Z_PROBE_SLED
#ifndef SLED_DOCKING_OFFSET
#define SLED_DOCKING_OFFSET 0
......@@ -2580,11 +2580,6 @@ inline void wait_bed() {
refresh_cmd_timeout();
}
void error_invalid_extruder(int code, int e) {
ECHO_SMV(DB, "M", code);
ECHO_EMV(MSG_INVALID_EXTRUDER, e);
}
/******************************************************************************
***************************** G-Code Functions ********************************
*******************************************************************************/
......@@ -3011,10 +3006,8 @@ inline void gcode_G28(boolean home_XY = false) {
// Manual G28 bed level
#ifdef ULTIPANEL
ECHO_LM(DB, " --LEVEL PLATE SCRIPT--");
set_ChangeScreen(true);
while(!lcd_clicked()) {
set_pageShowInfo(0);
lcd_update();
idle(true);
}
saved_feedrate = feedrate;
saved_feedrate_multiplier = feedrate_multiplier;
......@@ -3051,63 +3044,52 @@ inline void gcode_G28(boolean home_XY = false) {
// PROBE FIRST POINT
set_pageShowInfo(1);
set_ChangeScreen(true);
do_blocking_move_to(LEFT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, current_position[Z_AXIS]);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], Z_MIN_POS);
while(!lcd_clicked()) {
manage_heater();
manage_inactivity();
idle(true);
}
// PROBE SECOND POINT
set_ChangeScreen(true);
set_pageShowInfo(2);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS],Z_MIN_POS + 5);
do_blocking_move_to(RIGHT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, current_position[Z_AXIS]);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS],Z_MIN_POS);
while(!lcd_clicked()) {
manage_heater();
manage_inactivity();
idle(true);
}
// PROBE THIRD POINT
set_ChangeScreen(true);
set_pageShowInfo(3);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS],Z_MIN_POS + 5);
do_blocking_move_to(RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION, current_position[Z_AXIS]);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS],Z_MIN_POS);
while(!lcd_clicked()) {
manage_heater();
manage_inactivity();
idle(true);
}
// PROBE FOURTH POINT
set_ChangeScreen(true);
set_pageShowInfo(4);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS],Z_MIN_POS + 5);
do_blocking_move_to(LEFT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION, current_position[Z_AXIS]);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS],Z_MIN_POS);
while(!lcd_clicked()) {
manage_heater();
manage_inactivity();
idle(true);
}
// PROBE CENTER
set_ChangeScreen(true);
set_pageShowInfo(5);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS],Z_MIN_POS + 5);
do_blocking_move_to((X_MAX_POS-X_MIN_POS)/2, (Y_MAX_POS-Y_MIN_POS)/2, current_position[Z_AXIS]);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS],Z_MIN_POS);
while(!lcd_clicked()) {
manage_heater();
manage_inactivity();
idle(true);
}
// FINISH MANUAL BED LEVEL
set_ChangeScreen(true);
set_pageShowInfo(6);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS],Z_MIN_POS + 5);
enqueuecommands_P(PSTR("G28 X0 Y0\nG4 P0\nG4 P0\nG4 P0"));
enqueuecommands_P(PSTR("G28"));
#endif // ULTIPANEL
}
else if (home_all_axis || homeZ) HOMEAXIS(Z);
......@@ -3947,7 +3929,8 @@ inline void gcode_M31() {
}
}
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
#ifdef LONG_FILENAME_HOST_SUPPORT
/**
* M33: Get the long full path of a file or folder
*
......@@ -3963,6 +3946,7 @@ inline void gcode_M31() {
inline void gcode_M33() {
card.printLongPath(current_command_args);
}
#endif
/**
......@@ -4389,7 +4373,7 @@ inline void gcode_M105() {
ECHO_MV(" /", degTargetHotend(target_extruder), 1);
#endif
#if HAS_TEMP_BED
ECHO_MV(MSG_B, degBed(), 1);
ECHO_MV(" " MSG_B, degBed(), 1);
ECHO_MV(" /", degTargetBed(), 1);
#endif
for (int8_t e = 0; e < EXTRUDERS; ++e) {
......@@ -4647,7 +4631,7 @@ inline void gcode_M140() {
if (code_seen('S')) setTargetBed(code_value());
}
#ifdef ULTIPANEL
#if defined(ULTIPANEL) && TEMP_SENSOR_0 != 0
/**
* M145: Set the heatup state for a material in the LCD menu
......@@ -4749,19 +4733,14 @@ inline void gcode_M140() {
#endif // HAS_TEMP_BED
/**
* M200: Set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).
* T<extruder>
* D<millimeters>
* M200: Set filament diameter and set E axis units to cubic millimetres
*
* T<extruder> - Optional extruder number. Current extruder if omitted.
* D<mm> - Diameter of the filament. Use "D0" to set units back to millimetres.
*/
inline void gcode_M200() {
int tmp_extruder = active_extruder;
if (code_seen('T')) {
tmp_extruder = code_value_short();
if (tmp_extruder >= EXTRUDERS) {
error_invalid_extruder(200, tmp_extruder);
return;
}
}
if (setTargetedHotend(200)) return;
if (code_seen('D')) {
float diameter = code_value();
......@@ -4770,10 +4749,10 @@ inline void gcode_M200() {
// for all extruders
volumetric_enabled = (diameter != 0.0);
if (volumetric_enabled) {
filament_size[tmp_extruder] = diameter;
filament_size[target_extruder] = diameter;
// make sure all extruders have some sane value for the filament size
for (int i=0; i<EXTRUDERS; i++)
if (! filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
for (int i = 0; i < EXTRUDERS; i++)
if (!filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
}
}
else {
......@@ -4787,7 +4766,7 @@ inline void gcode_M200() {
* M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
*/
inline void gcode_M201() {
for (int8_t i=0; i < NUM_AXIS; i++) {
for (int8_t i = 0; i < NUM_AXIS; i++) {
if (code_seen(axis_codes[i])) {
max_acceleration_units_per_sq_second[i] = code_value();
}
......@@ -4798,7 +4777,7 @@ inline void gcode_M201() {
#if 0 // Not used for Sprinter/grbl gen6
inline void gcode_M202() {
for(int8_t i=0; i < NUM_AXIS; i++) {
for(int8_t i = 0; i < NUM_AXIS; i++) {
if(code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i];
}
}
......@@ -5163,6 +5142,8 @@ inline void gcode_M303() {
int c = code_seen('C') ? code_value_short() : 5;
float temp = code_seen('S') ? code_value() : (e < 0 ? 70.0 : 150.0);
PID_autotune(temp, e, c);
gcode_LastN += 1;
FlushSerialRequestResend();
}
#ifdef PIDTEMPBED
......@@ -5670,12 +5651,6 @@ inline void gcode_M503() {
filament_changing = false;
}
/**
* M601: Resume the print from filament change
*/
inline void gcode_M601() { filament_changing = false; }
#endif //FILAMENTCHANGEENABLE
#ifdef DUAL_X_CARRIAGE
......@@ -6136,79 +6111,44 @@ inline void gcode_T(uint8_t tmp_extruder) {
}
/**
* Process Commands and dispatch them to handlers
* Process a single command and dispatch it to its handler
* This is called from the main loop()
*/
void process_next_command() {
current_command = command_queue[cmd_queue_index_r];
if ((debugLevel & DEBUG_ECHO)) {
ECHO_LV(DB, current_command);
ECHO_LV(DB, command_queue[cmd_queue_index_r]);
}
// Sanitize the current command:
// - Skip leading spaces
// - Bypass N...
// - Overwrite * with nul to mark the end
while (*current_command == ' ') ++current_command;
if (*current_command == 'N' && current_command[1] >= '0' && current_command[1] <= '9') {
while (*current_command != ' ') ++current_command;
while (*current_command == ' ') ++current_command;
}
char *starpos = strchr(current_command, '*'); // * should always be the last parameter
if (starpos) *starpos = '\0';
// Get the command code, which must be G, M, or T
char command_code = *current_command;
// The code must have a numeric value
bool code_is_good = (current_command[1] >= '0' && current_command[1] <= '9');
int codenum; // define ahead of goto
// Bail early if there's no code
if (!code_is_good) goto ExitUnknownCommand;
// Args pointer optimizes code_seen, especially those taking XYZEF
// This wastes a little cpu on commands that expect no arguments.
current_command_args = current_command;
while (*current_command_args != ' ') ++current_command_args;
while (*current_command_args == ' ') ++current_command_args;
// Interpret the code int
seen_pointer = current_command;
codenum = code_value_short();
// Handle a known G, M, or T
switch(command_code) {
case 'G': switch (codenum) {
if(code_seen('G')) {
int gCode = code_value_short();
switch(gCode) {
//G0 -> G1
case 0:
case 1:
gcode_G0_G1(); break;
// G2, G3
#if DISABLED(SCARA)
#ifndef SCARA
case 2: // G2 - CW ARC
case 3: // G3 - CCW ARC
gcode_G2_G3(codenum == 2); break;
gcode_G2_G3(gCode == 2); break;
#endif
// G4 Dwell
case 4:
gcode_G4(); break;
#if ENABLED(FWRETRACT)
#ifdef FWRETRACT
case 10: // G10: retract
case 11: // G11: retract_recover
gcode_G10_G11(codenum == 10); break;
#endif // FWRETRACT
gcode_G10_G11(gCode == 10); break;
#endif //FWRETRACT
case 28: //G28: Home all axes, one at a time
gcode_G28(); gcode_M114(); break;
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points.
gcode_G29(); gcode_M114(); break;
#ifndef Z_PROBE_SLED
......@@ -6217,11 +6157,11 @@ void process_next_command() {
#else // Z_PROBE_SLED
case 31: // G31: dock the sled
case 32: // G32: undock the sled
dock_sled(codenum == 31); break;
dock_sled(gCode == 31); break;
#endif // Z_PROBE_SLED
#endif // ENABLE_AUTO_BED_LEVELING
#if ENABLED(DELTA) && ENABLED(Z_PROBE_ENDSTOP)
#if defined(DELTA) && defined(Z_PROBE_ENDSTOP)
case 29: // G29 Detailed Z-Probe, probes the bed at more points.
gcode_G29(); break;
case 30: // G30 Delta AutoCalibration
......@@ -6239,16 +6179,17 @@ void process_next_command() {
case 92: // G92
gcode_G92(); break;
}
break;
}
case 'M': switch (codenum) {
#if ENABLED(ULTIPANEL)
else if (code_seen('M')) {
switch(code_value_short()) {
#ifdef ULTIPANEL
case 0: // M0 - Unconditional stop - Wait for user button press on LCD
case 1: // M1 - Conditional stop - Wait for user button press on LCD
gcode_M0_M1(); break;
#endif //ULTIPANEL
#if ENABLED(LASERBEAM)
#ifdef LASERBEAM
case 3: // M03 S - Setting laser beam
gcode_M3(); break;
case 4: // M04 - Turn on laser beam
......@@ -6265,7 +6206,7 @@ void process_next_command() {
case 17: //M17 - Enable/Power all stepper motors
gcode_M17(); break;
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
case 20: // M20 - list SD card
gcode_M20(); break;
case 21: // M21 - init SD card
......@@ -6291,7 +6232,7 @@ void process_next_command() {
case 32: // M32 - Select file and start SD print
gcode_M32(); break;
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
#ifdef LONG_FILENAME_HOST_SUPPORT
case 33: // M33 - Get the long full path to a file or folder
gcode_M33(); break;
#endif
......@@ -6307,7 +6248,7 @@ void process_next_command() {
case 42: // M42 -Change pin status via gcode
gcode_M42(); break;
#if ENABLED(ENABLE_AUTO_BED_LEVELING) && ENABLED(Z_PROBE_REPEATABILITY_TEST)
#if defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
case 49: // M49 Z-Probe repeatability
gcode_M49(); break;
#endif
......@@ -6354,7 +6295,7 @@ void process_next_command() {
case 115: // M115 Report capabilities
gcode_M115(); break;
#if ENABLED(ULTIPANEL)
#ifdef ULTIPANEL
case 117: // M117 display message
gcode_M117(); break;
#endif
......@@ -6366,7 +6307,7 @@ void process_next_command() {
case 121: // M121 Disable endstops
gcode_M121(); break;
#if ENABLED(BARICUDA)
#ifdef BARICUDA
// PWM for HEATER_1_PIN
#if HAS_HEATER_1
case 126: // M126 valve open
......@@ -6387,7 +6328,7 @@ void process_next_command() {
case 140: // M140 Set bed temp
gcode_M140(); break;
#if ENABLED(BLINKM)
#ifdef BLINKM
case 150: // M150
gcode_M150(); break;
#endif //BLINKM
......@@ -6415,7 +6356,7 @@ void process_next_command() {
case 206: // M206 additional homing offset
gcode_M206(); break;
#if ENABLED(FWRETRACT)
#ifdef FWRETRACT
case 207: //M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop]
gcode_M207(); break;
case 208: // M208 - set retract recover length S[positive mm surplus to the M207 S*] F[feedrate mm/min]
......@@ -6436,12 +6377,12 @@ void process_next_command() {
case 226: // M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required
gcode_M226(); break;
#if ENABLED(CHDK) || (ENABLED(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1)
#if defined(CHDK) || (defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1)
case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/
gcode_M240(); break;
#endif // CHDK || PHOTOGRAPH_PIN
#if ENABLED(DOGLCD) && LCD_CONTRAST >= 0
#if defined(DOGLCD) && LCD_CONTRAST >= 0
case 250: // M250 Set LCD contrast value: C<value> (value 0..63)
gcode_M250(); break;
#endif // DOGLCD
......@@ -6456,23 +6397,20 @@ void process_next_command() {
gcode_M300(); break;
#endif // HAS_LCD_BUZZ
#if ENABLED(PIDTEMP)
#ifdef PIDTEMP
case 301: // M301
gcode_M301(); break;
#endif // PIDTEMP
#if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
#ifdef PREVENT_DANGEROUS_EXTRUDE
case 302: // allow cold extrudes, or set the minimum extrude temperature
gcode_M302(); break;
#endif // PREVENT_DANGEROUS_EXTRUDE
case 303: // M303 PID autotune
gcode_M303();
gcode_LastN += 1;
FlushSerialRequestResend();
break;
gcode_M303(); break;
#if ENABLED(PIDTEMPBED)
#ifdef PIDTEMPBED
case 304: // M304
gcode_M304(); break;
#endif // PIDTEMPBED
......@@ -6486,7 +6424,7 @@ void process_next_command() {
break;
#endif // HAS_MICROSTEPS
#if ENABLED(SCARA)
#ifdef SCARA
case 360: // M360 SCARA Theta pos1
if (gcode_M360()) return; break;
case 361: // M361 SCARA Theta pos2
......@@ -6511,7 +6449,7 @@ void process_next_command() {
gcode_M402(); break;
#endif
#if ENABLED(FILAMENT_SENSOR)
#ifdef FILAMENT_SENSOR
case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width
gcode_M404(); break;
case 405: //M405 Turn on filament sensor for control
......@@ -6537,22 +6475,22 @@ void process_next_command() {
case 503: // M503 print settings currently in memory
gcode_M503(); break;
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
case 540:
gcode_M540(); break;
#endif
#if ENABLED(FILAMENTCHANGEENABLE)
case 600: // M600 Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
#ifdef FILAMENTCHANGEENABLE
case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
gcode_M600(); break;
#endif
#if ENABLED(DUAL_X_CARRIAGE)
#ifdef DUAL_X_CARRIAGE
case 605:
gcode_M605(); break;
#endif
#if ENABLED(ENABLE_AUTO_BED_LEVELING) || ENABLED(DELTA)
#if defined(ENABLE_AUTO_BED_LEVELING) || defined(DELTA)
case 666: // M666 Set Z probe offset or set delta endstop and geometry adjustment
gcode_M666(); break;
#endif
......@@ -6565,7 +6503,7 @@ void process_next_command() {
gcode_M908(); break;
#endif // HAS_DIGIPOTSS
#if ENABLED(NPR2)
#ifdef NPR2
case 997: // M997 Cxx Move Carter xx gradi
gcode_M997(); break;
#endif // NPR2
......@@ -6573,24 +6511,21 @@ void process_next_command() {
case 999: // M999: Restart after being Stopped
gcode_M999(); break;
#if ENABLED(CUSTOM_M_CODE_SET_Z_PROBE_OFFSET)
#ifdef CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
case CUSTOM_M_CODE_SET_Z_PROBE_OFFSET:
gcode_SET_Z_PROBE_OFFSET(); break;
#endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
}
break;
case 'T':
gcode_T(codenum);
break;
default: code_is_good = false;
}
ExitUnknownCommand:
else if (code_seen('T')) {
gcode_T(code_value_short());
}
// Still unknown command? Throw an error
if (!code_is_good) unknown_command_error();
else {
ECHO_SM(ER, MSG_UNKNOWN_COMMAND);
ECHO_EVM(command_queue[cmd_queue_index_r], "\"");
}
ok_to_send();
}
......@@ -6604,11 +6539,11 @@ void FlushSerialRequestResend() {
void ok_to_send() {
refresh_cmd_timeout();
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
if (fromsd[cmd_queue_index_r]) return;
#endif
ECHO_S(OK);
#if ENABLED(ADVANCED_OK)
#ifdef ADVANCED_OK
ECHO_MV(" N", gcode_LastN);
ECHO_MV(" P", (int)(BLOCK_BUFFER_SIZE - movesplanned() - 1));
ECHO_MV(" B", BUFSIZE - commands_in_queue);
......@@ -6622,7 +6557,7 @@ void clamp_to_software_endstops(float target[3]) {
NOLESS(target[Y_AXIS], min_pos[Y_AXIS]);
float negative_z_offset = 0;
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset += Z_PROBE_OFFSET_FROM_EXTRUDER;
if (home_offset[Z_AXIS] < 0) negative_z_offset += home_offset[Z_AXIS];
#endif
......@@ -6636,7 +6571,7 @@ void clamp_to_software_endstops(float target[3]) {
}
}
#if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
#ifdef PREVENT_DANGEROUS_EXTRUDE
inline void prevent_dangerous_extrude(float &curr_e, float &dest_e) {
float de = dest_e - curr_e;
......@@ -6646,7 +6581,7 @@ void clamp_to_software_endstops(float target[3]) {
curr_e = dest_e; // Behave as if the move really took place, but ignore E part
ECHO_LM(ER, MSG_ERR_COLD_EXTRUDE_STOP);
}
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
#ifdef PREVENT_LENGTHY_EXTRUDE
if (labs(de) > EXTRUDE_MAXLENGTH) {
curr_e = dest_e; // Behave as if the move really took place, but ignore E part
ECHO_LM(ER, MSG_ERR_LONG_EXTRUDE_STOP);
......@@ -6657,7 +6592,7 @@ void clamp_to_software_endstops(float target[3]) {
#endif // PREVENT_DANGEROUS_EXTRUDE
#if ENABLED(DELTA) || ENABLED(SCARA)
#if defined(DELTA) || defined(SCARA)
inline bool prepare_move_delta() {
float difference[NUM_AXIS];
......@@ -7256,15 +7191,8 @@ bool setTargetedHotend(int code) {
if (code_seen('T')) {
target_extruder = code_value_short();
if (target_extruder >= EXTRUDERS) {
switch(code) {
case 104:
case 105:
case 109:
case 218:
case 221:
error_invalid_extruder(code, target_extruder);
break;
}
ECHO_SMV(ER, "M", code);
ECHO_EMV(" " MSG_INVALID_EXTRUDER, target_extruder);
return true;
}
}
......
......@@ -3,7 +3,7 @@
Created by Tim Koster, August 21 2013.
*/
#include "Marlin.h"
#if ENABLED(BLINKM)
#ifdef BLINKM
#include "blinkm.h"
......
......@@ -5,7 +5,7 @@
#include "temperature.h"
#include "language.h"
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
CardReader::CardReader() {
filesize = 0;
......@@ -126,7 +126,7 @@ void CardReader::ls() {
lsDive("", root);
}
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
#ifdef LONG_FILENAME_HOST_SUPPORT
/**
* Get a long pretty path based on a DOS 8.3 path
......@@ -191,7 +191,7 @@ void CardReader::initsd() {
cardOK = false;
if (root.isOpen()) root.close();
#if ENABLED(SDSLOW)
#ifdef SDSLOW
#define SPI_SPEED SPI_HALF_SPEED
#else
#define SPI_SPEED SPI_FULL_SPEED
......@@ -202,7 +202,7 @@ void CardReader::initsd() {
&& !card.init(SPI_SPEED, LCD_SDSS)
#endif
) {
ECHO_LM(ER, MSG_SD_INIT_FAIL);
ECHO_LM(DB, MSG_SD_INIT_FAIL);
}
else if (!volume.init(&card)) {
ECHO_LM(ER, MSG_SD_VOL_INIT_FAIL);
......@@ -212,7 +212,7 @@ void CardReader::initsd() {
}
else {
cardOK = true;
ECHO_LM(OK, MSG_SD_CARD_OK);
ECHO_LM(DB, MSG_SD_CARD_OK);
}
workDir = root;
curDir = &root;
......@@ -264,7 +264,7 @@ void CardReader::getAbsFilename(char *t) {
t[0] = 0;
}
void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/, bool lcd_status/*=true*/) {
void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/) {
if (!cardOK) return;
if (file.isOpen()) { //replacing current file by new file, or subfile call
if (!replace_current) {
......@@ -357,7 +357,6 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/,
else {
saving = true;
ECHO_EMV(MSG_SD_WRITE_TO_FILE, name);
lcd_setstatus(fname);
}
}
}
......@@ -383,7 +382,8 @@ void CardReader::removeFile(char* name) {
subdirname[dirname_end - dirname_start] = 0;
ECHO_EV(subdirname);
if (!myDir.open(curDir, subdirname, O_READ)) {
ECHO_LMV(ER, MSG_SD_OPEN_FILE_FAIL, subdirname);
ECHO_MV(MSG_SD_OPEN_FILE_FAIL, subdirname);
ECHO_C('.');
return;
}
......@@ -401,21 +401,22 @@ void CardReader::removeFile(char* name) {
}
if (file.remove(curDir, fname)) {
ECHO_LMV(OK, MSG_SD_FILE_DELETED, fname);
ECHO_EMV(MSG_SD_FILE_DELETED, fname);
sdpos = 0;
}
else {
ECHO_LMV(ER, MSG_SD_FILE_DELETION_ERR, fname);
ECHO_MV(MSG_SD_FILE_DELETION_ERR, fname);
ECHO_C('.');
}
}
void CardReader::getStatus() {
if (cardOK) {
ECHO_SMV(OK, MSG_SD_PRINTING_BYTE, sdpos);
ECHO_MV(MSG_SD_PRINTING_BYTE, sdpos);
ECHO_EMV(MSG_SD_SLASH, filesize);
}
else {
ECHO_LM(OK, MSG_SD_NOT_PRINTING);
ECHO_EM(MSG_SD_NOT_PRINTING);
}
}
......
#ifndef CARDREADER_H
#define CARDREADER_H
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
#define MAX_DIR_DEPTH 10 // Maximum folder depth
......@@ -18,7 +18,7 @@ public:
//this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset
void checkautostart(bool x);
void openFile(char* name, bool read, bool replace_current = true, bool lcd_status = true);
void openFile(char* name,bool read,bool replace_current=true);
void openLogFile(char* name);
void removeFile(char* name);
void closeFile(bool store_location = false);
......@@ -30,7 +30,7 @@ public:
void getStatus();
void printingHasFinished();
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
#ifdef LONG_FILENAME_HOST_SUPPORT
void printLongPath(char *path);
#endif
......@@ -84,7 +84,7 @@ extern CardReader card;
#define IS_SD_PRINTING (card.sdprinting)
#if (SDCARDDETECT > -1)
#if ENABLED(SDCARDDETECTINVERTED)
#ifdef SDCARDDETECTINVERTED
#define IS_SD_INSERTED (READ(SDCARDDETECT) != 0)
#else
#define IS_SD_INSERTED (READ(SDCARDDETECT) == 0)
......
/**
* Comunication.h - serial messages functions
* Part of Marlin
* Part of MarlinKimbra
*
* Author: Simone Primarosa
*/
......@@ -40,7 +40,7 @@
#endif
#define START "start" //start for host
#define OK "ok" //ok answer for host
#define OK "ok " //ok answer for host
#define ER "Error: " //error for host
#define WT "wait" //wait for host
#define DB "echo: " //message for user
......@@ -54,9 +54,13 @@
#define SERIAL_PRINT(msg, args...) MYSERIAL.print(msg, ##args)
#define SERIAL_ENDL MYSERIAL.println()
// Things to write to serial from Program memory. Saves 400 to 2k of RAM.
FORCE_INLINE void PS_PGM(const char *str) {
char ch;
while ((ch = pgm_read_byte(str++))) { SERIAL_WRITE(ch); }
while ((ch = pgm_read_byte(str))) {
MYSERIAL.write(ch);
str++;
}
}
#define ECHO_ENDL SERIAL_ENDL
......@@ -65,8 +69,8 @@ FORCE_INLINE void PS_PGM(const char *str) {
#define ECHO_MV(msg, val, args...) ECHO_PGM(msg),ECHO_V(val, ##args)
#define ECHO_VM(val, msg, args...) ECHO_V(val, ##args),ECHO_PGM(msg)
#define ECHO_M(msg) ECHO_PGM(msg)
#define ECHO_V SERIAL_PRINT
#define ECHO_C SERIAL_WRITE
#define ECHO_V(msg, args...) SERIAL_PRINT(msg, ##args)
#define ECHO_C(x) SERIAL_WRITE(x)
#define ECHO_S(srt) ECHO_PGM(srt)
#define ECHO_SM(srt, msg) ECHO_S(srt),ECHO_M(msg)
......
......@@ -7,7 +7,9 @@
#ifndef CONFIGURATION_LCD // Get the LCD defines which are needed first
#define CONFIGURATION_LCD
#if ENABLED(MAKRPANEL)
#define PIN_EXISTS(PN) (defined(PN##_PIN) && PN##_PIN >= 0)
#ifdef MAKRPANEL
#define DOGLCD
#define SDSUPPORT
#define DEFAULT_LCD_CONTRAST 17
......@@ -15,16 +17,16 @@
#define NEWPANEL
#endif
#if ENABLED(miniVIKI) || ENABLED(VIKI2) || ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#if defined(miniVIKI) || defined(VIKI2) || defined(ELB_FULL_GRAPHIC_CONTROLLER)
#define ULTRA_LCD //general LCD support, also 16x2
#define DOGLCD // Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family)
#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
#if ENABLED(miniVIKI)
#ifdef miniVIKI
#define DEFAULT_LCD_CONTRAST 95
#elif ENABLED(VIKI2)
#elif defined(VIKI2)
#define DEFAULT_LCD_CONTRAST 40
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#elif defined(ELB_FULL_GRAPHIC_CONTROLLER)
#define DEFAULT_LCD_CONTRAST 110
#define SDCARDDETECTINVERTED
#define SDSLOW
......@@ -35,23 +37,23 @@
#define ENCODER_STEPS_PER_MENU_ITEM 1
#endif
#if ENABLED(PANEL_ONE)
#ifdef PANEL_ONE
#define SDSUPPORT
#define ULTIMAKERCONTROLLER
#endif
#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
#ifdef REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
#define DOGLCD
#define U8GLIB_ST7920
#define REPRAP_DISCOUNT_SMART_CONTROLLER
#endif
#if ENABLED(ULTIMAKERCONTROLLER) || ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) || ENABLED(G3D_PANEL)
#if defined(ULTIMAKERCONTROLLER) || defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL)
#define ULTIPANEL
#define NEWPANEL
#endif
#if ENABLED(RADDS_DISPLAY)
#ifdef RADDS_DISPLAY
#define ENCODER_PULSES_PER_STEP 2
#define ENCODER_STEPS_PER_MENU_ITEM 1
......@@ -59,12 +61,12 @@
#define NEWPANEL
#endif
#if ENABLED(REPRAPWORLD_KEYPAD)
#ifdef REPRAPWORLD_KEYPAD
#define ULTIPANEL
#define NEWPANEL
#endif
#if ENABLED(RA_CONTROL_PANEL)
#ifdef RA_CONTROL_PANEL
#define LCD_I2C_TYPE_PCA8574
#define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander
#define ULTIPANEL
......@@ -75,7 +77,7 @@
* I2C PANELS
*/
#if ENABLED(LCD_I2C_SAINSMART_YWROBOT)
#ifdef LCD_I2C_SAINSMART_YWROBOT
// This uses the LiquidCrystal_I2C library ( https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home )
// Make sure it is placed in the Arduino libraries directory.
#define LCD_I2C_TYPE_PCF8575
......@@ -85,7 +87,7 @@
#endif
// PANELOLU2 LCD with status LEDs, separate encoder and click inputs
#if ENABLED(LCD_I2C_PANELOLU2)
#ifdef LCD_I2C_PANELOLU2
// This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
// Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
// (v1.2.3 no longer requires you to define PANELOLU in the LiquidTWI2.h library header file)
......@@ -95,15 +97,15 @@
#define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
#define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD
#if DISABLED(ENCODER_PULSES_PER_STEP)
#if !defined(ENCODER_PULSES_PER_STEP)
#define ENCODER_PULSES_PER_STEP 4
#endif
#if DISABLED(ENCODER_STEPS_PER_MENU_ITEM)
#if !defined(ENCODER_STEPS_PER_MENU_ITEM)
#define ENCODER_STEPS_PER_MENU_ITEM 1
#endif
#if ENABLED(LCD_USE_I2C_BUZZER)
#ifdef LCD_USE_I2C_BUZZER
#define LCD_FEEDBACK_FREQUENCY_HZ 1000
#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100
#endif
......@@ -113,7 +115,7 @@
#endif
// Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
#if ENABLED(LCD_I2C_VIKI)
#ifdef LCD_I2C_VIKI
// This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
// Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
// Note: The pause/stop/resume LCD button pin should be connected to the Arduino
......@@ -130,17 +132,17 @@
// 2 wire Non-latching LCD SR from:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
#if ENABLED(SAV_3DLCD)
#ifdef SAV_3DLCD
#define SR_LCD_2W_NL // Non latching 2 wire shiftregister
#define ULTIPANEL
#define NEWPANEL
#endif
#if ENABLED(ULTIPANEL)
#ifdef ULTIPANEL
#define NEWPANEL //enable this if you have a click-encoder panel
#define SDSUPPORT
#define ULTRA_LCD
#if ENABLED(DOGLCD) // Change number of lines to match the DOG graphic display
#ifdef DOGLCD // Change number of lines to match the DOG graphic display
#define LCD_WIDTH 22
#define LCD_HEIGHT 5
#else
......@@ -148,8 +150,8 @@
#define LCD_HEIGHT 4
#endif
#else //no panel but just LCD
#if ENABLED(ULTRA_LCD)
#if ENABLED(DOGLCD) // Change number of lines to match the 128x64 graphics display
#ifdef ULTRA_LCD
#ifdef DOGLCD // Change number of lines to match the 128x64 graphics display
#define LCD_WIDTH 22
#define LCD_HEIGHT 5
#else
......@@ -159,7 +161,7 @@
#endif
#endif
#if ENABLED(DOGLCD)
#ifdef DOGLCD
/* Custom characters defined in font font_6x10_marlin_symbols */
// \x00 intentionally skipped to avoid problems in strings
#define LCD_STR_REFRESH "\x01"
......@@ -191,13 +193,13 @@
/**
* Default LCD contrast for dogm-like LCD displays
*/
#if ENABLED(DOGLCD) && DISABLED(DEFAULT_LCD_CONTRAST)
#if defined(DOGLCD) && !defined(DEFAULT_LCD_CONTRAST)
#define DEFAULT_LCD_CONTRAST 32
#endif
#if ENABLED(DOGLCD)
#ifdef DOGLCD
#define HAS_LCD_CONTRAST
#if ENABLED(U8GLIB_ST7920)
#ifdef U8GLIB_ST7920
#undef HAS_LCD_CONTRAST
#endif
#endif
......@@ -205,12 +207,12 @@
/**
* LCD BUZZ
*/
#define HAS_LCD_BUZZ (ENABLED(ULTRALCD) || (ENABLED(BEEPER) && BEEPER >= 0) || ENABLED(LCD_USE_I2C_BUZZER))
#define HAS_LCD_BUZZ (defined(ULTRALCD) || (defined(BEEPER) && BEEPER >= 0) || defined(LCD_USE_I2C_BUZZER))
/**
* SPLASH_SCREEN_DURATION for no DOGLCD display
*/
#if DISABLED(DOGLCD)
#if !defined(DOGLCD)
#undef SPLASH_SCREEN_DURATION
#define SPLASH_SCREEN_DURATION 500
#endif
......@@ -221,7 +223,7 @@
/**
* SINGLENOZZLE
*/
#if ENABLED(SINGLENOZZLE)
#ifdef SINGLENOZZLE
#define HOTENDS 1
#undef TEMP_SENSOR_1_AS_REDUNDANT
#else
......@@ -231,7 +233,7 @@
/**
* DRIVER_EXTRUDERS
*/
#if DISABLED(MKR4) && DISABLED(NPR2)
#if !defined(MKR4) && !defined(NPR2)
#define DRIVER_EXTRUDERS EXTRUDERS // This defines the number of Driver extruder
#endif
......@@ -252,7 +254,7 @@
/**
* ENDSTOPPULLUPS
*/
#if ENABLED(ENDSTOPPULLUPS)
#ifdef ENDSTOPPULLUPS
#define ENDSTOPPULLUP_XMAX
#define ENDSTOPPULLUP_YMAX
#define ENDSTOPPULLUP_ZMAX
......@@ -293,7 +295,7 @@
/**
* Firmware Test
*/
#if ENABLED(FIRMWARE_TEST)
#ifdef FIRMWARE_TEST
#undef BAUDRATE
#define BAUDRATE 115200 // Baudrate setting to 115200 because serial monitor arduino function at max 115200 baudrate.
#endif
......@@ -308,7 +310,7 @@
/**
* SCARA
*/
#if ENABLED(SCARA)
#ifdef SCARA
#undef SLOWDOWN
#define QUICK_HOME //SCARA needs Quickhome
#endif
......@@ -316,7 +318,7 @@
/**
* DELTA
*/
#if ENABLED(DELTA)
#ifdef DELTA
#undef SLOWDOWN //DELTA not needs SLOWDOWN
// DELTA must have same valour for 3 axis endstop hits
#undef Y_HOME_BUMP_MM
......@@ -329,12 +331,12 @@
* AUTOSET LOCATIONS OF LIMIT SWITCHES
* Added by ZetaPhoenix 09-15-2012
*/
#if ENABLED(MANUAL_HOME_POSITIONS) // Use manual limit switch locations
#ifdef MANUAL_HOME_POSITIONS // Use manual limit switch locations
#define X_HOME_POS MANUAL_X_HOME_POS
#define Y_HOME_POS MANUAL_Y_HOME_POS
#define Z_HOME_POS MANUAL_Z_HOME_POS
#else //!MANUAL_HOME_POSITIONS – Use home switch positions based on homing direction and travel limits
#if ENABLED(BED_CENTER_AT_0_0)
#ifdef BED_CENTER_AT_0_0
#define X_HOME_POS X_MAX_LENGTH * X_HOME_DIR * 0.5
#define Y_HOME_POS Y_MAX_LENGTH * Y_HOME_DIR * 0.5
#else
......@@ -347,7 +349,7 @@
/**
* Auto Bed Leveling
*/
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
// Boundaries for probing based on set limits
#define MIN_PROBE_X (max(X_MIN_POS, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define MAX_PROBE_X (min(X_MAX_POS, X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
......@@ -358,7 +360,7 @@
/**
* Sled Options
*/
#if ENABLED(Z_PROBE_SLED)
#ifdef Z_PROBE_SLED
#define Z_SAFE_HOMING
#endif
......@@ -372,7 +374,7 @@
* MAX_STEP_FREQUENCY differs for TOSHIBA OR ARDUINO DUE OR ARDUINO MEGA
*/
#ifdef __SAM3X8E__
#if ENABLED(CONFIG_STEPPERS_TOSHIBA)
#ifdef CONFIG_STEPPERS_TOSHIBA
#define MAX_STEP_FREQUENCY 120000 // Max step frequency for Toshiba Stepper Controllers
#define DOUBLE_STEP_FREQUENCY MAX_STEP_FREQUENCY
#else
......@@ -380,7 +382,7 @@
#define DOUBLE_STEP_FREQUENCY 120000 //96kHz is close to maximum for an Arduino Due
#endif
#else
#if ENABLED(CONFIG_STEPPERS_TOSHIBA)
#ifdef CONFIG_STEPPERS_TOSHIBA
#define MAX_STEP_FREQUENCY 10000 // Max step frequency for Toshiba Stepper Controllers
#define DOUBLE_STEP_FREQUENCY MAX_STEP_FREQUENCY
#else
......@@ -403,12 +405,12 @@
/**
* Advance calculated values
*/
#if ENABLED(ADVANCE)
#ifdef ADVANCE
#define EXTRUSION_AREA (0.25 * D_FILAMENT * D_FILAMENT * M_PI)
#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS] / EXTRUSION_AREA)
#endif
#if ENABLED(ULTIPANEL)
#ifdef ULTIPANEL
#undef SDCARDDETECTINVERTED
#endif
......@@ -509,10 +511,101 @@
#define ARRAY_BY_HOTENDS(v1, v2, v3, v4) { v1 }
#endif
/**
* Shorthand for pin tests, used wherever needed
*/
#define HAS_TEMP_0 (PIN_EXISTS(TEMP_0) && TEMP_SENSOR_0 != 0 && TEMP_SENSOR_0 != -2)
#define HAS_TEMP_1 (PIN_EXISTS(TEMP_1) && TEMP_SENSOR_1 != 0)
#define HAS_TEMP_2 (PIN_EXISTS(TEMP_2) && TEMP_SENSOR_2 != 0)
#define HAS_TEMP_3 (PIN_EXISTS(TEMP_3) && TEMP_SENSOR_3 != 0)
#define HAS_TEMP_BED (PIN_EXISTS(TEMP_BED) && TEMP_SENSOR_BED != 0)
#define HAS_HEATER_0 (PIN_EXISTS(HEATER_0))
#define HAS_HEATER_1 (PIN_EXISTS(HEATER_1))
#define HAS_HEATER_2 (PIN_EXISTS(HEATER_2))
#define HAS_HEATER_3 (PIN_EXISTS(HEATER_3))
#define HAS_HEATER_BED (PIN_EXISTS(HEATER_BED))
#define HAS_AUTO_FAN_0 (PIN_EXISTS(EXTRUDER_0_AUTO_FAN))
#define HAS_AUTO_FAN_1 (PIN_EXISTS(EXTRUDER_1_AUTO_FAN))
#define HAS_AUTO_FAN_2 (PIN_EXISTS(EXTRUDER_2_AUTO_FAN))
#define HAS_AUTO_FAN_3 (PIN_EXISTS(EXTRUDER_3_AUTO_FAN))
#define HAS_AUTO_FAN (HAS_AUTO_FAN_0 || HAS_AUTO_FAN_1 || HAS_AUTO_FAN_2 || HAS_AUTO_FAN_3)
#define HAS_FAN (PIN_EXISTS(FAN))
#define HAS_CONTROLLERFAN (PIN_EXISTS(CONTROLLERFAN))
#define HAS_SERVO_0 (PIN_EXISTS(SERVO0))
#define HAS_SERVO_1 (PIN_EXISTS(SERVO1))
#define HAS_SERVO_2 (PIN_EXISTS(SERVO2))
#define HAS_SERVO_3 (PIN_EXISTS(SERVO3))
#define HAS_FILAMENT_SENSOR (defined(FILAMENT_SENSOR) && PIN_EXISTS(FILWIDTH))
#define HAS_POWER_CONSUMPTION_SENSOR (defined(POWER_CONSUMPTION) && PIN_EXISTS(POWER_CONSUMPTION))
#define HAS_FILRUNOUT (defined(FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FILRUNOUT))
#define HAS_HOME (PIN_EXISTS(HOME))
#define HAS_KILL (PIN_EXISTS(KILL))
#define HAS_SUICIDE (PIN_EXISTS(SUICIDE))
#define HAS_PHOTOGRAPH (PIN_EXISTS(PHOTOGRAPH))
#define HAS_X_MIN (PIN_EXISTS(X_MIN))
#define HAS_X_MAX (PIN_EXISTS(X_MAX))
#define HAS_Y_MIN (PIN_EXISTS(Y_MIN))
#define HAS_Y_MAX (PIN_EXISTS(Y_MAX))
#define HAS_Z_MIN (PIN_EXISTS(Z_MIN))
#define HAS_Z_MAX (PIN_EXISTS(Z_MAX))
#define HAS_Z2_MIN (PIN_EXISTS(Z2_MIN))
#define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX))
#define HAS_Z_PROBE (PIN_EXISTS(Z_PROBE))
#define HAS_E_MIN (PIN_EXISTS(E_MIN))
#define HAS_SOLENOID_1 (PIN_EXISTS(SOL1))
#define HAS_SOLENOID_2 (PIN_EXISTS(SOL2))
#define HAS_SOLENOID_3 (PIN_EXISTS(SOL3))
#define HAS_MICROSTEPS (PIN_EXISTS(X_MS1))
#define HAS_MICROSTEPS_E0 (PIN_EXISTS(E0_MS1))
#define HAS_MICROSTEPS_E1 (PIN_EXISTS(E1_MS1))
#define HAS_MICROSTEPS_E2 (PIN_EXISTS(E2_MS1))
#define HAS_X_ENABLE (PIN_EXISTS(X_ENABLE))
#define HAS_X2_ENABLE (PIN_EXISTS(X2_ENABLE))
#define HAS_Y_ENABLE (PIN_EXISTS(Y_ENABLE))
#define HAS_Y2_ENABLE (PIN_EXISTS(Y2_ENABLE))
#define HAS_Z_ENABLE (PIN_EXISTS(Z_ENABLE))
#define HAS_Z2_ENABLE (PIN_EXISTS(Z2_ENABLE))
#define HAS_E0_ENABLE (PIN_EXISTS(E0_ENABLE))
#define HAS_E1_ENABLE (PIN_EXISTS(E1_ENABLE))
#define HAS_E2_ENABLE (PIN_EXISTS(E2_ENABLE))
#define HAS_E3_ENABLE (PIN_EXISTS(E3_ENABLE))
#define HAS_X_DIR (PIN_EXISTS(X_DIR))
#define HAS_X2_DIR (PIN_EXISTS(X2_DIR))
#define HAS_Y_DIR (PIN_EXISTS(Y_DIR))
#define HAS_Y2_DIR (PIN_EXISTS(Y2_DIR))
#define HAS_Z_DIR (PIN_EXISTS(Z_DIR))
#define HAS_Z2_DIR (PIN_EXISTS(Z2_DIR))
#define HAS_E0_DIR (PIN_EXISTS(E0_DIR))
#define HAS_E1_DIR (PIN_EXISTS(E1_DIR))
#define HAS_E2_DIR (PIN_EXISTS(E2_DIR))
#define HAS_E3_DIR (PIN_EXISTS(E3_DIR))
#define HAS_X_STEP (PIN_EXISTS(X_STEP))
#define HAS_X2_STEP (PIN_EXISTS(X2_STEP))
#define HAS_Y_STEP (PIN_EXISTS(Y_STEP))
#define HAS_Y2_STEP (PIN_EXISTS(Y2_STEP))
#define HAS_Z_STEP (PIN_EXISTS(Z_STEP))
#define HAS_Z2_STEP (PIN_EXISTS(Z2_STEP))
#define HAS_E0_STEP (PIN_EXISTS(E0_STEP))
#define HAS_E1_STEP (PIN_EXISTS(E1_STEP))
#define HAS_E2_STEP (PIN_EXISTS(E2_STEP))
#define HAS_E3_STEP (PIN_EXISTS(E3_STEP))
#define HAS_E0E1 (PIN_EXISTS(E0E1_CHOICE))
#define HAS_E0E2 (PIN_EXISTS(E0E2_CHOICE))
#define HAS_E0E3 (PIN_EXISTS(E0E3_CHOICE))
#define HAS_E0E4 (PIN_EXISTS(E0E4_CHOICE))
#define HAS_E1E3 (PIN_EXISTS(E1E3_CHOICE))
#define HAS_BTN_BACK (PIN_EXISTS(BTN_BACK))
/**
* Shorthand for filament sensor and power sensor for ultralcd.cpp, dogm_lcd_implementation.h, ultralcd_implementation_hitachi_HD44780.h
*/
#define HAS_LCD_FILAMENT_SENSOR (HAS_FILAMENT_SENSOR && defined(FILAMENT_LCD_DISPLAY))
#define HAS_LCD_POWER_SENSOR (HAS_POWER_CONSUMPTION_SENSOR && defined(POWER_CONSUMPTION_LCD_DISPLAY))
/**
* Helper Macros for heaters and extruder fan
*/
#if ENABLED(INVERTED_HEATER_PINS)
#ifdef INVERTED_HEATER_PINS
#define WRITE_HEATER(pin,value) WRITE(pin,!value)
#else
#define WRITE_HEATER(pin,value) WRITE(pin,value)
......@@ -527,7 +620,7 @@
#endif
#endif
#endif
#if ENABLED(HEATERS_PARALLEL)
#ifdef HEATERS_PARALLEL
#define WRITE_HEATER_0(v) { WRITE_HEATER_0P(v); WRITE_HEATER_1(v); }
#else
#define WRITE_HEATER_0(v) WRITE_HEATER_0P(v)
......@@ -540,5 +633,4 @@
#endif
#endif //CONFIGURATION_LCD
#endif //CONDITIONALS_H
......@@ -102,7 +102,7 @@
#include "ultralcd.h"
#include "configuration_store.h"
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
#include "cardreader.h"
#endif
......@@ -138,7 +138,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
#define EEPROM_OFFSET 100
#if ENABLED(EEPROM_SETTINGS)
#ifdef EEPROM_SETTINGS
void Config_StoreSettings() {
float dummy = 0.0f;
......@@ -159,7 +159,7 @@ void Config_StoreSettings() {
EEPROM_WRITE_VAR(i, max_e_jerk);
EEPROM_WRITE_VAR(i, home_offset);
#if DISABLED(DELTA)
#ifndef DELTA
EEPROM_WRITE_VAR(i, zprobe_zoffset);
#endif
......@@ -167,18 +167,18 @@ void Config_StoreSettings() {
EEPROM_WRITE_VAR(i, hotend_offset);
#endif
#if ENABLED(DELTA)
#ifdef DELTA
EEPROM_WRITE_VAR(i, endstop_adj);
EEPROM_WRITE_VAR(i, delta_radius);
EEPROM_WRITE_VAR(i, delta_diagonal_rod);
EEPROM_WRITE_VAR(i, max_pos);
EEPROM_WRITE_VAR(i, tower_adj);
EEPROM_WRITE_VAR(i, z_probe_offset);
#elif ENABLED(Z_DUAL_ENDSTOPS)
#elif defined(Z_DUAL_ENDSTOPS)
EEPROM_WRITE_VAR(i, z_endstop_adj); // 1 floats
#endif
#if DISABLED(ULTIPANEL)
#ifndef ULTIPANEL
int plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP, plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP, plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED,
absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP, absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP, absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED,
gumPreheatHotendTemp = GUM_PREHEAT_HOTEND_TEMP, gumPreheatHPBTemp = GUM_PREHEAT_HPB_TEMP, gumPreheatFanSpeed = GUM_PREHEAT_FAN_SPEED;
......@@ -195,7 +195,7 @@ void Config_StoreSettings() {
EEPROM_WRITE_VAR(i, gumPreheatFanSpeed);
for (int e = 0; e < 4; e++) {
#if ENABLED(PIDTEMP)
#ifdef PIDTEMP
if (e < HOTENDS) {
EEPROM_WRITE_VAR(i, PID_PARAM(Kp, e));
EEPROM_WRITE_VAR(i, PID_PARAM(Ki, e));
......@@ -212,7 +212,7 @@ void Config_StoreSettings() {
} // Extruders Loop
#if DISABLED(PIDTEMPBED)
#ifndef PIDTEMPBED
float bedKp = DUMMY_PID_VALUE, bedKi = DUMMY_PID_VALUE, bedKd = DUMMY_PID_VALUE;
#endif
......@@ -220,19 +220,19 @@ void Config_StoreSettings() {
EEPROM_WRITE_VAR(i, bedKi);
EEPROM_WRITE_VAR(i, bedKd);
#if DISABLED(DOGLCD) || LCD_CONTRAST < 0
#if defined(DOGLCD) || LCD_CONTRAST < 0
const int lcd_contrast = 32;
#endif
EEPROM_WRITE_VAR(i, lcd_contrast);
#if ENABLED(SCARA)
#ifdef SCARA
EEPROM_WRITE_VAR(i, axis_scaling); // 3 floats
#else
dummy = 1.0f;
EEPROM_WRITE_VAR(i, dummy);
#endif
#if ENABLED(FWRETRACT)
#ifdef FWRETRACT
EEPROM_WRITE_VAR(i, autoretract_enabled);
EEPROM_WRITE_VAR(i, retract_length);
#if EXTRUDERS > 1
......@@ -261,7 +261,7 @@ void Config_StoreSettings() {
EEPROM_WRITE_VAR(i, dummy);
}
#if ENABLED(IDLE_OOZING_PREVENT)
#ifdef IDLE_OOZING_PREVENT
EEPROM_WRITE_VAR(i, idleoozing_enabled);
#endif
......@@ -310,7 +310,7 @@ void Config_RetrieveSettings() {
EEPROM_READ_VAR(i, max_e_jerk);
EEPROM_READ_VAR(i, home_offset);
#if DISABLED(DELTA)
#ifndef DELTA
EEPROM_READ_VAR(i, zprobe_zoffset);
#endif
......@@ -318,7 +318,7 @@ void Config_RetrieveSettings() {
EEPROM_READ_VAR(i, hotend_offset);
#endif
#if ENABLED(DELTA)
#ifdef DELTA
EEPROM_READ_VAR(i, endstop_adj);
EEPROM_READ_VAR(i, delta_radius);
EEPROM_READ_VAR(i, delta_diagonal_rod);
......@@ -329,7 +329,7 @@ void Config_RetrieveSettings() {
set_delta_constants();
#endif //DELTA
#if DISABLED(ULTIPANEL)
#ifndef ULTIPANEL
int plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed,
absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed,
gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed;
......@@ -345,7 +345,7 @@ void Config_RetrieveSettings() {
EEPROM_READ_VAR(i, gumPreheatHPBTemp);
EEPROM_READ_VAR(i, gumPreheatFanSpeed);
#if ENABLED(PIDTEMP)
#ifdef PIDTEMP
for (int e = 0; e < 4; e++) { // 4 = max hotend currently supported
EEPROM_READ_VAR(i, dummy); // Kp
if (e < EXTRUDERS && dummy != DUMMY_PID_VALUE) {
......@@ -363,7 +363,7 @@ void Config_RetrieveSettings() {
for (int q = 12; q--;) EEPROM_READ_VAR(i, dummy); // 4x Kp, Ki, Kd
#endif // !PIDTEMP
#if DISABLED(PIDTEMPBED)
#ifndef PIDTEMPBED
float bedKp, bedKi, bedKd;
#endif
......@@ -377,19 +377,19 @@ void Config_RetrieveSettings() {
for (int q = 2; q--;) EEPROM_READ_VAR(i, dummy); // bedKi, bedKd
}
#if DISABLED(DOGLCD) || LCD_CONTRAST < 0
#if defined(DOGLCD) || LCD_CONTRAST < 0
int lcd_contrast;
#endif
EEPROM_READ_VAR(i, lcd_contrast);
#if ENABLED(SCARA)
#ifdef SCARA
EEPROM_READ_VAR(i, axis_scaling); // 3 floats
#else
EEPROM_READ_VAR(i, dummy);
#endif
#if ENABLED(FWRETRACT)
#ifdef FWRETRACT
EEPROM_READ_VAR(i, autoretract_enabled);
EEPROM_READ_VAR(i, retract_length);
#if EXTRUDERS > 1
......@@ -417,7 +417,7 @@ void Config_RetrieveSettings() {
calculate_volumetric_multipliers();
#if ENABLED(IDLE_OOZING_PREVENT)
#ifdef IDLE_OOZING_PREVENT
EEPROM_READ_VAR(i, idleoozing_enabled);
#endif
......@@ -444,13 +444,13 @@ void Config_ResetDefault() {
float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT;
float tmp2[] = DEFAULT_MAX_FEEDRATE;
long tmp3[] = DEFAULT_MAX_ACCELERATION;
#if ENABLED(PIDTEMP)
#ifdef PIDTEMP
float tmp4[] = DEFAULT_Kp;
float tmp5[] = DEFAULT_Ki;
float tmp6[] = DEFAULT_Kd;
#endif // PIDTEMP
#if ENABLED(HOTEND_OFFSET_X) && ENABLED(HOTEND_OFFSET_Y)
#if defined(HOTEND_OFFSET_X) && defined(HOTEND_OFFSET_Y)
float tmp7[] = HOTEND_OFFSET_X;
float tmp8[] = HOTEND_OFFSET_Y;
#else
......@@ -469,7 +469,7 @@ void Config_ResetDefault() {
hotend_offset[X_AXIS][i] = tmp7[i];
hotend_offset[Y_AXIS][i] = tmp8[i];
#endif
#if ENABLED(SCARA)
#ifdef SCARA
if (i < sizeof(axis_scaling) / sizeof(*axis_scaling))
axis_scaling[i] = 1;
#endif
......@@ -489,13 +489,13 @@ void Config_ResetDefault() {
max_e_jerk = DEFAULT_EJERK;
home_offset[X_AXIS] = home_offset[Y_AXIS] = home_offset[Z_AXIS] = 0;
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
#elif DISABLED(DELTA)
#elif !defined(DELTA)
zprobe_zoffset = 0;
#endif
#if ENABLED(DELTA)
#ifdef DELTA
endstop_adj[X_AXIS] = endstop_adj[Y_AXIS] = endstop_adj[Z_AXIS] = 0;
delta_radius = DEFAULT_DELTA_RADIUS;
delta_diagonal_rod = DEFAULT_DELTA_DIAGONAL_ROD;
......@@ -505,7 +505,7 @@ void Config_ResetDefault() {
set_delta_constants();
#endif
#if ENABLED(ULTIPANEL)
#ifdef ULTIPANEL
plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP;
plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP;
plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED;
......@@ -517,11 +517,11 @@ void Config_ResetDefault() {
gumPreheatFanSpeed = GUM_PREHEAT_FAN_SPEED;
#endif
#if ENABLED(HAS_LCD_CONTRAST)
#ifdef HAS_LCD_CONTRAST
lcd_contrast = DEFAULT_LCD_CONTRAST;
#endif //DOGLCD
#if ENABLED(PIDTEMP)
#ifdef PIDTEMP
for (int e = 0; e < HOTENDS; e++)
{
Kp[e] = tmp4[e];
......@@ -532,13 +532,13 @@ void Config_ResetDefault() {
updatePID();
#endif // PIDTEMP
#if ENABLED(PIDTEMPBED)
#ifdef PIDTEMPBED
bedKp = DEFAULT_bedKp;
bedKi = scalePID_i(DEFAULT_bedKi);
bedKd = scalePID_d(DEFAULT_bedKd);
#endif
#if ENABLED(FWRETRACT)
#ifdef FWRETRACT
autoretract_enabled = false;
retract_length = RETRACT_LENGTH;
#if EXTRUDERS > 1
......@@ -566,14 +566,14 @@ void Config_ResetDefault() {
#endif // EXTRUDERS > 1
calculate_volumetric_multipliers();
#if ENABLED(IDLE_OOZING_PREVENT)
#ifdef IDLE_OOZING_PREVENT
idleoozing_enabled = true;
#endif
ECHO_LM(DB, "Hardcoded Default Settings Loaded");
}
#if DISABLED(DISABLE_M503)
#if !defined(DISABLE_M503)
/**
* Print Configuration Settings - M503
......@@ -599,7 +599,7 @@ void Config_ResetDefault() {
#endif //EXTRUDERS > 1
ECHO_E;
#if ENABLED(SCARA)
#ifdef SCARA
if (!forReplay) {
ECHO_LM(DB, "Scaling factors:");
}
......@@ -679,7 +679,7 @@ void Config_ResetDefault() {
}
#endif //HOTENDS > 1
#if ENABLED(DELTA)
#ifdef DELTA
if (!forReplay) {
ECHO_LM(DB, "Delta Geometry adjustment:");
}
......@@ -707,19 +707,19 @@ void Config_ResetDefault() {
ECHO_MV(" Y", z_probe_offset[1]);
ECHO_EMV(" Z", z_probe_offset[2]);
#elif ENABLED(Z_DUAL_ENDSTOPS)
#elif defined(Z_DUAL_ENDSTOPS)
if (!forReplay) {
ECHO_LM(DB, "Z2 Endstop adjustement (mm):");
}
ECHO_LMV(DB, " M666 Z", z_endstop_adj );
#elif ENABLED(ENABLE_AUTO_BED_LEVELING)
#elif defined(ENABLE_AUTO_BED_LEVELING)
if (!forReplay) {
ECHO_LM(DB, "Z Probe offset (mm)");
}
ECHO_LMV(DB, " M666 P", zprobe_zoffset);
#endif
#if ENABLED(ULTIPANEL)
#ifdef ULTIPANEL
if (!forReplay) {
ECHO_LM(DB, "Material heatup parameters:");
}
......@@ -737,11 +737,11 @@ void Config_ResetDefault() {
ECHO_EM(" (Material GUM)");
#endif // ULTIPANEL
#if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED)
#if defined(PIDTEMP) || defined(PIDTEMPBED)
if (!forReplay) {
ECHO_LM(DB, "PID settings:");
}
#if ENABLED(PIDTEMP)
#ifdef PIDTEMP
for (int e = 0; e < HOTENDS; e++) {
ECHO_SMV(DB, " M301 E", e);
ECHO_MV(" P", PID_PARAM(Kp, e));
......@@ -749,14 +749,14 @@ void Config_ResetDefault() {
ECHO_EMV(" D", unscalePID_d(PID_PARAM(Kd, e)));
}
#endif
#if ENABLED(PIDTEMPBED)
#ifdef PIDTEMPBED
ECHO_SMV(DB, " M304 P", bedKp); // for compatibility with hosts, only echos values for E0
ECHO_MV(" I", unscalePID_i(bedKi));
ECHO_EMV(" D", unscalePID_d(bedKd));
#endif
#endif
#if ENABLED(FWRETRACT)
#ifdef FWRETRACT
if (!forReplay) {
ECHO_LM(DB,"Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
}
......@@ -813,7 +813,7 @@ void Config_ResetDefault() {
void ConfigSD_PrintSettings(bool forReplay) {
// Always have this function, even with SD_SETTINGS disabled, the current values will be shown
#if ENABLED(POWER_CONSUMPTION)
#ifdef POWER_CONSUMPTION
if (!forReplay) {
ECHO_LM(DB, "Watt/h consumed:");
}
......@@ -837,14 +837,14 @@ void Config_ResetDefault() {
*
*/
void ConfigSD_ResetDefault() {
#if ENABLED(POWER_CONSUMPTION)
#ifdef POWER_CONSUMPTION
power_consumption_hour = 0;
#endif
printer_usage_seconds = 0;
ECHO_LM(OK, "Hardcoded SD Default Settings Loaded");
}
#if ENABLED(SDSUPPORT) && ENABLED(SD_SETTINGS)
#if defined(SDSUPPORT) && defined(SD_SETTINGS)
void ConfigSD_StoreSettings() {
if(!IS_SD_INSERTED || card.isFileOpen() || card.sdprinting) return;
......
......@@ -6,7 +6,7 @@
void Config_ResetDefault();
void ConfigSD_ResetDefault();
#if DISABLED(DISABLE_M503)
#ifndef DISABLE_M503
void Config_PrintSettings(bool forReplay = false);
void ConfigSD_PrintSettings(bool forReplay = false);
#else
......@@ -22,7 +22,7 @@ void ConfigSD_ResetDefault();
FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }
#endif
#if ENABLED(SDSUPPORT) && ENABLED(SD_SETTINGS)
#if defined(SDSUPPORT) && defined(SD_SETTINGS)
static const char *cfgSD_KEY[] = { //Keep this in lexicographical order for better search performance(O(Nlog2(N)) insted of O(N*N)) (if you don't keep this sorted, the algorithm for find the key index won't work, keep attention.)
#ifdef POWER_CONSUMPTION
"PWR",
......
......@@ -3,7 +3,7 @@
// Please note that using the high-res version takes 402Bytes of PROGMEM.
//#define START_BMPHIGH
#if ENABLED(START_BMPHIGH)
#ifdef START_BMPHIGH
#define START_BMPWIDTH 112
#define START_BMPHEIGHT 38
#define START_BMPBYTEWIDTH 14
......
......@@ -18,7 +18,7 @@
* Implementation of the LCD display routines for a DOGM128 graphic display. These are common LCD 128x64 pixel graphic displays.
*/
#if ENABLED(ULTIPANEL)
#ifdef ULTIPANEL
#define BLEN_A 0
#define BLEN_B 1
#define BLEN_C 2
......@@ -35,12 +35,12 @@
#include "ultralcd_st7920_u8glib_rrd.h"
#include "Configuration.h"
#if DISABLED(MAPPER_C2C3) && DISABLED(MAPPER_NON) && ENABLED(USE_BIG_EDIT_FONT)
#if defined(MAPPER_C2C3) && defined(MAPPER_NON) && defined(USE_BIG_EDIT_FONT)
#undef USE_BIG_EDIT_FONT
#endif
#if ENABLED(USE_SMALL_INFOFONT)
#ifdef USE_SMALL_INFOFONT
#include "dogm_font_data_6x9_marlin.h"
#define FONT_STATUSMENU_NAME u8g_font_6x9
#else
......@@ -50,17 +50,17 @@
#include "dogm_font_data_Marlin_symbols.h" // The Marlin special symbols
#define FONT_SPECIAL_NAME Marlin_symbols
#if DISABLED(SIMULATE_ROMFONT)
#if ENABLED(DISPLAY_CHARSET_ISO10646_1)
#ifndef SIMULATE_ROMFONT
#if defined( DISPLAY_CHARSET_ISO10646_1 )
#include "dogm_font_data_ISO10646_1.h"
#define FONT_MENU_NAME ISO10646_1_5x7
#elif ENABLED(DISPLAY_CHARSET_ISO10646_5)
#elif defined( DISPLAY_CHARSET_ISO10646_5 )
#include "dogm_font_data_ISO10646_5_Cyrillic.h"
#define FONT_MENU_NAME ISO10646_5_Cyrillic_5x7
#elif ENABLED(DISPLAY_CHARSET_ISO10646_KANA)
#elif defined( DISPLAY_CHARSET_ISO10646_KANA )
#include "dogm_font_data_ISO10646_Kana.h"
#define FONT_MENU_NAME ISO10646_Kana_5x7
#elif ENABLED(DISPLAY_CHARSET_ISO10646_CN)
#elif defined( DISPLAY_CHARSET_ISO10646_CN )
#include "dogm_font_data_ISO10646_CN.h"
#define FONT_MENU_NAME ISO10646_CN
#define TALL_FONT_CORRECTION 1
......@@ -69,13 +69,13 @@
#define FONT_MENU_NAME ISO10646_1_5x7
#endif
#else // SIMULATE_ROMFONT
#if ENABLED(DISPLAY_CHARSET_HD44780_JAPAN)
#if defined( DISPLAY_CHARSET_HD44780_JAPAN )
#include "dogm_font_data_HD44780_J.h"
#define FONT_MENU_NAME HD44780_J_5x7
#elif ENABLED(DISPLAY_CHARSET_HD44780_WESTERN)
#elif defined( DISPLAY_CHARSET_HD44780_WESTERN )
#include "dogm_font_data_HD44780_W.h"
#define FONT_MENU_NAME HD44780_W_5x7
#elif ENABLED(DISPLAY_CHARSET_HD44780_CYRILLIC)
#elif defined( DISPLAY_CHARSET_HD44780_CYRILLIC )
#include "dogm_font_data_HD44780_C.h"
#define FONT_MENU_NAME HD44780_C_5x7
#else // fall-back
......@@ -94,7 +94,7 @@
// DOGM parameters (size in pixels)
#define DOG_CHAR_WIDTH 6
#define DOG_CHAR_HEIGHT 12
#if ENABLED(USE_BIG_EDIT_FONT)
#ifdef USE_BIG_EDIT_FONT
#define FONT_MENU_EDIT_NAME u8g_font_9x18
#define DOG_CHAR_WIDTH_EDIT 9
#define DOG_CHAR_HEIGHT_EDIT 18
......@@ -113,16 +113,16 @@
#define START_ROW 0
// LCD selection
#if ENABLED(U8GLIB_ST7920)
#ifdef U8GLIB_ST7920
//U8GLIB_ST7920_128X64_RRD u8g(0,0,0);
U8GLIB_ST7920_128X64_RRD u8g(0);
#elif ENABLED(MAKRPANEL)
#elif defined(MAKRPANEL)
// The MaKrPanel display, ST7565 controller as well
U8GLIB_NHD_C12864 u8g(DOGLCD_CS, DOGLCD_A0);
#elif ENABLED(VIKI2) || ENABLED(miniVIKI)
#elif defined(VIKI2) || defined(miniVIKI)
// Mini Viki and Viki 2.0 LCD, ST7565 controller as well
U8GLIB_NHD_C12864 u8g(DOGLCD_CS, DOGLCD_A0);
#elif ENABLED(U8GLIB_LM6059_AF)
#elif defined(U8GLIB_LM6059_AF)
// Based on the Adafruit ST7565 (http://www.adafruit.com/products/250)
U8GLIB_LM6059 u8g(DOGLCD_CS, DOGLCD_A0);
#else
......@@ -189,7 +189,7 @@ static bool show_splashscreen = true;
/* Warning: This function is called from interrupt context */
static void lcd_implementation_init() {
#if ENABLED(LCD_PIN_BL) // Enable LCD backlight
#ifdef LCD_PIN_BL // Enable LCD backlight
pinMode(LCD_PIN_BL, OUTPUT);
digitalWrite(LCD_PIN_BL, HIGH);
#endif
......@@ -200,17 +200,17 @@ static void lcd_implementation_init() {
// pinMode(17, OUTPUT); // Enable LCD backlight
// digitalWrite(17, HIGH);
#if ENABLED(LCD_SCREEN_ROT_90)
#ifdef LCD_SCREEN_ROT_90
u8g.setRot90(); // Rotate screen by 90°
#elif ENABLED(LCD_SCREEN_ROT_180)
#elif defined(LCD_SCREEN_ROT_180)
u8g.setRot180(); // Rotate screen by 180°
#elif ENABLED(LCD_SCREEN_ROT_270)
#elif defined(LCD_SCREEN_ROT_270)
u8g.setRot270(); // Rotate screen by 270°
#endif
// Show splashscreen
int offx = (u8g.getWidth() - START_BMPWIDTH) / 2;
#if ENABLED(START_BMPHIGH)
#ifdef START_BMPHIGH
int offy = 0;
#else
int offy = DOG_CHAR_HEIGHT;
......@@ -265,7 +265,7 @@ static void lcd_implementation_status_screen() {
// Symbols menu graphics, animated fan
u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp);
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
// SD Card Symbol
u8g.drawBox(42, 42 - TALL_FONT_CORRECTION, 8, 7);
u8g.drawBox(50, 44 - TALL_FONT_CORRECTION, 2, 5);
......@@ -333,7 +333,7 @@ static void lcd_implementation_status_screen() {
#define XYZ_BASELINE 38
lcd_setFont(FONT_STATUSMENU);
#if ENABLED(USE_SMALL_INFOFONT)
#ifdef USE_SMALL_INFOFONT
u8g.drawBox(0,30,LCD_PIXEL_WIDTH,10);
#else
u8g.drawBox(0,30,LCD_PIXEL_WIDTH,9);
......@@ -344,28 +344,19 @@ static void lcd_implementation_status_screen() {
u8g.drawPixel(8,XYZ_BASELINE - 5);
u8g.drawPixel(8,XYZ_BASELINE - 3);
u8g.setPrintPos(10,XYZ_BASELINE);
if (axis_known_position[X_AXIS])
lcd_print(ftostr31ns(current_position[X_AXIS]));
else
lcd_printPGM(PSTR("---"));
u8g.setPrintPos(43,XYZ_BASELINE);
lcd_print('Y');
u8g.drawPixel(49,XYZ_BASELINE - 5);
u8g.drawPixel(49,XYZ_BASELINE - 3);
u8g.setPrintPos(51,XYZ_BASELINE);
if (axis_known_position[Y_AXIS])
lcd_print(ftostr31ns(current_position[Y_AXIS]));
else
lcd_printPGM(PSTR("---"));
u8g.setPrintPos(83,XYZ_BASELINE);
lcd_print('Z');
u8g.drawPixel(89,XYZ_BASELINE - 5);
u8g.drawPixel(89,XYZ_BASELINE - 3);
u8g.setPrintPos(91,XYZ_BASELINE);
if (axis_known_position[Z_AXIS])
lcd_print(ftostr32sp(current_position[Z_AXIS]));
else
lcd_printPGM(PSTR("---.--"));
lcd_print(ftostr31(current_position[Z_AXIS]));
u8g.setColorIndex(1); // black on white
// Feedrate
......@@ -379,7 +370,7 @@ static void lcd_implementation_status_screen() {
// Status line
lcd_setFont(FONT_STATUSMENU);
#if ENABLED(USE_SMALL_INFOFONT)
#ifdef USE_SMALL_INFOFONT
u8g.setPrintPos(0,62);
#else
u8g.setPrintPos(0,63);
......@@ -491,7 +482,7 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
uint8_t lcd_width = LCD_WIDTH, char_width = DOG_CHAR_WIDTH;
uint8_t vallen = lcd_strlen(value);
#if ENABLED(USE_BIG_EDIT_FONT)
#ifdef USE_BIG_EDIT_FONT
if (lcd_strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) {
lcd_setFont(FONT_MENU_EDIT);
lcd_width = LCD_WIDTH_EDIT + 1;
......
......@@ -197,9 +197,9 @@
#define MSG_KP " Kp: "
#define MSG_KI " Ki: "
#define MSG_KD " Kd: "
#define MSG_B " B:"
#define MSG_T " T:"
#define MSG_AT " @:"
#define MSG_T "T:"
#define MSG_B "B:"
#define MSG_AT "@:"
#define MSG_PID_AUTOTUNE_FINISHED MSG_PID_AUTOTUNE " finished! Put the last Kp, Ki and Kd constants from above into Configuration.h or send command M500 for save in EEPROM the new value!"
#define MSG_PID_DEBUG " PID_DEBUG "
#define MSG_PID_DEBUG_INPUT ": Input "
......@@ -232,7 +232,8 @@
#define MSG_BED_LEVELLING_Z " Z: "
// LCD Menu Messages
#if !(ENABLED(DISPLAY_CHARSET_HD44780_JAPAN) || ENABLED(DISPLAY_CHARSET_HD44780_WESTERN) || ENABLED(DISPLAY_CHARSET_HD44780_CYRILLIC))
#if !(defined( DISPLAY_CHARSET_HD44780_JAPAN ) || defined( DISPLAY_CHARSET_HD44780_WESTERN ) || defined( DISPLAY_CHARSET_HD44780_CYRILLIC ))
#define DISPLAY_CHARSET_HD44780_JAPAN
#endif
......
......@@ -24,14 +24,15 @@
#define MSG_AUTOSTART "Autostart"
#define MSG_DISABLE_STEPPERS "Disable steppers"
#define MSG_AUTO_HOME "Auto home"
#define MSG_BED_SETTING "Bed Setting"
#define MSG_LP_INTRO " Leveling bed... Press to start "
#define MSG_LP_1 " Adjust first point & Press the button"
#define MSG_LP_2 " Adjust second point & Press the button"
#define MSG_LP_3 " Adjust third point & Press the button"
#define MSG_LP_4 " Adjust fourth point & Press the button"
#define MSG_LP_5 " Is it ok? Press to end"
#define MSG_LP_6 " BED leveled!"
#define MSG_MBL_SETTING "Manual Bed Leveling"
#define MSG_MBL_BUTTON " Press the button "
#define MSG_MBL_INTRO " Leveling bed... "
#define MSG_MBL_1 " Adjust first point "
#define MSG_MBL_2 " Adjust second point"
#define MSG_MBL_3 " Adjust third point "
#define MSG_MBL_4 " Adjust fourth point"
#define MSG_MBL_5 " Is it ok? "
#define MSG_MBL_6 " BED leveled! "
#define MSG_SET_HOME_OFFSETS "Set home offsets"
#define MSG_SET_ORIGIN "Set origin"
#define MSG_PREHEAT_PLA "Preheat PLA"
......
......@@ -24,14 +24,15 @@
#define MSG_AUTOSTART "Autostart"
#define MSG_DISABLE_STEPPERS "Disabilita Motori"
#define MSG_AUTO_HOME "Auto Home"
#define MSG_BED_SETTING "Bed Setting"
#define MSG_LP_INTRO " Leveling bed... Press to start "
#define MSG_LP_1 " Adjust first point & Press the button"
#define MSG_LP_2 " Adjust second point & Press the button"
#define MSG_LP_3 " Adjust third point & Press the button"
#define MSG_LP_4 " Adjust fourth point & Press the button"
#define MSG_LP_5 " Is it ok? Press to end"
#define MSG_LP_6 " BED leveled!"
#define MSG_MBL_SETTING "Manual Bed Leveling "
#define MSG_MBL_BUTTON " Press the button "
#define MSG_MBL_INTRO " Leveling bed... "
#define MSG_MBL_1 " Adjust first point "
#define MSG_MBL_2 " Adjust second point"
#define MSG_MBL_3 " Adjust third point "
#define MSG_MBL_4 " Adjust fourth point"
#define MSG_MBL_5 " Is it ok? "
#define MSG_MBL_6 " BED leveled! "
#define MSG_SET_HOME_OFFSETS "Setta offset home"
#define MSG_SET_ORIGIN "Imposta Origine"
#define MSG_PREHEAT_PLA "Preriscalda PLA"
......
#ifndef MACROS_H
#define MACROS_H
// Macros for bit masks
#define BIT(b) (1<<(b))
#define TEST(n,b) (((n)&BIT(b))!=0)
#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
// Macros for maths shortcuts
#define M_PI 3.1415926536
#define RADIANS(d) ((d)*M_PI/180.0)
#define DEGREES(r) ((r)*180.0/M_PI)
#define SIN_60 0.8660254037844386
#define COS_60 0.5
// Macros to contrain values
#define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
#define NOMORE(v,n) do{ if (v > n) v = n; }while(0)
// Macros to support option testing
#define _CAT(a, ...) a ## __VA_ARGS__
#define SWITCH_ENABLED_0 0
#define SWITCH_ENABLED_1 1
#define SWITCH_ENABLED_ 1
#define ENABLED(b) _CAT(SWITCH_ENABLED_, b)
#define DISABLED(b) (!_CAT(SWITCH_ENABLED_, b))
// Macros for check PIN
#define PIN_EXISTS(PN) (defined(PN##_PIN) && PN##_PIN >= 0)
/**
* Shorthand for pin tests, used wherever needed
*/
#define HAS_TEMP_0 (PIN_EXISTS(TEMP_0) && TEMP_SENSOR_0 != 0 && TEMP_SENSOR_0 != -2)
#define HAS_TEMP_1 (PIN_EXISTS(TEMP_1) && TEMP_SENSOR_1 != 0)
#define HAS_TEMP_2 (PIN_EXISTS(TEMP_2) && TEMP_SENSOR_2 != 0)
#define HAS_TEMP_3 (PIN_EXISTS(TEMP_3) && TEMP_SENSOR_3 != 0)
#define HAS_TEMP_BED (PIN_EXISTS(TEMP_BED) && TEMP_SENSOR_BED != 0)
#define HAS_HEATER_0 (PIN_EXISTS(HEATER_0))
#define HAS_HEATER_1 (PIN_EXISTS(HEATER_1))
#define HAS_HEATER_2 (PIN_EXISTS(HEATER_2))
#define HAS_HEATER_3 (PIN_EXISTS(HEATER_3))
#define HAS_HEATER_BED (PIN_EXISTS(HEATER_BED))
#define HAS_AUTO_FAN_0 (PIN_EXISTS(EXTRUDER_0_AUTO_FAN))
#define HAS_AUTO_FAN_1 (PIN_EXISTS(EXTRUDER_1_AUTO_FAN))
#define HAS_AUTO_FAN_2 (PIN_EXISTS(EXTRUDER_2_AUTO_FAN))
#define HAS_AUTO_FAN_3 (PIN_EXISTS(EXTRUDER_3_AUTO_FAN))
#define HAS_AUTO_FAN (HAS_AUTO_FAN_0 || HAS_AUTO_FAN_1 || HAS_AUTO_FAN_2 || HAS_AUTO_FAN_3)
#define HAS_FAN (PIN_EXISTS(FAN))
#define HAS_CONTROLLERFAN (PIN_EXISTS(CONTROLLERFAN))
#define HAS_SERVO_0 (PIN_EXISTS(SERVO0))
#define HAS_SERVO_1 (PIN_EXISTS(SERVO1))
#define HAS_SERVO_2 (PIN_EXISTS(SERVO2))
#define HAS_SERVO_3 (PIN_EXISTS(SERVO3))
#define HAS_FILAMENT_SENSOR (ENABLED(FILAMENT_SENSOR) && PIN_EXISTS(FILWIDTH))
#define HAS_POWER_CONSUMPTION_SENSOR (ENABLED(POWER_CONSUMPTION) && PIN_EXISTS(POWER_CONSUMPTION))
#define HAS_FILRUNOUT (ENABLED(FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FILRUNOUT))
#define HAS_HOME (PIN_EXISTS(HOME))
#define HAS_KILL (PIN_EXISTS(KILL))
#define HAS_SUICIDE (PIN_EXISTS(SUICIDE))
#define HAS_PHOTOGRAPH (PIN_EXISTS(PHOTOGRAPH))
#define HAS_X_MIN (PIN_EXISTS(X_MIN))
#define HAS_X_MAX (PIN_EXISTS(X_MAX))
#define HAS_Y_MIN (PIN_EXISTS(Y_MIN))
#define HAS_Y_MAX (PIN_EXISTS(Y_MAX))
#define HAS_Z_MIN (PIN_EXISTS(Z_MIN))
#define HAS_Z_MAX (PIN_EXISTS(Z_MAX))
#define HAS_Z2_MIN (PIN_EXISTS(Z2_MIN))
#define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX))
#define HAS_Z_PROBE (PIN_EXISTS(Z_PROBE))
#define HAS_E_MIN (PIN_EXISTS(E_MIN))
#define HAS_SOLENOID_1 (PIN_EXISTS(SOL1))
#define HAS_SOLENOID_2 (PIN_EXISTS(SOL2))
#define HAS_SOLENOID_3 (PIN_EXISTS(SOL3))
#define HAS_MICROSTEPS (PIN_EXISTS(X_MS1))
#define HAS_MICROSTEPS_E0 (PIN_EXISTS(E0_MS1))
#define HAS_MICROSTEPS_E1 (PIN_EXISTS(E1_MS1))
#define HAS_MICROSTEPS_E2 (PIN_EXISTS(E2_MS1))
#define HAS_X_ENABLE (PIN_EXISTS(X_ENABLE))
#define HAS_X2_ENABLE (PIN_EXISTS(X2_ENABLE))
#define HAS_Y_ENABLE (PIN_EXISTS(Y_ENABLE))
#define HAS_Y2_ENABLE (PIN_EXISTS(Y2_ENABLE))
#define HAS_Z_ENABLE (PIN_EXISTS(Z_ENABLE))
#define HAS_Z2_ENABLE (PIN_EXISTS(Z2_ENABLE))
#define HAS_E0_ENABLE (PIN_EXISTS(E0_ENABLE))
#define HAS_E1_ENABLE (PIN_EXISTS(E1_ENABLE))
#define HAS_E2_ENABLE (PIN_EXISTS(E2_ENABLE))
#define HAS_E3_ENABLE (PIN_EXISTS(E3_ENABLE))
#define HAS_X_DIR (PIN_EXISTS(X_DIR))
#define HAS_X2_DIR (PIN_EXISTS(X2_DIR))
#define HAS_Y_DIR (PIN_EXISTS(Y_DIR))
#define HAS_Y2_DIR (PIN_EXISTS(Y2_DIR))
#define HAS_Z_DIR (PIN_EXISTS(Z_DIR))
#define HAS_Z2_DIR (PIN_EXISTS(Z2_DIR))
#define HAS_E0_DIR (PIN_EXISTS(E0_DIR))
#define HAS_E1_DIR (PIN_EXISTS(E1_DIR))
#define HAS_E2_DIR (PIN_EXISTS(E2_DIR))
#define HAS_E3_DIR (PIN_EXISTS(E3_DIR))
#define HAS_X_STEP (PIN_EXISTS(X_STEP))
#define HAS_X2_STEP (PIN_EXISTS(X2_STEP))
#define HAS_Y_STEP (PIN_EXISTS(Y_STEP))
#define HAS_Y2_STEP (PIN_EXISTS(Y2_STEP))
#define HAS_Z_STEP (PIN_EXISTS(Z_STEP))
#define HAS_Z2_STEP (PIN_EXISTS(Z2_STEP))
#define HAS_E0_STEP (PIN_EXISTS(E0_STEP))
#define HAS_E1_STEP (PIN_EXISTS(E1_STEP))
#define HAS_E2_STEP (PIN_EXISTS(E2_STEP))
#define HAS_E3_STEP (PIN_EXISTS(E3_STEP))
#define HAS_E0E1 (PIN_EXISTS(E0E1_CHOICE))
#define HAS_E0E2 (PIN_EXISTS(E0E2_CHOICE))
#define HAS_E0E3 (PIN_EXISTS(E0E3_CHOICE))
#define HAS_E0E4 (PIN_EXISTS(E0E4_CHOICE))
#define HAS_E1E3 (PIN_EXISTS(E1E3_CHOICE))
#define HAS_BTN_BACK (PIN_EXISTS(BTN_BACK))
/**
* Shorthand for filament sensor and power sensor for ultralcd.cpp, dogm_lcd_implementation.h, ultralcd_implementation_hitachi_HD44780.h
*/
#define HAS_LCD_FILAMENT_SENSOR (HAS_FILAMENT_SENSOR && defined(FILAMENT_LCD_DISPLAY))
#define HAS_LCD_POWER_SENSOR (HAS_POWER_CONSUMPTION_SENSOR && defined(POWER_CONSUMPTION_LCD_DISPLAY))
#endif //__MACROS_H
......@@ -4909,7 +4909,7 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a
********************************* END MOTHERBOARD ***************************************
/****************************************************************************************/
#if DISABLED(KNOWN_BOARD)
#ifndef KNOWN_BOARD
#error Unknown MOTHERBOARD value in configuration.h
#endif
......@@ -4980,35 +4980,35 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a
#define Z_MAX_PIN -1
#endif //Z_HOME_DIR > 0
#if DISABLED(Z_PROBE_ENDSTOP) // Allow code to compile regardless of Z_PROBE_ENDSTOP setting.
#ifndef Z_PROBE_ENDSTOP // Allow code to compile regardless of Z_PROBE_ENDSTOP setting.
#define Z_PROBE_PIN -1
#endif
#if ENABLED(DISABLE_XMAX_ENDSTOP)
#ifdef DISABLE_XMAX_ENDSTOP
#undef X_MAX_PIN
#define X_MAX_PIN -1
#endif
#if ENABLED(DISABLE_XMIN_ENDSTOP)
#ifdef DISABLE_XMIN_ENDSTOP
#undef X_MIN_PIN
#define X_MIN_PIN -1
#endif
#if ENABLED(DISABLE_YMAX_ENDSTOP)
#ifdef DISABLE_YMAX_ENDSTOP
#define Y_MAX_PIN -1
#endif
#if ENABLED(DISABLE_YMIN_ENDSTOP)
#ifdef DISABLE_YMIN_ENDSTOP
#undef Y_MIN_PIN
#define Y_MIN_PIN -1
#endif
#if ENABLED(DISABLE_ZMAX_ENDSTOP)
#ifdef DISABLE_ZMAX_ENDSTOP
#undef Z_MAX_PIN
#define Z_MAX_PIN -1
#endif
#if ENABLED(DISABLE_ZMIN_ENDSTOP)
#ifdef DISABLE_ZMIN_ENDSTOP
#undef Z_MIN_PIN
#define Z_MIN_PIN -1
#endif
......@@ -5049,7 +5049,7 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a
#define TEMP_3_PIN -1
#endif
#if ENABLED(MKR4)
#ifdef MKR4
#if (EXTRUDERS == 2) && (DRIVER_EXTRUDERS == 1) // Use this for one driver and two extruder
#define E0E1_CHOICE_PIN 5
#elif (EXTRUDERS == 3) && (DRIVER_EXTRUDERS == 1) // Use this for one driver and 3 extruder
......@@ -5067,20 +5067,20 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a
#endif //EXTRUDERS
#endif //MKR4
#if ENABLED(NPR2)
#ifdef NPR2
#define E_MIN_PIN -1
#endif //NPR2
#if ENABLED(LASERBEAM)
#ifdef LASERBEAM
#define LASER_PWR_PIN 41
#define LASER_TTL_PIN 42
#endif
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
#ifdef FILAMENT_RUNOUT_SENSOR
#define FILRUNOUT_PIN -1
#endif
#if ENABLED(FILAMENT_SENSOR)
#ifdef FILAMENT_SENSOR
// FMM added for Filament Extruder
//define analog pin for the filament width sensor input
//Use the RAMPS 1.4 Analog input 5 on the AUX2 connector
......
......@@ -73,7 +73,7 @@ float max_e_jerk;
float mintravelfeedrate;
unsigned long axis_steps_per_sqr_second[3 + EXTRUDERS];
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
// Transform required to compensate for bed level
matrix_3x3 plan_bed_level_matrix = {
1.0, 0.0, 0.0,
......@@ -82,7 +82,7 @@ unsigned long axis_steps_per_sqr_second[3 + EXTRUDERS];
};
#endif // ENABLE_AUTO_BED_LEVELING
#if ENABLED(AUTOTEMP)
#ifdef AUTOTEMP
float autotemp_max = 250;
float autotemp_min = 210;
float autotemp_factor = 0.1;
......@@ -117,7 +117,7 @@ unsigned char g_uc_extruder_last_move[4] = {0,0,0,0};
static long axis_segment_time[2][3] = { {MAX_FREQ_TIME+1,0,0}, {MAX_FREQ_TIME+1,0,0} };
#endif
#if ENABLED(FILAMENT_SENSOR)
#ifdef FILAMENT_SENSOR
static char meas_sample; //temporary variable to hold filament measurement sample
#endif
......@@ -174,7 +174,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
plateau_steps = 0;
}
#if ENABLED(ADVANCE)
#ifdef ADVANCE
volatile long initial_advance = block->advance * entry_factor * entry_factor;
volatile long final_advance = block->advance * exit_factor * exit_factor;
#endif // ADVANCE
......@@ -187,7 +187,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
block->decelerate_after = accelerate_steps+plateau_steps;
block->initial_rate = initial_rate;
block->final_rate = final_rate;
#if ENABLED(ADVANCE)
#ifdef ADVANCE
block->initial_advance = initial_advance;
block->final_advance = final_advance;
#endif
......@@ -357,7 +357,7 @@ void plan_init() {
}
#if ENABLED(AUTOTEMP)
#ifdef AUTOTEMP
void getHighESpeed() {
static float oldt = 0;
......@@ -390,11 +390,11 @@ void plan_init() {
void check_axes_activity() {
unsigned char axis_active[NUM_AXIS] = { 0 },
tail_fan_speed = fanSpeed;
#if ENABLED(BARICUDA)
#ifdef BARICUDA
unsigned char tail_valve_pressure = ValvePressure,
tail_e_to_p_pressure = EtoPPressure;
#endif
#if ENABLED(LASERBEAM)
#ifdef LASERBEAM
unsigned char tail_laser_ttl_modulation = laser_ttl_modulation;
#endif
block_t *block;
......@@ -402,14 +402,15 @@ void check_axes_activity() {
if (blocks_queued()) {
uint8_t block_index = block_buffer_tail;
tail_fan_speed = block_buffer[block_index].fan_speed;
#if ENABLED(BARICUDA)
#ifdef BARICUDA
block = &block_buffer[block_index];
tail_valve_pressure = block->valve_pressure;
tail_e_to_p_pressure = block->e_to_p_pressure;
#endif
#if ENABLED(LASERBEAM)
#ifdef LASERBEAM
tail_laser_ttl_modulation = block_buffer[block_index].laser_ttlmodulation;
#endif
while (block_index != block_buffer_head) {
block = &block_buffer[block_index];
for (int i=0; i<NUM_AXIS; i++) if (block->steps[i]) axis_active[i]++;
......@@ -442,18 +443,18 @@ void check_axes_activity() {
fan_kick_end = 0;
}
#endif//FAN_KICKSTART_TIME
#if ENABLED(FAN_SOFT_PWM)
#ifdef FAN_SOFT_PWM
fanSpeedSoftPwm = tail_fan_speed;
#else
analogWrite(FAN_PIN, tail_fan_speed);
#endif //!FAN_SOFT_PWM
#endif // HAS_FAN
#if ENABLED(AUTOTEMP)
#ifdef AUTOTEMP
getHighESpeed();
#endif
#if ENABLED(BARICUDA)
#ifdef BARICUDA
#if HAS_HEATER_1
analogWrite(HEATER_1_PIN,tail_valve_pressure);
#endif
......@@ -462,7 +463,8 @@ void check_axes_activity() {
#endif
#endif
#if ENABLED(LASERBEAM)
// add Laser TTL Modulation(PWM) Control
#ifdef LASERBEAM
analogWrite(LASER_TTL_PIN, tail_laser_ttl_modulation);
#endif
}
......@@ -472,7 +474,7 @@ float junction_deviation = 0.1;
// Add a new linear movement to the buffer. steps[X_AXIS], _y and _z is the absolute position in
// mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
// calculation the caller must also provide the physical length of the line in millimeters.
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver)
#else
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver)
......@@ -485,7 +487,7 @@ float junction_deviation = 0.1;
// Rest here until there is room in the buffer.
while (block_buffer_tail == next_buffer_head) idle();
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
#endif
......@@ -503,9 +505,9 @@ float junction_deviation = 0.1;
dz = target[Z_AXIS] - position[Z_AXIS],
de = target[E_AXIS] - position[E_AXIS];
#if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
#ifdef PREVENT_DANGEROUS_EXTRUDE
if (de) {
#if ENABLED(NPR2)
#ifdef NPR2
if (extruder != 1)
#endif
{
......@@ -516,7 +518,7 @@ float junction_deviation = 0.1;
}
}
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
#ifdef PREVENT_LENGTHY_EXTRUDE
if (labs(de) > axis_steps_per_unit[E_AXIS + extruder] * EXTRUDE_MAXLENGTH) {
#ifdef EASY_LOAD
if (!allow_lengthy_extrude_once) {
......@@ -524,7 +526,7 @@ float junction_deviation = 0.1;
position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
de = 0; // no difference
ECHO_LM(ER, MSG_ERR_LONG_EXTRUDE_STOP);
#if ENABLED(EASY_LOAD)
#ifdef EASY_LOAD
}
allow_lengthy_extrude_once = false;
#endif
......@@ -540,7 +542,7 @@ float junction_deviation = 0.1;
block->busy = false;
// Number of steps for each axis
#if ENABLED(COREXY)
#ifdef COREXY
// corexy planning
// these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html
block->steps[A_AXIS] = labs(dx + dy);
......@@ -562,17 +564,19 @@ float junction_deviation = 0.1;
if (block->step_event_count <= dropsegments) return;
block->fan_speed = fanSpeed;
#if ENABLED(BARICUDA)
#ifdef BARICUDA
block->valve_pressure = ValvePressure;
block->e_to_p_pressure = EtoPPressure;
#endif
#if ENABLED(LASERBEAM)
// Add update block variables for LASER BEAM control
#ifdef LASERBEAM
block->laser_ttlmodulation = laser_ttl_modulation;
#endif
// Compute direction bits for this block
uint8_t db = 0;
#if ENABLED(COREXY)
#ifdef COREXY
if (dx < 0) db |= BIT(X_HEAD); // Save the real Extruder (head) direction in X Axis
if (dy < 0) db |= BIT(Y_HEAD); // ...and Y
if (dx + dy < 0) db |= BIT(A_AXIS); // Motor A direction
......@@ -588,7 +592,7 @@ float junction_deviation = 0.1;
block->active_driver = driver;
//enable active axes
#if ENABLED(COREXY)
#ifdef COREXY
if (block->steps[A_AXIS] || block->steps[B_AXIS]) {
enable_x();
enable_y();
......@@ -598,13 +602,13 @@ float junction_deviation = 0.1;
if (block->steps[Y_AXIS]) enable_y();
#endif
#if DISABLED(Z_LATE_ENABLE)
#ifndef Z_LATE_ENABLE
if (block->steps[Z_AXIS]) enable_z();
#endif
// Enable extruder(s)
if (block->steps[E_AXIS]) {
#if DISABLED(MKR4) && DISABLED(NPR2)
#if !defined(MKR4) && !defined(NPR2)
if (DISABLE_INACTIVE_EXTRUDER) { //enable only selected extruder
for (int i=0; i<EXTRUDERS; i++)
......@@ -627,7 +631,7 @@ float junction_deviation = 0.1;
#if EXTRUDERS > 1
case 1:
enable_e1();
g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE * 2;
g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2;
if (g_uc_extruder_last_move[0] == 0) disable_e0();
#if EXTRUDERS > 2
if (g_uc_extruder_last_move[2] == 0) disable_e2();
......@@ -639,7 +643,7 @@ float junction_deviation = 0.1;
#if EXTRUDERS > 2
case 2:
enable_e2();
g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE * 2;
g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2;
if (g_uc_extruder_last_move[0] == 0) disable_e0();
if (g_uc_extruder_last_move[1] == 0) disable_e1();
#if EXTRUDERS > 3
......@@ -649,7 +653,7 @@ float junction_deviation = 0.1;
#if EXTRUDERS > 3
case 3:
enable_e3();
g_uc_extruder_last_move[3] = BLOCK_BUFFER_SIZE * 2;
g_uc_extruder_last_move[3] = BLOCK_BUFFER_SIZE*2;
if (g_uc_extruder_last_move[0] == 0) disable_e0();
if (g_uc_extruder_last_move[1] == 0) disable_e1();
if (g_uc_extruder_last_move[2] == 0) disable_e2();
......@@ -698,7 +702,7 @@ float junction_deviation = 0.1;
* So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head.
* Having the real displacement of the head, we can calculate the total movement length and apply the desired speed.
*/
#if ENABLED(COREXY)
#ifdef COREXY
float delta_mm[6];
delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
delta_mm[Y_HEAD] = dy / axis_steps_per_unit[B_AXIS];
......@@ -717,7 +721,7 @@ float junction_deviation = 0.1;
}
else {
block->millimeters = sqrt(
#if ENABLED(COREXY)
#ifdef COREXY
square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD])
#else
square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS])
......@@ -733,12 +737,12 @@ float junction_deviation = 0.1;
int moves_queued = movesplanned();
// Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill
#if ENABLED(OLD_SLOWDOWN) || ENABLED(SLOWDOWN)
#if defined(OLD_SLOWDOWN) || defined(SLOWDOWN)
bool mq = moves_queued > 1 && moves_queued < BLOCK_BUFFER_SIZE / 2;
#if ENABLED(OLD_SLOWDOWN)
#ifdef OLD_SLOWDOWN
if (mq) feed_rate *= 2.0 * moves_queued / BLOCK_BUFFER_SIZE;
#endif
#if ENABLED(SLOWDOWN)
#ifdef SLOWDOWN
// segment time im micro seconds
unsigned long segment_time = lround(1000000.0/inverse_second);
if (mq) {
......@@ -756,7 +760,7 @@ float junction_deviation = 0.1;
block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
#if ENABLED(FILAMENT_SENSOR)
#ifdef FILAMENT_SENSOR
//FMM update ring buffer used for delay with filament measurements
if (extruder == FILAMENT_SENSOR_EXTRUDER_NUM && delay_index2 > -1) { //only for extruder with filament sensor and if ring buffer is initialized
......@@ -957,7 +961,7 @@ float junction_deviation = 0.1;
for (int i = 0; i < NUM_AXIS; i++) previous_speed[i] = current_speed[i];
previous_nominal_speed = block->nominal_speed;
#if ENABLED(ADVANCE)
#ifdef ADVANCE
// Calculate advance rate
if (!bse || (!bsx && !bsy && !bsz)) {
block->advance_rate = 0;
......@@ -989,7 +993,7 @@ float junction_deviation = 0.1;
} // plan_buffer_line()
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
vector_3 plan_get_position() {
vector_3 position = vector_3(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS), st_get_position_mm(Z_AXIS));
......@@ -1004,13 +1008,13 @@ float junction_deviation = 0.1;
}
#endif // ENABLE_AUTO_BED_LEVELING
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
void plan_set_position(float x, float y, float z, const float &e)
#else
void plan_set_position(const float &x, const float &y, const float &z, const float &e)
#endif // ENABLE_AUTO_BED_LEVELING
{
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
#endif
......
......@@ -37,7 +37,7 @@ typedef struct {
long acceleration_rate; // The acceleration rate used for acceleration calculation
unsigned char direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
unsigned char active_driver; // Selects the active driver
#if ENABLED(ADVANCE)
#ifdef ADVANCE
long advance_rate;
volatile long initial_advance;
volatile long final_advance;
......@@ -60,11 +60,11 @@ typedef struct {
unsigned long final_rate; // The minimal rate at exit
unsigned long acceleration_st; // acceleration steps/sec^2
unsigned long fan_speed;
#if ENABLED(BARICUDA)
#ifdef BARICUDA
unsigned long valve_pressure;
unsigned long e_to_p_pressure;
#endif
#if ENABLED(LASERBEAM)
#ifdef LASERBEAM
unsigned long laser_ttlmodulation;
#endif
volatile char busy;
......@@ -82,7 +82,7 @@ extern volatile unsigned char block_buffer_head;
extern volatile unsigned char block_buffer_tail;
FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block_buffer_tail + BLOCK_BUFFER_SIZE); }
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
#include "vector_3.h"
......@@ -132,7 +132,7 @@ extern float max_e_jerk;
extern float mintravelfeedrate;
extern unsigned long axis_steps_per_sqr_second[3 + EXTRUDERS];
#if ENABLED(AUTOTEMP)
#ifdef AUTOTEMP
extern bool autotemp_enabled;
extern float autotemp_max;
extern float autotemp_min;
......
#include "qr_solve.h"
#if ENABLED(AUTO_BED_LEVELING_GRID)
#ifdef AUTO_BED_LEVELING_GRID
#include <stdlib.h>
#include <math.h>
......
#include "Configuration.h"
#if ENABLED(AUTO_BED_LEVELING_GRID)
#ifdef AUTO_BED_LEVELING_GRID
void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy );
double ddot ( int n, double dx[], int incx, double dy[], int incy );
......
......@@ -9,24 +9,24 @@
/**
* Dual Stepper Drivers
*/
#if ENABLED(Z_DUAL_STEPPER_DRIVERS) && ENABLED(Y_DUAL_STEPPER_DRIVERS)
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Y_DUAL_STEPPER_DRIVERS)
#error You cannot have dual stepper drivers for both Y and Z.
#endif
/**
* Progress Bar
*/
#if ENABLED(LCD_PROGRESS_BAR)
#if DISABLED(SDSUPPORT)
#ifdef LCD_PROGRESS_BAR
#ifndef SDSUPPORT
#error LCD_PROGRESS_BAR requires SDSUPPORT.
#endif
#if ENABLED(DOGLCD)
#ifdef DOGLCD
#error LCD_PROGRESS_BAR does not apply to graphical displays.
#endif
#if ENABLED(FILAMENT_LCD_DISPLAY)
#ifdef FILAMENT_LCD_DISPLAY
#error LCD_PROGRESS_BAR and FILAMENT_LCD_DISPLAY are not fully compatible. Comment out this line to use both.
#endif
#if ENABLED(POWER_CONSUMPTION_LCD_DISPLAY)
#ifdef POWER_CONSUMPTION_LCD_DISPLAY
#error LCD_PROGRESS_BAR and POWER_CONSUMPTION_LCD_DISPLAY are not fully compatible. Comment out this line to use both.
#endif
#endif
......@@ -34,14 +34,14 @@
/**
* Babystepping
*/
#if ENABLED(BABYSTEPPING)
#if ENABLED(COREXY)
#ifdef BABYSTEPPING
#ifdef COREXY
#error BABYSTEPPING not implemented for COREXY yet.
#endif
#if ENABLED(SCARA)
#ifdef SCARA
#error BABYSTEPPING is not implemented for SCARA yet.
#endif
#if ENABLED(DELTA) && ENABLED(BABYSTEP_XY)
#if defined(DELTA) && defined(BABYSTEP_XY)
#error BABYSTEPPING only implemented for Z axis on deltabots.
#endif
#endif
......@@ -49,28 +49,28 @@
/**
* Filament Change with Extruder Runout Prevention
*/
#if ENABLED(FILAMENTCHANGEENABLE) && ENABLED(EXTRUDER_RUNOUT_PREVENT)
#if defined(FILAMENTCHANGEENABLE) && defined(EXTRUDER_RUNOUT_PREVENT)
#error EXTRUDER_RUNOUT_PREVENT currently incompatible with FILAMENTCHANGE.
#endif
/**
* Extruder Runout Prevention
*/
#if ENABLED(EXTRUDER_RUNOUT_PREVENT) && EXTRUDER_RUNOUT_MINTEMP < EXTRUDE_MINTEMP
#if defined(EXTRUDER_RUNOUT_PREVENT) && EXTRUDER_RUNOUT_MINTEMP < EXTRUDE_MINTEMP
#error EXTRUDER_RUNOUT_MINTEMP have to be greater than EXTRUDE_MINTEMP
#endif
/**
* Idle oozing prevent with Extruder Runout Prevention
*/
#if ENABLED(EXTRUDER_RUNOUT_PREVENT) && defined(IDLE_OOZING_PREVENT)
#if defined(EXTRUDER_RUNOUT_PREVENT) && defined(IDLE_OOZING_PREVENT)
#error EXTRUDER_RUNOUT_PREVENT and IDLE_OOZING_PREVENT are incopatible. Please comment one of them.
#endif
/**
* Idle oozing prevent
*/
#if ENABLED(IDLE_OOZING_PREVENT) && IDLE_OOZING_MINTEMP < EXTRUDE_MINTEMP
#if defined(IDLE_OOZING_PREVENT) && IDLE_OOZING_MINTEMP < EXTRUDE_MINTEMP
#error IDLE_OOZING_MINTEMP have to be greater than EXTRUDE_MINTEMP
#endif
......@@ -83,19 +83,19 @@
#error The maximum number of EXTRUDERS is 4.
#endif
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
#error EXTRUDERS must be 1 with TEMP_SENSOR_1_AS_REDUNDANT.
#endif
#if ENABLED(HEATERS_PARALLEL)
#ifdef HEATERS_PARALLEL
#error EXTRUDERS must be 1 with HEATERS_PARALLEL.
#endif
#if ENABLED(Y_DUAL_STEPPER_DRIVERS)
#ifdef Y_DUAL_STEPPER_DRIVERS
#error EXTRUDERS must be 1 with Y_DUAL_STEPPER_DRIVERS.
#endif
#if ENABLED(Z_DUAL_STEPPER_DRIVERS)
#ifdef Z_DUAL_STEPPER_DRIVERS
#error EXTRUDERS must be 1 with Z_DUAL_STEPPER_DRIVERS.
#endif
......@@ -111,21 +111,21 @@
/**
* Required LCD language
*/
#if DISABLED(DOGLCD) && ENABLED(ULTRA_LCD) && DISABLED(DISPLAY_CHARSET_HD44780_JAPAN) && DISABLED(DISPLAY_CHARSET_HD44780_WESTERN) && DISABLED(DISPLAY_CHARSET_HD44780_CYRILLIC)
#if !defined(DOGLCD) && defined(ULTRA_LCD) && !defined(DISPLAY_CHARSET_HD44780_JAPAN) && !defined(DISPLAY_CHARSET_HD44780_WESTERN)&& !defined(DISPLAY_CHARSET_HD44780_CYRILLIC)
#error You must enable either DISPLAY_CHARSET_HD44780_JAPAN or DISPLAY_CHARSET_HD44780_WESTERN or DISPLAY_CHARSET_HD44780_CYRILLIC for your LCD controller.
#endif
/**
* Auto Bed Leveling
*/
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
/**
* Require a Z Min pin
*/
#if Z_MIN_PIN == -1
#if Z_PROBE_PIN == -1 || (DISABLED(Z_PROBE_ENDSTOP) // It's possible for someone to set a pin for the Z Probe, but not enable it.
#if ENABLED(Z_PROBE_REPEATABILITY_TEST)
#if Z_PROBE_PIN == -1 || defined(Z_PROBE_ENDSTOP) // It's possible for someone to set a pin for the Z Probe, but not enable it.
#ifdef Z_PROBE_REPEATABILITY_TEST
#error You must have a Z_MIN or Z_PROBE endstop to enable Z_PROBE_REPEATABILITY_TEST.
#else
#error ENABLE_AUTO_BED_LEVELING requires a Z_MIN or Z_PROBE endstop. Z_MIN_PIN or Z_PROBE_PIN must point to a valid hardware pin.
......@@ -136,7 +136,7 @@
/**
* Require a Z Probe Pin if Z_PROBE_ENDSTOP is enabled.
*/
#if ENABLED(Z_PROBE_ENDSTOP)
#if defined(Z_PROBE_ENDSTOP)
#ifndef Z_PROBE_PIN
#error You must have a Z_PROBE_PIN defined in your pins_XXXX.h file if you enable Z_PROBE_ENDSTOP
#endif
......@@ -160,7 +160,7 @@
/**
* Check if Probe_Offset * Grid Points is greater than Probing Range
*/
#if ENABLED(AUTO_BED_LEVELING_GRID)
#ifdef AUTO_BED_LEVELING_GRID
// Make sure probing points are reachable
#if LEFT_PROBE_BED_POSITION < MIN_PROBE_X
......@@ -227,14 +227,14 @@
/**
* ULTIPANEL encoder
*/
#if ENABLED(ULTIPANEL) && DISABLED(NEWPANEL) && DISABLED(SR_LCD_2W_NL) && DISABLED(SHIFT_CLK)
#if defined(ULTIPANEL) && !defined(NEWPANEL) && !defined(SR_LCD_2W_NL) && !defined(SHIFT_CLK)
#error ULTIPANEL requires some kind of encoder.
#endif
/**
* Delta & Z_PROBE_ENDSTOP
*/
#if ENABLED(DELTA) && ENABLED(Z_PROBE_ENDSTOP)
#if defined(DELTA) && defined(Z_PROBE_ENDSTOP)
#ifndef Z_PROBE_PIN
#error You must have a Z_PROBE_PIN defined in your pins2tool.h file if you enable Z_PROBE_ENDSTOP
#endif
......@@ -246,8 +246,8 @@
/**
* Dual X Carriage requirements
*/
#if ENABLED(DUAL_X_CARRIAGE)
#if EXTRUDERS == 1 || ENABLED(COREXY) \
#ifdef DUAL_X_CARRIAGE
#if EXTRUDERS == 1 || defined(COREXY) \
|| !HAS_X2_ENABLE || !HAS_X2_STEP || !HAS_X2_DIR \
|| !defined(X2_HOME_POS) || !defined(X2_MIN_POS) || !defined(X2_MAX_POS) \
|| !HAS_X_MAX
......@@ -288,7 +288,7 @@
#if !HAS_HEATER_2
#error HEATER_2_PIN not defined for this board
#endif
#elif HOTENDS > 1 || ENABLED(HEATERS_PARALLEL)
#elif HOTENDS > 1 || defined(HEATERS_PARALLEL)
#if !HAS_HEATER_1
#error HEATER_1_PIN not defined for this board
#endif
......@@ -308,11 +308,11 @@
#error WATCH_TEMP_PERIOD now uses seconds instead of milliseconds
#endif
#if DISABLED(THERMAL_PROTECTION_HOTENDS) && (ENABLED(WATCH_TEMP_PERIOD) || defined(THERMAL_PROTECTION_PERIOD))
#if !defined(THERMAL_PROTECTION_HOTENDS) && (defined(WATCH_TEMP_PERIOD) || defined(THERMAL_PROTECTION_PERIOD))
#error Thermal Runaway Protection for hotends must now be enabled with THERMAL_PROTECTION_HOTENDS
#endif
#if DISABLED(THERMAL_PROTECTION_BED) && ENABLED(THERMAL_PROTECTION_BED_PERIOD)
#if !defined(THERMAL_PROTECTION_BED) && defined(THERMAL_PROTECTION_BED_PERIOD)
#error Thermal Runaway Protection for the bed must now be enabled with THERMAL_PROTECTION_BED
#endif
......
......@@ -49,7 +49,7 @@ block_t *current_block; // A pointer to the block currently being traced
static unsigned char out_bits = 0; // The next stepping-bits to be output
static unsigned int cleaning_buffer_counter;
#if ENABLED(Z_DUAL_ENDSTOPS)
#ifdef Z_DUAL_ENDSTOPS
static bool performing_homing = false,
locked_z_motor = false,
locked_z2_motor = false;
......@@ -59,7 +59,7 @@ static unsigned int cleaning_buffer_counter;
static long counter_x, counter_y, counter_z, counter_e;
volatile static unsigned long step_events_completed; // The number of step events executed in the current block
#if ENABLED(ADVANCE)
#ifdef ADVANCE
static long advance_rate, advance, final_advance = 0;
static long old_advance = 0;
static long e_steps[4];
......@@ -76,13 +76,13 @@ volatile long endstops_trigsteps[3] = { 0 };
volatile long endstops_stepsTotal, endstops_stepsDone;
static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_PROBE as BIT value
#if DISABLED(Z_DUAL_ENDSTOPS)
#ifndef Z_DUAL_ENDSTOPS
static byte old_endstop_bits = 0; // use X_MIN, X_MAX... Z_MAX, Z_PROBE, Z2_MIN, Z2_MAX
#else
static uint16_t old_endstop_bits = 0; // use X_MIN, X_MAX... Z_MAX, Z_PROBE, Z2_MIN, Z2_MAX
#endif
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
bool abort_on_endstop_hit = false;
#endif
......@@ -100,7 +100,7 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
//================================ functions ================================
//===========================================================================
#if ENABLED(DUAL_X_CARRIAGE)
#ifdef DUAL_X_CARRIAGE
#define X_APPLY_DIR(v,ALWAYS) \
if (extruder_duplication_enabled || ALWAYS) { \
X_DIR_WRITE(v); \
......@@ -122,7 +122,7 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
#define X_APPLY_STEP(v,Q) X_STEP_WRITE(v)
#endif
#if ENABLED(Y_DUAL_STEPPER_DRIVERS)
#ifdef Y_DUAL_STEPPER_DRIVERS
#define Y_APPLY_DIR(v,Q) { Y_DIR_WRITE(v); Y2_DIR_WRITE((v) != INVERT_Y2_VS_Y_DIR); }
#define Y_APPLY_STEP(v,Q) { Y_STEP_WRITE(v); Y2_STEP_WRITE(v); }
#else
......@@ -130,9 +130,9 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
#define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v)
#endif
#if ENABLED(Z_DUAL_STEPPER_DRIVERS)
#ifdef Z_DUAL_STEPPER_DRIVERS
#define Z_APPLY_DIR(v,Q) { Z_DIR_WRITE(v); Z2_DIR_WRITE(v); }
#if ENABLED(Z_DUAL_ENDSTOPS)
#ifdef Z_DUAL_ENDSTOPS
#define Z_APPLY_STEP(v,Q) \
if (performing_homing) { \
if (Z_HOME_DIR > 0) {\
......@@ -261,13 +261,13 @@ void checkHitEndstops() {
ECHO_MV(MSG_ENDSTOP_Z, (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZS);
}
#if ENABLED(Z_PROBE_ENDSTOP)
#ifdef Z_PROBE_ENDSTOP
if (endstop_hit_bits & BIT(Z_PROBE)) {
ECHO_MV(MSG_ENDSTOP_ZPS, (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZPS);
}
#endif
#if ENABLED(NPR2)
#ifdef NPR2
if (endstop_hit_bits & BIT(E_MIN)) {
ECHO_MV(MSG_ENDSTOP_E, (float)endstops_trigsteps[E_AXIS] / axis_steps_per_unit[E_AXIS]);
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ES);
......@@ -277,7 +277,7 @@ void checkHitEndstops() {
endstops_hit_on_purpose();
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && ENABLED(SDSUPPORT)
#if defined(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && defined(SDSUPPORT)
if (abort_on_endstop_hit) {
card.sdprinting = false;
card.closeFile();
......@@ -377,7 +377,7 @@ void set_stepper_direction() {
count_direction[Z_AXIS] = 1;
}
#if DISABLED(ADVANCE)
#ifndef ADVANCE
if (TEST(out_bits, E_AXIS)) {
REV_E_DIR();
count_direction[E_AXIS] = -1;
......@@ -398,7 +398,7 @@ FORCE_INLINE void trapezoid_generator_reset() {
set_stepper_direction();
}
#if ENABLED(ADVANCE)
#ifdef ADVANCE
advance = current_block->initial_advance;
final_advance = current_block->final_advance;
// Do E steps + advance steps
......@@ -441,7 +441,7 @@ ISR(TIMER1_COMPA_vect) {
counter_y = counter_z = counter_e = counter_x;
step_events_completed = 0;
#if ENABLED(Z_LATE_ENABLE)
#ifdef Z_LATE_ENABLE
if (current_block->steps[Z_AXIS] > 0) {
enable_z();
OCR1A = 2000; //1ms wait
......@@ -449,8 +449,8 @@ ISR(TIMER1_COMPA_vect) {
}
#endif
// #if ENABLED(ADVANCE)
// e_steps[current_block->active_driver] = 0;
// #ifdef ADVANCE
// e_steps[current_block->active_extruder] = 0;
// #endif
}
else {
......@@ -463,7 +463,7 @@ ISR(TIMER1_COMPA_vect) {
// Check endstops
if (check_endstops) {
#if ENABLED(Z_DUAL_ENDSTOPS)
#ifdef Z_DUAL_ENDSTOPS
uint16_t current_endstop_bits = 0;
#else
byte current_endstop_bits = 0;
......@@ -490,7 +490,7 @@ ISR(TIMER1_COMPA_vect) {
step_events_completed = current_block->step_event_count; \
}
#if ENABLED(COREXY)
#ifdef COREXY
// Head direction in -X axis for CoreXY bots.
// If DeltaX == -DeltaY, the movement is only in Y axis
if ((current_block->steps[A_AXIS] != current_block->steps[B_AXIS]) || (TEST(out_bits, A_AXIS) == TEST(out_bits, B_AXIS))) {
......@@ -499,7 +499,7 @@ ISR(TIMER1_COMPA_vect) {
if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular Cartesian bot)
#endif
{ // -direction
#if ENABLED(DUAL_X_CARRIAGE)
#ifdef DUAL_X_CARRIAGE
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
if ((current_block->active_driver == 0 && X_HOME_DIR == -1) || (current_block->active_driver != 0 && X2_HOME_DIR == -1))
#endif
......@@ -510,7 +510,7 @@ ISR(TIMER1_COMPA_vect) {
}
}
else { // +direction
#if ENABLED(DUAL_X_CARRIAGE)
#ifdef DUAL_X_CARRIAGE
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
if ((current_block->active_driver == 0 && X_HOME_DIR == 1) || (current_block->active_driver != 0 && X2_HOME_DIR == 1))
#endif
......@@ -520,7 +520,7 @@ ISR(TIMER1_COMPA_vect) {
#endif
}
}
#if ENABLED(COREXY)
#ifdef COREXY
}
// Head direction in -Y axis for CoreXY bots.
// If DeltaX == DeltaY, the movement is only in X axis
......@@ -539,13 +539,13 @@ ISR(TIMER1_COMPA_vect) {
UPDATE_ENDSTOP(Y, MAX);
#endif
}
#if ENABLED(COREXY)
#ifdef COREXY
}
#endif
if (TEST(out_bits, Z_AXIS)) { // z -direction
#if HAS_Z_MIN
#if ENABLED(Z_DUAL_ENDSTOPS)
#ifdef Z_DUAL_ENDSTOPS
SET_ENDSTOP_BIT(Z, MIN);
#if HAS_Z2_MIN
SET_ENDSTOP_BIT(Z2, MIN);
......@@ -567,7 +567,7 @@ ISR(TIMER1_COMPA_vect) {
#endif // !Z_DUAL_ENDSTOPS
#endif // Z_MIN_PIN
#if ENABLED(Z_PROBE_ENDSTOP)
#ifdef Z_PROBE_ENDSTOP
UPDATE_ENDSTOP(Z, PROBE);
SET_ENDSTOP_BIT(Z, PROBE);
......@@ -580,7 +580,7 @@ ISR(TIMER1_COMPA_vect) {
else { // z +direction
#if HAS_Z_MAX
#if ENABLED(Z_DUAL_ENDSTOPS)
#ifdef Z_DUAL_ENDSTOPS
SET_ENDSTOP_BIT(Z, MAX);
#if HAS_Z2_MAX
......@@ -616,7 +616,7 @@ ISR(TIMER1_COMPA_vect) {
MSerial.checkRx(); // Check for serial chars.
#endif
#if ENABLED(ADVANCE)
#ifdef ADVANCE
counter_e += current_block->steps[E_AXIS];
if (counter_e > 0) {
counter_e -= current_block->step_event_count;
......@@ -639,7 +639,7 @@ ISR(TIMER1_COMPA_vect) {
STEP_START(e,E);
#endif
#if ENABLED(STEPPER_HIGH_LOW_DELAY)
#ifdef STEPPER_HIGH_LOW_DELAY
delayMicroseconds(STEPPER_HIGH_LOW_DELAY);
#endif
......@@ -676,7 +676,7 @@ ISR(TIMER1_COMPA_vect) {
timer = calc_timer(acc_step_rate);
OCR1A = timer;
acceleration_time += timer;
#if ENABLED(ADVANCE)
#ifdef ADVANCE
for(int8_t i=0; i < step_loops; i++) {
advance += advance_rate;
}
......@@ -705,7 +705,7 @@ ISR(TIMER1_COMPA_vect) {
timer = calc_timer(step_rate);
OCR1A = timer;
deceleration_time += timer;
#if ENABLED(ADVANCE)
#ifdef ADVANCE
for(int8_t i=0; i < step_loops; i++) {
advance -= advance_rate;
}
......@@ -729,7 +729,7 @@ ISR(TIMER1_COMPA_vect) {
}
}
#if ENABLED(ADVANCE)
#ifdef ADVANCE
unsigned char old_OCR0A;
// Timer interrupt for E. e_steps is set in the main routine;
// Timer 0 is shared with millies
......@@ -807,11 +807,11 @@ void st_init() {
microstep_init(); //Initialize Microstepping Pins
// initialise TMC Steppers
#if ENABLED(HAVE_TMCDRIVER)
#ifdef HAVE_TMCDRIVER
tmc_init();
#endif
// initialise L6470 Steppers
#if ENABLED(HAVE_L6470DRIVER)
#ifdef HAVE_L6470DRIVER
L6470_init();
#endif
......@@ -824,13 +824,13 @@ void st_init() {
#endif
#if HAS_Y_DIR
Y_DIR_INIT;
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_DIR
#if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_DIR
Y2_DIR_INIT;
#endif
#endif
#if HAS_Z_DIR
Z_DIR_INIT;
#if ENABLED(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_DIR
#if defined(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_DIR
Z2_DIR_INIT;
#endif
#endif
......@@ -861,7 +861,7 @@ void st_init() {
Y_ENABLE_INIT;
if (!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH);
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_ENABLE
#if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_ENABLE
Y2_ENABLE_INIT;
if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH);
#endif
......@@ -870,7 +870,7 @@ void st_init() {
Z_ENABLE_INIT;
if (!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH);
#if ENABLED(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_ENABLE
#if defined(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_ENABLE
Z2_ENABLE_INIT;
if (!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH);
#endif
......@@ -910,63 +910,63 @@ void st_init() {
#if HAS_X_MIN
SET_INPUT(X_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_XMIN)
#ifdef ENDSTOPPULLUP_XMIN
WRITE(X_MIN_PIN,HIGH);
#endif
#endif
#if HAS_Y_MIN
SET_INPUT(Y_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_YMIN)
#ifdef ENDSTOPPULLUP_YMIN
WRITE(Y_MIN_PIN,HIGH);
#endif
#endif
#if HAS_Z_MIN
SET_INPUT(Z_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_ZMIN)
#ifdef ENDSTOPPULLUP_ZMIN
WRITE(Z_MIN_PIN,HIGH);
#endif
#endif
#if HAS_E_MIN
SET_INPUT(E_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_EMIN)
#ifdef ENDSTOPPULLUP_EMIN
WRITE(E_MIN_PIN, HIGH);
#endif
#endif
#if HAS_X_MAX
SET_INPUT(X_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_XMAX)
#ifdef ENDSTOPPULLUP_XMAX
WRITE(X_MAX_PIN,HIGH);
#endif
#endif
#if HAS_Y_MAX
SET_INPUT(Y_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_YMAX)
#ifdef ENDSTOPPULLUP_YMAX
WRITE(Y_MAX_PIN,HIGH);
#endif
#endif
#if HAS_Z_MAX
SET_INPUT(Z_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_ZMAX)
#ifdef ENDSTOPPULLUP_ZMAX
WRITE(Z_MAX_PIN,HIGH);
#endif
#endif
#if HAS_Z2_MAX
SET_INPUT(Z2_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_ZMAX)
#ifdef ENDSTOPPULLUP_ZMAX
WRITE(Z2_MAX_PIN,HIGH);
#endif
#endif
#if HAS_Z_PROBE && ENABLED(Z_PROBE_ENDSTOP) // Check for Z_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used.
#if HAS_Z_PROBE && defined(Z_PROBE_ENDSTOP) // Check for Z_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used.
SET_INPUT(Z_PROBE_PIN);
#if ENABLED(ENDSTOPPULLUP_ZPROBE)
#ifdef ENDSTOPPULLUP_ZPROBE
WRITE(Z_PROBE_PIN,HIGH);
#endif
#endif
......@@ -990,14 +990,14 @@ void st_init() {
AXIS_INIT(x, X2, X);
#endif
#if HAS_Y_STEP
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_STEP
#if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_STEP
Y2_STEP_INIT;
Y2_STEP_WRITE(INVERT_Y_STEP_PIN);
#endif
AXIS_INIT(y, Y, Y);
#endif
#if HAS_Z_STEP
#if ENABLED(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_STEP
#if defined(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_STEP
Z2_STEP_INIT;
Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
#endif
......@@ -1037,7 +1037,7 @@ void st_init() {
TCNT1 = 0;
ENABLE_STEPPER_DRIVER_INTERRUPT();
#if ENABLED(ADVANCE)
#ifdef ADVANCE
#if defined(TCCR0A) && defined(WGM01)
TCCR0A &= ~BIT(WGM01);
TCCR0A &= ~BIT(WGM00);
......@@ -1081,7 +1081,7 @@ long st_get_position(uint8_t axis) {
return count_pos;
}
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
float st_get_position_mm(AxisEnum axis) {
return st_get_position(axis) / axis_steps_per_unit[axis];
......@@ -1102,7 +1102,7 @@ void quickStop() {
ENABLE_STEPPER_DRIVER_INTERRUPT();
}
#if ENABLED(NPR2)
#ifdef NPR2
void colorstep(long csteps,const bool direction) {
enable_e1();
//setup new step
......@@ -1150,7 +1150,7 @@ void quickStop() {
case Z_AXIS: {
#if DISABLED(DELTA)
#ifndef DELTA
BABYSTEP_AXIS(z, Z, BABYSTEP_INVERT_Z);
......@@ -1325,7 +1325,7 @@ void microstep_readings() {
#endif
}
#if ENABLED(Z_DUAL_ENDSTOPS)
#ifdef Z_DUAL_ENDSTOPS
void In_Homing_Process(bool state) { performing_homing = state; }
void Lock_z_motor(bool state) { locked_z_motor = state; }
void Lock_z2_motor(bool state) { locked_z2_motor = state; }
......
......@@ -53,7 +53,7 @@
#define REV_E_DIR() E0_DIR_WRITE(INVERT_E0_DIR)
#endif //DRIVER_EXTRUDERS
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
extern bool abort_on_endstop_hit;
#endif
......@@ -70,7 +70,7 @@ void st_set_e_position(const long &e);
// Get current position in steps
long st_get_position(uint8_t axis);
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
// Get current position in mm
float st_get_position_mm(AxisEnum axis);
#endif
......@@ -101,18 +101,18 @@ void digipot_current(uint8_t driver, int current);
void microstep_init();
void microstep_readings();
#if ENABLED(Z_DUAL_ENDSTOPS)
#ifdef Z_DUAL_ENDSTOPS
void In_Homing_Process(bool state);
void Lock_z_motor(bool state);
void Lock_z2_motor(bool state);
#endif
#if ENABLED(BABYSTEPPING)
#ifdef BABYSTEPPING
void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention
#endif
#if ENABLED(NPR2) // Multiextruder
#ifdef NPR2 // Multiextruder
void colorstep(long csteps,const bool direction);
#endif // NPR2
#endif
#endif // stepper_h
......@@ -22,203 +22,203 @@
#include "stepper_indirection.h"
#include "Configuration.h"
#if ENABLED(HAVE_TMCDRIVER)
#ifdef HAVE_TMCDRIVER
#include <SPI.h>
#include <TMC26XStepper.h>
#endif
// Stepper objects of TMC steppers used
#if ENABLED(X_IS_TMC)
#ifdef X_IS_TMC
TMC26XStepper stepperX(200,X_ENABLE_PIN,X_STEP_PIN,X_DIR_PIN,X_MAX_CURRENT,X_SENSE_RESISTOR);
#endif
#if ENABLED(X2_IS_TMC)
#ifdef X2_IS_TMC
TMC26XStepper stepperX2(200,X2_ENABLE_PIN,X2_STEP_PIN,X2_DIR_PIN,X2_MAX_CURRENT,X2_SENSE_RESISTOR);
#endif
#if ENABLED(Y_IS_TMC)
#ifdef Y_IS_TMC
TMC26XStepper stepperY(200,Y_ENABLE_PIN,Y_STEP_PIN,Y_DIR_PIN,Y_MAX_CURRENT,Y_SENSE_RESISTOR);
#endif
#if ENABLED(Y2_IS_TMC)
#ifdef Y2_IS_TMC
TMC26XStepper stepperY2(200,Y2_ENABLE_PIN,Y2_STEP_PIN,Y2_DIR_PIN,Y2_MAX_CURRENT,Y2_SENSE_RESISTOR);
#endif
#if ENABLED(Z_IS_TMC)
#ifdef Z_IS_TMC
TMC26XStepper stepperZ(200,Z_ENABLE_PIN,Z_STEP_PIN,Z_DIR_PIN,Z_MAX_CURRENT,Z_SENSE_RESISTOR);
#endif
#if ENABLED(Z2_IS_TMC)
#ifdef Z2_IS_TMC
TMC26XStepper stepperZ2(200,Z2_ENABLE_PIN,Z2_STEP_PIN,Z2_DIR_PIN,Z2_MAX_CURRENT,Z2_SENSE_RESISTOR);
#endif
#if ENABLED(E0_IS_TMC)
#ifdef E0_IS_TMC
TMC26XStepper stepperE0(200,E0_ENABLE_PIN,E0_STEP_PIN,E0_DIR_PIN,E0_MAX_CURRENT,E0_SENSE_RESISTOR);
#endif
#if ENABLED(E1_IS_TMC)
#ifdef E1_IS_TMC
TMC26XStepper stepperE1(200,E1_ENABLE_PIN,E1_STEP_PIN,E1_DIR_PIN,E1_MAX_CURRENT,E1_SENSE_RESISTOR);
#endif
#if ENABLED(E2_IS_TMC)
#ifdef E2_IS_TMC
TMC26XStepper stepperE2(200,E2_ENABLE_PIN,E2_STEP_PIN,E2_DIR_PIN,E2_MAX_CURRENT,E2_SENSE_RESISTOR);
#endif
#if ENABLED(E3_IS_TMC)
#ifdef E3_IS_TMC
TMC26XStepper stepperE3(200,E3_ENABLE_PIN,E3_STEP_PIN,E3_DIR_PIN,E3_MAX_CURRENT,E3_SENSE_RESISTOR);
#endif
#if ENABLED(HAVE_TMCDRIVER)
#ifdef HAVE_TMCDRIVER
void tmc_init()
{
#if ENABLED(X_IS_TMC)
#ifdef X_IS_TMC
stepperX.setMicrosteps(X_MICROSTEPS);
stepperX.start();
#endif
#if ENABLED(X2_IS_TMC)
#endif
#ifdef X2_IS_TMC
stepperX2.setMicrosteps(X2_MICROSTEPS);
stepperX2.start();
#endif
#if ENABLED(Y_IS_TMC)
#endif
#ifdef Y_IS_TMC
stepperY.setMicrosteps(Y_MICROSTEPS);
stepperY.start();
#endif
#if ENABLED(Y2_IS_TMC)
#endif
#ifdef Y2_IS_TMC
stepperY2.setMicrosteps(Y2_MICROSTEPS);
stepperY2.start();
#endif
#if ENABLED(Z_IS_TMC)
#endif
#ifdef Z_IS_TMC
stepperZ.setMicrosteps(Z_MICROSTEPS);
stepperZ.start();
#endif
#if ENABLED(Z2_IS_TMC)
#endif
#ifdef Z2_IS_TMC
stepperZ2.setMicrosteps(Z2_MICROSTEPS);
stepperZ2.start();
#endif
#if ENABLED(E0_IS_TMC)
#endif
#ifdef E0_IS_TMC
stepperE0.setMicrosteps(E0_MICROSTEPS);
stepperE0.start();
#endif
#if ENABLED(E1_IS_TMC)
#endif
#ifdef E1_IS_TMC
stepperE1.setMicrosteps(E1_MICROSTEPS);
stepperE1.start();
#endif
#if ENABLED(E2_IS_TMC)
#endif
#ifdef E2_IS_TMC
stepperE2.setMicrosteps(E2_MICROSTEPS);
stepperE2.start();
#endif
#if ENABLED(E3_IS_TMC)
#endif
#ifdef E3_IS_TMC
stepperE3.setMicrosteps(E3_MICROSTEPS);
stepperE3.start();
#endif
#endif
}
#endif
// L6470 Driver objects and inits
#if ENABLED(HAVE_L6470DRIVER)
#ifdef HAVE_L6470DRIVER
#include <SPI.h>
#include <L6470.h>
#endif
// L6470 Stepper objects
#if ENABLED(X_IS_L6470)
#ifdef X_IS_L6470
L6470 stepperX(X_ENABLE_PIN);
#endif
#if ENABLED(X2_IS_L6470)
#endif
#ifdef X2_IS_L6470
L6470 stepperX2(X2_ENABLE_PIN);
#endif
#if ENABLED(Y_IS_L6470)
#endif
#ifdef Y_IS_L6470
L6470 stepperY(Y_ENABLE_PIN);
#endif
#if ENABLED(Y2_IS_L6470)
#endif
#ifdef Y2_IS_L6470
L6470 stepperY2(Y2_ENABLE_PIN);
#endif
#if ENABLED(Z_IS_L6470)
#endif
#ifdef Z_IS_L6470
L6470 stepperZ(Z_ENABLE_PIN);
#endif
#if ENABLED(Z2_IS_L6470)
#endif
#ifdef Z2_IS_L6470
L6470 stepperZ2(Z2_ENABLE_PIN);
#endif
#if ENABLED(E0_IS_L6470)
#endif
#ifdef E0_IS_L6470
L6470 stepperE0(E0_ENABLE_PIN);
#endif
#if ENABLED(E1_IS_L6470)
#endif
#ifdef E1_IS_L6470
L6470 stepperE1(E1_ENABLE_PIN);
#endif
#if ENABLED(E2_IS_L6470)
#endif
#ifdef E2_IS_L6470
L6470 stepperE2(E2_ENABLE_PIN);
#endif
#if ENABLED(E3_IS_L6470)
#endif
#ifdef E3_IS_L6470
L6470 stepperE3(E3_ENABLE_PIN);
#endif
#endif
// init routine
#if ENABLED(HAVE_L6470DRIVER)
#ifdef HAVE_L6470DRIVER
void L6470_init()
{
#if ENABLED(X_IS_L6470)
#ifdef X_IS_L6470
stepperX.init(X_K_VAL);
stepperX.softFree();
stepperX.setMicroSteps(X_MICROSTEPS);
stepperX.setOverCurrent(X_OVERCURRENT); //set overcurrent protection
stepperX.setStallCurrent(X_STALLCURRENT);
#endif
#if ENABLED(X2_IS_L6470)
#endif
#ifdef X2_IS_L6470
stepperX2.init(X2_K_VAL);
stepperX2.softFree();
stepperX2.setMicroSteps(X2_MICROSTEPS);
stepperX2.setOverCurrent(X2_OVERCURRENT); //set overcurrent protection
stepperX2.setStallCurrent(X2_STALLCURRENT);
#endif
#if ENABLED(Y_IS_L6470)
#endif
#ifdef Y_IS_L6470
stepperY.init(Y_K_VAL);
stepperY.softFree();
stepperY.setMicroSteps(Y_MICROSTEPS);
stepperY.setOverCurrent(Y_OVERCURRENT); //set overcurrent protection
stepperY.setStallCurrent(Y_STALLCURRENT);
#endif
#if ENABLED(Y2_IS_L6470)
#endif
#ifdef Y2_IS_L6470
stepperY2.init(Y2_K_VAL);
stepperY2.softFree();
stepperY2.setMicroSteps(Y2_MICROSTEPS);
stepperY2.setOverCurrent(Y2_OVERCURRENT); //set overcurrent protection
stepperY2.setStallCurrent(Y2_STALLCURRENT);
#endif
#if ENABLED(Z_IS_L6470)
#endif
#ifdef Z_IS_L6470
stepperZ.init(Z_K_VAL);
stepperZ.softFree();
stepperZ.setMicroSteps(Z_MICROSTEPS);
stepperZ.setOverCurrent(Z_OVERCURRENT); //set overcurrent protection
stepperZ.setStallCurrent(Z_STALLCURRENT);
#endif
#if ENABLED(Z2_IS_L6470)
#endif
#ifdef Z2_IS_L6470
stepperZ2.init(Z2_K_VAL);
stepperZ2.softFree();
stepperZ2.setMicroSteps(Z2_MICROSTEPS);
stepperZ2.setOverCurrent(Z2_OVERCURRENT); //set overcurrent protection
stepperZ2.setStallCurrent(Z2_STALLCURRENT);
#endif
#if ENABLED(E0_IS_L6470)
#endif
#ifdef E0_IS_L6470
stepperE0.init(E0_K_VAL);
stepperE0.softFree();
stepperE0.setMicroSteps(E0_MICROSTEPS);
stepperE0.setOverCurrent(E0_OVERCURRENT); //set overcurrent protection
stepperE0.setStallCurrent(E0_STALLCURRENT);
#endif
#if ENABLED(E1_IS_L6470)
#endif
#ifdef E1_IS_L6470
stepperE1.init(E1_K_VAL);
stepperE1.softFree();
stepperE1.setMicroSteps(E1_MICROSTEPS);
stepperE1.setOverCurrent(E1_OVERCURRENT); //set overcurrent protection
stepperE1.setStallCurrent(E1_STALLCURRENT);
#endif
#if ENABLED(E2_IS_L6470)
#endif
#ifdef E2_IS_L6470
stepperE2.init(E2_K_VAL);
stepperE2.softFree();
stepperE2.setMicroSteps(E2_MICROSTEPS);
stepperE2.setOverCurrent(E2_OVERCURRENT); //set overcurrent protection
stepperE2.setStallCurrent(E2_STALLCURRENT);
#endif
#if ENABLED(E3_IS_L6470)
#endif
#ifdef E3_IS_L6470
stepperE3.init(E3_K_VAL);
stepperE3.softFree();
stepperE3.setMicroSteps(E3_MICROSTEPS);
stepperE3.setOverCurrent(E3_OVERCURRENT); //set overcurrent protection
stepperE3.setStallCurrent(E3_STALLCURRENT);
#endif
#endif
}
#endif
......@@ -22,8 +22,6 @@
#ifndef STEPPER_INDIRECTION_H
#define STEPPER_INDIRECTION_H
#include "macros.h"
// X motor
#define X_STEP_INIT SET_OUTPUT(X_STEP_PIN)
#define X_STEP_WRITE(STATE) WRITE(X_STEP_PIN,STATE)
......@@ -158,12 +156,12 @@
// Pin redefines for TMC drivers.
// TMC26X drivers have step and dir on normal pins, but everything else via SPI
//////////////////////////////////
#if ENABLED(HAVE_TMCDRIVER)
#ifdef HAVE_TMCDRIVER
#include <SPI.h>
#include <TMC26XStepper.h>
void tmc_init();
#if ENABLED(X_IS_TMC)
#ifdef X_IS_TMC
extern TMC26XStepper stepperX;
#undef X_ENABLE_INIT
#define X_ENABLE_INIT ((void)0)
......@@ -175,7 +173,7 @@
#define X_ENABLE_READ stepperX.isEnabled()
#endif
#if ENABLED(X2_IS_TMC)
#ifdef X2_IS_TMC
extern TMC26XStepper stepperX2;
#undef X2_ENABLE_INIT
#define X2_ENABLE_INIT ((void)0)
......@@ -186,7 +184,7 @@
#undef X2_ENABLE_READ
#define X2_ENABLE_READ stepperX2.isEnabled()
#endif
#if ENABLED(Y_IS_TMC)
#ifdef Y_IS_TMC
extern TMC26XStepper stepperY;
#undef Y_ENABLE_INIT
#define Y_ENABLE_INIT ((void)0)
......@@ -197,7 +195,7 @@
#undef Y_ENABLE_READ
#define Y_ENABLE_READ stepperY.isEnabled()
#endif
#if ENABLED(Y2_IS_TMC)
#ifdef Y2_IS_TMC
extern TMC26XStepper stepperY2;
#undef Y2_ENABLE_INIT
#define Y2_ENABLE_INIT ((void)0)
......@@ -208,7 +206,7 @@
#undef Y2_ENABLE_READ
#define Y2_ENABLE_READ stepperY2.isEnabled()
#endif
#if ENABLED(Z_IS_TMC)
#ifdef Z_IS_TMC
extern TMC26XStepper stepperZ;
#undef Z_ENABLE_INIT
#define Z_ENABLE_INIT ((void)0)
......@@ -219,7 +217,7 @@
#undef Z_ENABLE_READ
#define Z_ENABLE_READ stepperZ.isEnabled()
#endif
#if ENABLED(Z2_IS_TMC)
#ifdef Z2_IS_TMC
extern TMC26XStepper stepperZ2;
#undef Z2_ENABLE_INIT
#define Z2_ENABLE_INIT ((void)0)
......@@ -230,7 +228,7 @@
#undef Z2_ENABLE_READ
#define Z2_ENABLE_READ stepperZ2.isEnabled()
#endif
#if ENABLED(E0_IS_TMC)
#ifdef E0_IS_TMC
extern TMC26XStepper stepperE0;
#undef E0_ENABLE_INIT
#define E0_ENABLE_INIT ((void)0)
......@@ -241,7 +239,7 @@
#undef E0_ENABLE_READ
#define E0_ENABLE_READ stepperE0.isEnabled()
#endif
#if ENABLED(E1_IS_TMC)
#ifdef E1_IS_TMC
extern TMC26XStepper stepperE1;
#undef E1_ENABLE_INIT
#define E1_ENABLE_INIT ((void)0)
......@@ -252,7 +250,7 @@
#undef E1_ENABLE_READ
#define E1_ENABLE_READ stepperE1.isEnabled()
#endif
#if ENABLED(E2_IS_TMC)
#ifdef E2_IS_TMC
extern TMC26XStepper stepperE2;
#undef E2_ENABLE_INIT
#define E2_ENABLE_INIT ((void)0)
......@@ -263,7 +261,7 @@
#undef E2_ENABLE_READ
#define E2_ENABLE_READ stepperE2.isEnabled()
#endif
#if ENABLED(E3_IS_TMC)
#ifdef E3_IS_TMC
extern TMC26XStepper stepperE3;
#undef E3_ENABLE_INIT
#define E3_ENABLE_INIT ((void)0)
......@@ -281,13 +279,13 @@
// Pin redefines for L6470 drivers.
// L640 drivers have step on normal pins, but dir and everything else via SPI
//////////////////////////////////
#if ENABLED(HAVE_L6470DRIVER)
#ifdef HAVE_L6470DRIVER
#include <SPI.h>
#include <L6470.h>
void L6470_init();
#if ENABLED(X_IS_L6470)
#ifdef X_IS_L6470
extern L6470 stepperX;
#undef X_ENABLE_INIT
#define X_ENABLE_INIT ((void)0)
......@@ -308,7 +306,7 @@
#define X_DIR_READ (stepperX.getStatus() & STATUS_DIR)
#endif
#if ENABLED(X2_IS_L6470)
#ifdef X2_IS_L6470
extern L6470 stepperX2;
#undef X2_ENABLE_INIT
#define X2_ENABLE_INIT ((void)0)
......@@ -328,7 +326,7 @@
#undef X2_DIR_READ
#define X2_DIR_READ (stepperX2.getStatus() & STATUS_DIR)
#endif
#if ENABLED(Y_IS_L6470)
#ifdef Y_IS_L6470
extern L6470 stepperY;
#undef Y_ENABLE_INIT
#define Y_ENABLE_INIT ((void)0)
......@@ -348,7 +346,7 @@
#undef Y_DIR_READ
#define Y_DIR_READ (stepperY.getStatus() & STATUS_DIR)
#endif
#if ENABLED(Y2_IS_L6470)
#ifdef Y2_IS_L6470
extern L6470 stepperY2;
#undef Y2_ENABLE_INIT
#define Y2_ENABLE_INIT ((void)0)
......@@ -368,7 +366,7 @@
#undef Y2_DIR_READ
#define Y2_DIR_READ (stepperY2.getStatus() & STATUS_DIR)
#endif
#if ENABLED(Z_IS_L6470)
#ifdef Z_IS_L6470
extern L6470 stepperZ;
#undef Z_ENABLE_INIT
#define Z_ENABLE_INIT ((void)0)
......@@ -388,7 +386,7 @@
#undef Y_DIR_READ
#define Y_DIR_READ (stepperZ.getStatus() & STATUS_DIR)
#endif
#if ENABLED(Z2_IS_L6470)
#ifdef Z2_IS_L6470
extern L6470 stepperZ2;
#undef Z2_ENABLE_INIT
#define Z2_ENABLE_INIT ((void)0)
......@@ -408,7 +406,7 @@
#undef Y2_DIR_READ
#define Y2_DIR_READ (stepperZ2.getStatus() & STATUS_DIR)
#endif
#if ENABLED(E0_IS_L6470)
#ifdef E0_IS_L6470
extern L6470 stepperE0;
#undef E0_ENABLE_INIT
#define E0_ENABLE_INIT ((void)0)
......@@ -428,7 +426,7 @@
#undef E0_DIR_READ
#define E0_DIR_READ (stepperE0.getStatus() & STATUS_DIR)
#endif
#if ENABLED(E1_IS_L6470)
#ifdef E1_IS_L6470
extern L6470 stepperE1;
#undef E1_ENABLE_INIT
#define E1_ENABLE_INIT ((void)0)
......@@ -448,7 +446,7 @@
#undef E1_DIR_READ
#define E1_DIR_READ (stepperE1.getStatus() & STATUS_DIR)
#endif
#if ENABLED(E2_IS_L6470)
#ifdef E2_IS_L6470
extern L6470 stepperE2;
#undef E2_ENABLE_INIT
#define E2_ENABLE_INIT ((void)0)
......@@ -468,7 +466,7 @@
#undef E2_DIR_READ
#define E2_DIR_READ (stepperE2.getStatus() & STATUS_DIR)
#endif
#if ENABLED(E3_IS_L6470)
#ifdef E3_IS_L6470
extern L6470 stepperE3;
#undef E3_ENABLE_INIT
#define E3_ENABLE_INIT ((void)0)
......
......@@ -34,7 +34,7 @@
#define K2 (1.0 - K1)
#endif
#if ENABLED(PIDTEMPBED) || ENABLED(PIDTEMP)
#if defined(PIDTEMPBED) || defined(PIDTEMP)
#define PID_dT ((OVERSAMPLENR * 14.0)/(F_CPU / 64.0 / 256.0))
#define RECI_PID_dT ( 1 / PID_dT )
#endif
......@@ -49,39 +49,39 @@ int current_temperature_raw[4] = { 0 };
float current_temperature[4] = { 0.0 };
int current_temperature_bed_raw = 0;
float current_temperature_bed = 0.0;
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
int redundant_temperature_raw = 0;
float redundant_temperature = 0.0;
#endif
#if ENABLED(PIDTEMPBED)
#ifdef PIDTEMPBED
float bedKp = DEFAULT_bedKp;
float bedKi = (DEFAULT_bedKi * PID_dT);
float bedKd = (DEFAULT_bedKd / PID_dT);
#endif //PIDTEMPBED
#if ENABLED(FAN_SOFT_PWM)
#ifdef FAN_SOFT_PWM
unsigned char fanSpeedSoftPwm;
#endif
unsigned char soft_pwm_bed;
#if ENABLED(BABYSTEPPING)
#ifdef BABYSTEPPING
volatile int babystepsTodo[3] = { 0 };
#endif
#if ENABLED(FILAMENT_SENSOR)
#ifdef FILAMENT_SENSOR
int current_raw_filwidth = 0; //Holds measured filament diameter - one extruder only
#endif
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || ENABLED(THERMAL_PROTECTION_BED)
#if defined(THERMAL_PROTECTION_HOTENDS) || defined(THERMAL_PROTECTION_BED)
enum TRState { TRReset, TRInactive, TRFirstHeating, TRStable, TRRunaway };
void thermal_runaway_protection(TRState *state, millis_t *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc);
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#ifdef THERMAL_PROTECTION_HOTENDS
static TRState thermal_runaway_state_machine[4] = { TRReset, TRReset, TRReset, TRReset };
static millis_t thermal_runaway_timer[4]; // = {0,0,0,0};
#endif
#if ENABLED(THERMAL_PROTECTION_BED)
#ifdef THERMAL_PROTECTION_BED
static TRState thermal_runaway_bed_state_machine = TRReset;
static millis_t thermal_runaway_bed_timer;
#endif
......@@ -97,7 +97,7 @@ unsigned char soft_pwm_bed;
static volatile bool temp_meas_ready = false;
#if ENABLED(PIDTEMP)
#ifdef PIDTEMP
//static cannot be external:
static float temp_iState[HOTENDS] = { 0 };
static float temp_dState[HOTENDS] = { 0 };
......@@ -110,7 +110,7 @@ static volatile bool temp_meas_ready = false;
static float temp_iState_max[HOTENDS];
static bool pid_reset[HOTENDS];
#endif //PIDTEMP
#if ENABLED(PIDTEMPBED)
#ifdef PIDTEMPBED
//static cannot be external:
static float temp_iState_bed = { 0 };
static float temp_dState_bed = { 0 };
......@@ -127,14 +127,14 @@ static volatile bool temp_meas_ready = false;
static unsigned char soft_pwm[HOTENDS];
#if ENABLED(FAN_SOFT_PWM)
#ifdef FAN_SOFT_PWM
static unsigned char soft_pwm_fan;
#endif
#if HAS_AUTO_FAN
static millis_t next_auto_fan_check_ms;
#endif
#if ENABLED(PIDTEMP)
#ifdef PIDTEMP
float Kp[HOTENDS], Ki[HOTENDS], Kd[HOTENDS];
#endif //PIDTEMP
......@@ -150,7 +150,7 @@ static int maxttemp[HOTENDS] = ARRAY_BY_HOTENDS( 16383, 16383, 16383, 16383 );
static int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
#endif
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
static void *heater_ttbl_map[2] = {(void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE };
static uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN };
#else
......@@ -162,7 +162,7 @@ static float analog2temp(int raw, uint8_t e);
static float analog2tempBed(int raw);
static void updateTemperaturesFromRawValues();
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#ifdef THERMAL_PROTECTION_HOTENDS
int watch_target_temp[HOTENDS] = { 0 };
millis_t watch_heater_next_ms[HOTENDS] = { 0 };
#endif
......@@ -175,7 +175,7 @@ static void updateTemperaturesFromRawValues();
static int meas_shift_index; //used to point to a delayed sample in buffer for filament width sensor
#endif
#if ENABLED(HEATER_0_USES_MAX6675)
#ifdef HEATER_0_USES_MAX6675
static int read_max6675();
#endif
......@@ -312,7 +312,7 @@ void PID_autotune(float temp, int hotend, int ncycles) {
if (hotend < 0) {
p = soft_pwm_bed;
ECHO_SMV(OK, MSG_B, input);
ECHO_EMV(MSG_AT, p);
ECHO_EMV(" " MSG_AT, p);
}
else {
p = soft_pwm[hotend];
......@@ -352,12 +352,12 @@ void PID_autotune(float temp, int hotend, int ncycles) {
}
void updatePID() {
#if ENABLED(PIDTEMP)
#ifdef PIDTEMP
for (int e = 0; e < HOTENDS; e++) {
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / PID_PARAM(Ki,e);
}
#endif
#if ENABLED(PIDTEMPBED)
#ifdef PIDTEMPBED
temp_iState_max_bed = PID_BED_INTEGRAL_DRIVE_MAX / bedKi;
#endif
}
......@@ -457,7 +457,7 @@ inline void _temp_error(int e, const char *serial_msg, const char *lcd_msg) {
lcd_setalertstatuspgm(lcd_msg);
#endif
}
#if DISABLED(BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE)
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
if (!killed) {
Running = false;
killed = true;
......@@ -477,8 +477,8 @@ void min_temp_error(uint8_t e) {
float get_pid_output(int e) {
float pid_output;
#if ENABLED(PIDTEMP)
#if ENABLED(PID_OPENLOOP)
#ifdef PIDTEMP
#ifdef PID_OPENLOOP
pid_output = constrain(target_temperature[e], 0, PID_MAX);
#else
pid_error[e] = target_temperature[e] - current_temperature[e];
......@@ -514,7 +514,7 @@ float get_pid_output(int e) {
temp_dState[e] = current_temperature[e];
#endif //PID_OPENLOOP
#if ENABLED(PID_DEBUG)
#ifdef PID_DEBUG
ECHO_SMV(DB, MSG_PID_DEBUG, e);
ECHO_MV(MSG_PID_DEBUG_INPUT, current_temperature[e]);
ECHO_MV(MSG_PID_DEBUG_OUTPUT, pid_output);
......@@ -530,10 +530,12 @@ float get_pid_output(int e) {
return pid_output;
}
#if ENABLED(PIDTEMPBED)
#ifdef PIDTEMPBED
float get_pid_output_bed() {
float pid_output;
#if DISABLED(PID_OPENLOOP)
#ifdef PID_OPENLOOP
pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER);
#else
pid_error_bed = target_temperature_bed - current_temperature_bed;
pTerm_bed = bedKp * pid_error_bed;
temp_iState_bed += pid_error_bed;
......@@ -552,11 +554,9 @@ float get_pid_output(int e) {
if (pid_error_bed < 0) temp_iState_bed -= pid_error_bed; // conditional un-integration
pid_output = 0;
}
#else
pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER);
#endif // PID_OPENLOOP
#if ENABLED(PID_BED_DEBUG)
#ifdef PID_BED_DEBUG
ECHO_SM(DB ," PID_BED_DEBUG ");
ECHO_MV(": Input ", current_temperature_bed);
ECHO_MV(" Output ", pid_output);
......@@ -583,20 +583,20 @@ void manage_heater() {
updateTemperaturesFromRawValues();
#if ENABLED(HEATER_0_USES_MAX6675)
#ifdef HEATER_0_USES_MAX6675
float ct = current_temperature[0];
if (ct > min(HEATER_0_MAXTEMP, 1023)) max_temp_error(0);
if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0);
#endif
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN
#if defined(THERMAL_PROTECTION_HOTENDS) || !defined(PIDTEMPBED) || HAS_AUTO_FAN
millis_t ms = millis();
#endif
// Loop through all hotends
for (int e = 0; e < HOTENDS; e++) {
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#ifdef THERMAL_PROTECTION_HOTENDS
thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
#endif
......@@ -606,7 +606,7 @@ void manage_heater() {
soft_pwm[e] = current_temperature[e] > minttemp[e] && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0;
// Check if the temperature is failing to increase
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#ifdef THERMAL_PROTECTION_HOTENDS
// Is it time to check this extruder's heater?
if (watch_heater_next_ms[e] && ms > watch_heater_next_ms[e]) {
......@@ -623,7 +623,7 @@ void manage_heater() {
#endif // THERMAL_PROTECTION_HOTENDS
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
_temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP));
}
......@@ -639,7 +639,7 @@ void manage_heater() {
#endif
// Control the extruder rate based on the width sensor
#if ENABLED(FILAMENT_SENSOR)
#ifdef FILAMENT_SENSOR
if (filament_sensor) {
meas_shift_index = delay_index1 - meas_delay_cm;
if (meas_shift_index < 0) meas_shift_index += MAX_MEASUREMENT_DELAY + 1; //loop around buffer if needed
......@@ -653,23 +653,23 @@ void manage_heater() {
}
#endif //FILAMENT_SENSOR
#if DISABLED(PIDTEMPBED)
#ifndef PIDTEMPBED
if (ms < next_bed_check_ms) return;
next_bed_check_ms = ms + BED_CHECK_INTERVAL;
#endif
#if TEMP_SENSOR_BED != 0
#if ENABLED(THERMAL_PROTECTION_BED)
#ifdef THERMAL_PROTECTION_BED
thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, -1, THERMAL_PROTECTION_BED_PERIOD, THERMAL_PROTECTION_BED_HYSTERESIS);
#endif
#if ENABLED(PIDTEMPBED)
#ifdef PIDTEMPBED
float pid_output = get_pid_output_bed();
soft_pwm_bed = current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP ? (int)pid_output >> 1 : 0;
#elif ENABLED(BED_LIMIT_SWITCHING)
#elif defined(BED_LIMIT_SWITCHING)
// Check if temperature is within the correct band
if (current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP) {
if (current_temperature_bed >= target_temperature_bed + BED_HYSTERESIS)
......@@ -698,7 +698,7 @@ void manage_heater() {
// Derived from RepRap FiveD extruder::getTemperature()
// For hot end temperature measurement.
static float analog2temp(int raw, uint8_t e) {
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
if (e > EXTRUDERS)
#else
if (e >= EXTRUDERS)
......@@ -709,7 +709,7 @@ static float analog2temp(int raw, uint8_t e) {
return 0.0;
}
#if ENABLED(HEATER_0_USES_MAX6675)
#ifdef HEATER_0_USES_MAX6675
if (e == 0) return 0.25 * raw;
#endif
......@@ -744,7 +744,7 @@ static float analog2temp(int raw, uint8_t e) {
// Derived from RepRap FiveD extruder::getTemperature()
// For bed temperature measurement.
static float analog2tempBed(int raw) {
#if ENABLED(BED_USES_THERMISTOR)
#ifdef BED_USES_THERMISTOR
float celsius = 0;
byte i;
......@@ -779,14 +779,14 @@ static void updateTemperaturesFromRawValues() {
static millis_t last_update = millis();
millis_t temp_last_update = millis();
millis_t from_last_update = temp_last_update - last_update;
#if ENABLED(HEATER_0_USES_MAX6675)
#ifdef HEATER_0_USES_MAX6675
current_temperature_raw[0] = read_max6675();
#endif
for (uint8_t e = 0; e < HOTENDS; e++) {
current_temperature[e] = analog2temp(current_temperature_raw[e], e);
}
current_temperature_bed = analog2tempBed(current_temperature_bed_raw);
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
redundant_temperature = analog2temp(redundant_temperature_raw, 1);
#endif
#if HAS_FILAMENT_SENSOR
......@@ -866,11 +866,11 @@ void tp_init() {
for (int e = 0; e < HOTENDS; e++) {
// populate with the first value
maxttemp[e] = maxttemp[0];
#if ENABLED(PIDTEMP)
#ifdef PIDTEMP
temp_iState_min[e] = 0.0;
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / PID_PARAM(Ki,e);
#endif //PIDTEMP
#if ENABLED(PIDTEMPBED)
#ifdef PIDTEMPBED
temp_iState_min_bed = 0.0;
temp_iState_max_bed = PID_BED_INTEGRAL_DRIVE_MAX / bedKi;
#endif // PIDTEMPBED
......@@ -893,17 +893,17 @@ void tp_init() {
#endif
#if HAS_FAN
SET_OUTPUT(FAN_PIN);
#if ENABLED(FAST_PWM_FAN)
#ifdef FAST_PWM_FAN
setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
#endif
#if ENABLED(FAN_SOFT_PWM)
#ifdef FAN_SOFT_PWM
soft_pwm_fan = fanSpeedSoftPwm / 2;
#endif
#endif
#if ENABLED(HEATER_0_USES_MAX6675)
#ifdef HEATER_0_USES_MAX6675
#if DISABLED(SDSUPPORT)
#ifndef SDSUPPORT
OUT_WRITE(SCK_PIN, LOW);
OUT_WRITE(MOSI_PIN, HIGH);
OUT_WRITE(MISO_PIN, HIGH);
......@@ -1036,7 +1036,7 @@ void tp_init() {
#endif // BED_MAXTEMP
}
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#ifdef THERMAL_PROTECTION_HOTENDS
/**
* Start Heating Sanity Check for hotends that are below
* their target temperature by a configurable margin.
......@@ -1052,7 +1052,7 @@ void tp_init() {
}
#endif
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || ENABLED(THERMAL_PROTECTION_BED)
#if defined(THERMAL_PROTECTION_HOTENDS) || defined(THERMAL_PROTECTION_BED)
void thermal_runaway_protection(TRState *state, millis_t *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) {
......@@ -1140,7 +1140,7 @@ void disable_all_heaters() {
#endif
}
#if ENABLED(HEATER_0_USES_MAX6675)
#ifdef HEATER_0_USES_MAX6675
#define MAX6675_HEAT_INTERVAL 250u
static millis_t next_max6675_ms = 0;
int max6675_temp = 2000;
......@@ -1223,11 +1223,11 @@ static unsigned long raw_temp_value[4] = { 0 };
static unsigned long raw_temp_bed_value = 0;
static void set_current_temp_raw() {
#if HAS_TEMP_0 && DISABLED(HEATER_0_USES_MAX6675)
#if HAS_TEMP_0 && !defined(HEATER_0_USES_MAX6675)
current_temperature_raw[0] = raw_temp_value[0];
#endif
#if HAS_TEMP_1
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
redundant_temperature_raw = raw_temp_value[1];
#else
current_temperature_raw[1] = raw_temp_value[1];
......@@ -1265,7 +1265,7 @@ ISR(TIMER0_COMPB_vect) {
static unsigned char pwm_count = BIT(SOFT_PWM_SCALE);
// Static members for each heater
#if ENABLED(SLOW_PWM_HEATERS)
#ifdef SLOW_PWM_HEATERS
static unsigned char slow_pwm_count = 0;
#define ISR_STATICS(n) \
static unsigned char soft_pwm_ ## n; \
......@@ -1277,7 +1277,7 @@ ISR(TIMER0_COMPB_vect) {
// Statics per heater
ISR_STATICS(0);
#if (HOTENDS > 1) || ENABLED(HEATERS_PARALLEL)
#if (HOTENDS > 1) || defined(HEATERS_PARALLEL)
ISR_STATICS(1);
#if HOTENDS > 2
ISR_STATICS(2);
......@@ -1294,7 +1294,7 @@ ISR(TIMER0_COMPB_vect) {
static unsigned long raw_filwidth_value = 0;
#endif
#if DISABLED(SLOW_PWM_HEATERS)
#ifndef SLOW_PWM_HEATERS
/**
* standard PWM modulation
*/
......@@ -1322,7 +1322,7 @@ ISR(TIMER0_COMPB_vect) {
soft_pwm_BED = soft_pwm_bed;
WRITE_HEATER_BED(soft_pwm_BED > 0 ? 1 : 0);
#endif
#if ENABLED(FAN_SOFT_PWM)
#ifdef FAN_SOFT_PWM
soft_pwm_fan = fanSpeedSoftPwm / 2;
WRITE_FAN(soft_pwm_fan > 0 ? 1 : 0);
#endif
......@@ -1343,7 +1343,7 @@ ISR(TIMER0_COMPB_vect) {
if (soft_pwm_BED < pwm_count) WRITE_HEATER_BED(0);
#endif
#if ENABLED(FAN_SOFT_PWM)
#ifdef FAN_SOFT_PWM
if (soft_pwm_fan < pwm_count) WRITE_FAN(0);
#endif
......@@ -1422,7 +1422,7 @@ ISR(TIMER0_COMPB_vect) {
PWM_OFF_ROUTINE(BED); // BED
#endif
#if ENABLED(FAN_SOFT_PWM)
#ifdef FAN_SOFT_PWM
if (pwm_count == 0) {
soft_pwm_fan = fanSpeedSoftPwm / 2;
WRITE_FAN(soft_pwm_fan > 0 ? 1 : 0);
......@@ -1595,7 +1595,7 @@ ISR(TIMER0_COMPB_vect) {
raw_powconsumption_value = 0;
#endif
#if HAS_TEMP_0 && DISABLED(HEATER_0_USES_MAX6675)
#if HAS_TEMP_0 && !defined(HEATER_0_USES_MAX6675)
#if HEATER_0_RAW_LO_TEMP > HEATER_0_RAW_HI_TEMP
#define GE0 <=
#else
......@@ -1647,7 +1647,7 @@ ISR(TIMER0_COMPB_vect) {
} // temp_count >= OVERSAMPLENR
#if ENABLED(BABYSTEPPING)
#ifdef BABYSTEPPING
for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) {
int curTodo = babystepsTodo[axis]; //get rid of volatile for performance
......@@ -1663,7 +1663,7 @@ ISR(TIMER0_COMPB_vect) {
#endif //BABYSTEPPING
}
#if ENABLED(PIDTEMP)
#ifdef PIDTEMP
// Apply the scale factors to the PID values
float scalePID_i(float i) { return i * PID_dT; }
float unscalePID_i(float i) { return i / PID_dT; }
......
......@@ -50,13 +50,13 @@ void manage_heater(); //it is critical that this is called periodically.
// do not use these routines and variables outside of temperature.cpp
extern int target_temperature[4];
extern float current_temperature[4];
#if ENABLED(SHOW_TEMP_ADC_VALUES)
#ifdef SHOW_TEMP_ADC_VALUES
extern int current_temperature_raw[4];
extern int current_temperature_bed_raw;
#endif
extern int target_temperature_bed;
extern float current_temperature_bed;
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
extern float redundant_temperature;
#endif
......@@ -64,7 +64,7 @@ extern float current_temperature_bed;
extern unsigned char soft_pwm_bed;
#endif
#if ENABLED(PIDTEMP)
#ifdef PIDTEMP
extern float Kp[HOTENDS], Ki[HOTENDS], Kd[HOTENDS];
#define PID_PARAM(param, e) param[e] // use macro to point to array value
float scalePID_i(float i);
......@@ -73,11 +73,11 @@ extern float current_temperature_bed;
float unscalePID_d(float d);
#endif
#if ENABLED(PIDTEMPBED)
#ifdef PIDTEMPBED
extern float bedKp,bedKi,bedKd;
#endif
#if ENABLED(BABYSTEPPING)
#ifdef BABYSTEPPING
extern volatile int babystepsTodo[3];
#endif
......@@ -93,7 +93,7 @@ extern float current_temperature_bed;
FORCE_INLINE float degHotend(uint8_t hotend) { return current_temperature[HOTEND_ARG]; }
FORCE_INLINE float degBed() { return current_temperature_bed; }
#if ENABLED(SHOW_TEMP_ADC_VALUES)
#ifdef SHOW_TEMP_ADC_VALUES
FORCE_INLINE float rawHotendTemp(uint8_t hotend) { return current_temperature_raw[HOTEND_ARG]; }
FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }
#endif
......@@ -101,13 +101,13 @@ FORCE_INLINE float degBed() { return current_temperature_bed; }
FORCE_INLINE float degTargetHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG]; }
FORCE_INLINE float degTargetBed() { return target_temperature_bed; }
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#ifdef THERMAL_PROTECTION_HOTENDS
void start_watching_heater(int e=0);
#endif
FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t hotend) {
target_temperature[HOTEND_ARG] = celsius;
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#ifdef THERMAL_PROTECTION_HOTENDS
start_watching_heater(HOTEND_ARG);
#endif
}
......@@ -152,7 +152,7 @@ void setExtruderAutoFanState(int pin, bool state);
void checkExtruderAutoFans();
FORCE_INLINE void autotempShutdown() {
#if ENABLED(AUTOTEMP)
#ifdef AUTOTEMP
if (autotemp_enabled) {
autotemp_enabled = false;
if (degTargetHotend(active_extruder) > autotemp_min)
......
......@@ -12,12 +12,11 @@ int8_t encoderDiff; // updated from interrupt context and added to encoderPositi
bool encoderRateMultiplierEnabled;
int32_t lastEncoderMovementMillis;
int pageShowInfo = 0;
boolean ChangeScreen = false;
void set_pageShowInfo(int value){ pageShowInfo = value; }
void set_ChangeScreen(boolean state) { ChangeScreen = state; }
#if defined(DELTA) && defined(Z_SAFE_HOMING) && Z_HOME_DIR < 0
int pageShowInfo = 0;
void set_pageShowInfo(int value){ pageShowInfo = value; }
#endif
/* Configuration settings */
int plaPreheatHotendTemp;
int plaPreheatHPBTemp;
int plaPreheatFanSpeed;
......@@ -38,8 +37,6 @@ int gumPreheatFanSpeed;
millis_t print_millis = 0;
#endif
/* !Configuration settings */
// Function pointer to menu functions.
typedef void (*menuFunc_t)();
......@@ -48,7 +45,7 @@ char lcd_status_message[3*LCD_WIDTH+1] = WELCOME_MSG; // worst case is kana with
#ifdef DOGLCD
#include "dogm_lcd_implementation.h"
#define LCD_Printpos(x, y) u8g.setPrintPos(LCD_PIXEL_WIDTH - DOG_CHAR_WIDTH * x, (y + 1) * DOG_CHAR_HEIGHT)
#define LCD_Printpos(x, y) u8g.setPrintPos(x + 5, (y + 1) * (DOG_CHAR_HEIGHT + 2))
#else
#include "ultralcd_implementation_hitachi_HD44780.h"
#define LCD_Printpos(x, y) lcd.setCursor(x, y)
......@@ -74,8 +71,6 @@ static void lcd_status_screen();
static void lcd_control_temperature_preheat_gum_settings_menu();
static void lcd_control_motion_menu();
static void lcd_control_volumetric_menu();
static void config_lcd_level_bed();
static void lcd_level_bed();
#ifdef HAS_LCD_CONTRAST
static void lcd_set_contrast();
#endif
......@@ -84,8 +79,11 @@ static void lcd_status_screen();
#endif
static void lcd_sdcard_menu();
#if ENABLED(DELTA)
#ifdef DELTA
static void lcd_delta_calibrate_menu();
#elif !defined(DELTA) && !defined(Z_SAFE_HOMING) && Z_HOME_DIR < 0
static void lcd_level_bed();
static void config_lcd_level_bed();
#endif // DELTA
/* Different types of actions that can be used in menu items. */
......@@ -116,7 +114,7 @@ static void lcd_status_screen();
#define ENCODER_FEEDRATE_DEADZONE 10
#if DISABLED(LCD_I2C_VIKI)
#if !defined(LCD_I2C_VIKI)
#ifndef ENCODER_STEPS_PER_MENU_ITEM
#define ENCODER_STEPS_PER_MENU_ITEM 5
#endif
......@@ -138,7 +136,7 @@ static void lcd_status_screen();
/**
* START_MENU generates the init code for a menu function
*/
#if ENABLED(BTN_BACK) && BTN_BACK > 0
#if defined(BTN_BACK) && BTN_BACK > 0
#define START_MENU(last_menu) do { \
encoderRateMultiplierEnabled = false; \
if (encoderPosition > 0x8000) encoderPosition = 0; \
......@@ -352,7 +350,7 @@ static void lcd_status_screen() {
}
#endif
#if ENABLED(ULTIPANEL)
#ifdef ULTIPANEL
bool current_click = LCD_CLICKED;
......@@ -414,7 +412,7 @@ static void lcd_status_screen() {
static void lcd_return_to_status() { lcd_goto_menu(lcd_status_screen); }
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
static void lcd_sdcard_pause() { card.pauseSDPrint(); }
static void lcd_sdcard_resume() { card.startFileprint(); }
......@@ -443,7 +441,7 @@ static void lcd_main_menu() {
}
else {
MENU_ITEM(submenu, MSG_PREPARE, lcd_prepare_menu);
#if ENABLED(DELTA)
#ifdef DELTA
MENU_ITEM(submenu, MSG_DELTA_CALIBRATE, lcd_delta_calibrate_menu);
#endif // DELTA
}
......@@ -476,7 +474,7 @@ static void lcd_main_menu() {
END_MENU();
}
#if ENABLED(SDSUPPORT) && ENABLED(MENU_ADDAUTOSTART)
#if defined(SDSUPPORT) && defined(MENU_ADDAUTOSTART)
static void lcd_autostart_sd() {
card.autostart_index = 0;
card.setroot();
......@@ -561,7 +559,7 @@ static void lcd_tune_menu() {
END_MENU();
}
#if ENABLED(EASY_LOAD)
#if defined(EASY_LOAD)
static void lcd_extrude(float length, float feedrate) {
current_position[E_AXIS] += length;
#ifdef DELTA
......@@ -681,7 +679,7 @@ void lcd_preheat_gum0() { _lcd_preheat(0, gumPreheatHotendTemp, gumPreheatHPBTem
}
static void lcd_preheat_gum_menu() {
START_MENU();
START_MENU(lcd_prepare_menu);
MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu);
MENU_ITEM(function, MSG_PREHEAT_GUM " 1", lcd_preheat_gum0);
#if TEMP_SENSOR_1 != 0 //2 extruder preheat
......@@ -703,93 +701,11 @@ void lcd_preheat_gum0() { _lcd_preheat(0, gumPreheatHotendTemp, gumPreheatHPBTem
#endif //more than one extruder present
void lcd_cooldown() {
setTargetHotend0(0);
setTargetHotend1(0);
setTargetHotend2(0);
setTargetHotend3(0);
setTargetBed(0);
disable_all_heaters();
fanSpeed = 0;
lcd_return_to_status();
}
static void config_lcd_level_bed() {
setTargetHotend(0,0);
ECHO_EM("Leveling...");
currentMenu = lcd_level_bed;
enqueuecommands_P(PSTR("G28 M"));
pageShowInfo = 0;
}
static void lcd_level_bed() {
if(ChangeScreen) {
lcd_implementation_clear();
switch(pageShowInfo) {
case 0:
{
LCD_Printpos(0, 1);
lcd_printPGM(PSTR(MSG_LP_INTRO));
currentMenu = lcd_level_bed;
ChangeScreen = false;
}
break;
case 1:
{
LCD_Printpos(0, 1);
lcd_printPGM(PSTR(MSG_LP_1));
currentMenu = lcd_level_bed;
ChangeScreen = false;
}
break;
case 2:
{
LCD_Printpos(0, 1);
lcd_printPGM(PSTR(MSG_LP_2));
currentMenu = lcd_level_bed;
ChangeScreen = false;
}
break;
case 3:
{
LCD_Printpos(0, 1);
lcd_printPGM(PSTR(MSG_LP_3));
currentMenu = lcd_level_bed;
ChangeScreen = false;
}
break;
case 4:
{
LCD_Printpos(0, 1);
lcd_printPGM(PSTR(MSG_LP_4));
currentMenu = lcd_level_bed;
ChangeScreen = false;
}
break;
case 5:
{
LCD_Printpos(0, 1);
lcd_printPGM(PSTR(MSG_LP_5));
currentMenu = lcd_level_bed;
ChangeScreen = false;
}
break;
case 6:
{
LCD_Printpos(2, 2);
lcd_printPGM(PSTR(MSG_LP_6));
ChangeScreen = false;
delay(1200);
encoderPosition = 0;
lcd_implementation_clear();
currentMenu = lcd_status_screen;
lcd_status_screen();
pageShowInfo = 0;
}
break;
}
}
}
/**
*
* "Prepare" submenu
......@@ -812,11 +728,11 @@ static void lcd_prepare_menu() {
//
// Level Bed
//
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS])
MENU_ITEM(gcode, MSG_LEVEL_BED, PSTR("G29"));
#elif DISABLED(DELTA) && DISABLED(Z_SAFE_HOMING)
MENU_ITEM(function, MSG_BED_SETTING, config_lcd_level_bed);
#elif !defined(DELTA) && !defined(Z_SAFE_HOMING) && Z_HOME_DIR < 0
MENU_ITEM(submenu, MSG_MBL_SETTING, config_lcd_level_bed);
#endif
//
......@@ -826,7 +742,7 @@ static void lcd_prepare_menu() {
//MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
//Add Preset menu for LASER setting '14. 7. 22
#if ENABLED(LASERBEAM)
#ifdef LASERBEAM
MENU_ITEM_EDIT(int3, MSG_LASER, &laser_ttl_modulation, 0, 255);
if(laser_ttl_modulation == 0) {
WRITE(LASER_PWR_PIN, LOW);
......@@ -871,7 +787,7 @@ static void lcd_prepare_menu() {
//
// Easy Load
//
#if ENABLED(EASY_LOAD)
#ifdef 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);
......@@ -891,14 +807,14 @@ static void lcd_prepare_menu() {
//
// Autostart
//
#if ENABLED(SDSUPPORT) && ENABLED(MENU_ADDAUTOSTART)
#if defined(SDSUPPORT) && defined(MENU_ADDAUTOSTART)
MENU_ITEM(function, MSG_AUTOSTART, lcd_autostart_sd);
#endif
END_MENU();
}
#if ENABLED(DELTA)
#ifdef DELTA
static void lcd_delta_calibrate_menu() {
START_MENU(lcd_main_menu);
......@@ -1114,14 +1030,14 @@ static void lcd_control_temperature_menu() {
// Fan Speed
//
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
#if ENABLED(IDLE_OOZING_PREVENT)
#ifdef IDLE_OOZING_PREVENT
MENU_ITEM_EDIT(bool, MSG_IDLEOOZING, &idleoozing_enabled);
#endif
//
// Autotemp, Min, Max, Fact
//
#if ENABLED(AUTOTEMP) && (TEMP_SENSOR_0 != 0)
#if defined(AUTOTEMP) && (TEMP_SENSOR_0 != 0)
MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &autotemp_enabled);
MENU_ITEM_EDIT(float3, MSG_MIN, &autotemp_min, 0, HEATER_0_MAXTEMP + LCD_MAX_TEMP_OFFSET);
MENU_ITEM_EDIT(float3, MSG_MAX, &autotemp_max, 0, HEATER_0_MAXTEMP + LCD_MAX_TEMP_OFFSET);
......@@ -1131,7 +1047,7 @@ static void lcd_control_temperature_menu() {
//
// PID-P, PID-I, PID-D
//
#if ENABLED(PIDTEMP)
#ifdef PIDTEMP
// set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(PID_PARAM(Ki,0));
raw_Kd = unscalePID_d(PID_PARAM(Kd,0));
......@@ -1288,10 +1204,10 @@ static void lcd_control_motion_menu() {
#if EXTRUDERS > 3
MENU_ITEM_EDIT(float51, MSG_E3STEPS, &axis_steps_per_unit[E_AXIS+3], 5, 9999);
#endif
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
MENU_ITEM_EDIT(bool, MSG_ENDSTOP_ABORT, &abort_on_endstop_hit);
#endif
#if ENABLED(SCARA)
#ifdef SCARA
MENU_ITEM_EDIT(float52, MSG_XSCALE, &axis_scaling[X_AXIS],0.5,2);
MENU_ITEM_EDIT(float52, MSG_YSCALE, &axis_scaling[Y_AXIS],0.5,2);
#endif
......@@ -1380,7 +1296,7 @@ static void lcd_control_volumetric_menu() {
}
#endif // FWRETRACT
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
#if SDCARDDETECT == -1
static void lcd_sd_refresh() {
card.initsd();
......@@ -1570,7 +1486,7 @@ static void menu_action_submenu(menuFunc_t func) { lcd_goto_menu(func); }
static void menu_action_gcode(const char* pgcode) { enqueuecommands_P(pgcode); }
static void menu_action_function(menuFunc_t func) { (*func)(); }
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
static void menu_action_sdfile(const char* filename, char* longFilename) {
char cmd[30];
char* c;
......@@ -1630,7 +1546,7 @@ void lcd_init() {
#endif // SR_LCD_2W_NL
#endif//!NEWPANEL
#if ENABLED(SDSUPPORT) && ENABLED(SDCARDDETECT) && (SDCARDDETECT > 0)
#if defined(SDSUPPORT) && defined(SDCARDDETECT) && (SDCARDDETECT > 0)
pinMode(SDCARDDETECT, INPUT);
WRITE(SDCARDDETECT, HIGH);
lcd_oldcardstatus = IS_SD_INSERTED;
......@@ -1743,7 +1659,7 @@ void lcd_update() {
if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100;
else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10;
#if ENABLED(ENCODER_RATE_MULTIPLIER_DEBUG)
#ifdef ENCODER_RATE_MULTIPLIER_DEBUG
ECHO_SMV(DB, "Enc Step Rate: ", encoderStepRate);
ECHO_MV(" Multiplier: ", encoderMultiplier);
ECHO_MV(" ENCODER_10X_STEPS_PER_SEC: ", ENCODER_10X_STEPS_PER_SEC);
......@@ -1794,10 +1710,18 @@ void lcd_update() {
#endif
#ifdef ULTIPANEL
if (currentMenu != lcd_status_screen && millis() > return_to_status_ms) {
// Return to Status Screen after a timeout
if (currentMenu != lcd_status_screen &&
#if !defined(DELTA) && !defined(Z_SAFE_HOMING) && Z_HOME_DIR < 0
currentMenu != lcd_level_bed &&
#endif
millis() > return_to_status_ms
) {
lcd_return_to_status();
lcdDrawUpdate = 2;
}
#endif // ULTIPANEL
if (lcdDrawUpdate == 2) lcd_implementation_clear();
......@@ -1825,7 +1749,7 @@ void lcd_finishstatus(bool persist=false) {
#endif
}
#if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
#if defined(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
void dontExpireStatus() { expire_status_ms = 0; }
#endif
......@@ -1894,7 +1818,7 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
void lcd_buttons_update() {
#ifdef NEWPANEL
uint8_t newbutton = 0;
#if ENABLED(INVERT_ROTARY_SWITCH)
#ifdef INVERT_ROTARY_SWITCH
if (READ(BTN_EN1) == 0) newbutton |= EN_B;
if (READ(BTN_EN2) == 0) newbutton |= EN_A;
#else
......@@ -1967,7 +1891,7 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
}
bool lcd_detected(void) {
#if (ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008)) && ENABLED(DETECT_DEVICE)
#if (defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008)) && defined(DETECT_DEVICE)
return lcd.LcdDetected() == 1;
#else
return true;
......@@ -2270,5 +2194,66 @@ char *ftostr52(const float &x) {
return conv;
}
#if !defined(DELTA) && !defined(Z_SAFE_HOMING) && Z_HOME_DIR < 0
static void lcd_level_bed() {
switch(pageShowInfo) {
case 0:
{
LCD_Printpos(0, 0); lcd_printPGM(PSTR(MSG_MBL_INTRO));
LCD_Printpos(0, 1); lcd_printPGM(PSTR(MSG_MBL_BUTTON));
}
break;
case 1:
{
LCD_Printpos(0, 0); lcd_printPGM(PSTR(MSG_MBL_1));
LCD_Printpos(0, 1); lcd_printPGM(PSTR(MSG_MBL_BUTTON));
}
break;
case 2:
{
LCD_Printpos(0, 0); lcd_printPGM(PSTR(MSG_MBL_2));
LCD_Printpos(0, 1); lcd_printPGM(PSTR(MSG_MBL_BUTTON));
}
break;
case 3:
{
LCD_Printpos(0, 0); lcd_printPGM(PSTR(MSG_MBL_3));
LCD_Printpos(0, 1); lcd_printPGM(PSTR(MSG_MBL_BUTTON));
}
break;
case 4:
{
LCD_Printpos(0, 0); lcd_printPGM(PSTR(MSG_MBL_4));
LCD_Printpos(0, 1); lcd_printPGM(PSTR(MSG_MBL_BUTTON));
}
break;
case 5:
{
LCD_Printpos(0, 0); lcd_printPGM(PSTR(MSG_MBL_5));
LCD_Printpos(0, 1); lcd_printPGM(PSTR(MSG_MBL_BUTTON));
}
break;
case 6:
{
LCD_Printpos(0, 0); lcd_printPGM(PSTR(MSG_MBL_6));
LCD_Printpos(0, 1); lcd_printPGM(PSTR(" "));
delay(5000);
enqueuecommands_P(PSTR("G28"));
lcd_return_to_status();
}
break;
}
}
static void config_lcd_level_bed() {
ECHO_EM(MSG_MBL_SETTING);
enqueuecommands_P(PSTR("G28 M"));
pageShowInfo = 0;
lcd_goto_menu(lcd_level_bed);
}
#endif
#endif //ULTRA_LCD
......@@ -3,7 +3,7 @@
#include "Marlin.h"
#if ENABLED(ULTRA_LCD)
#ifdef ULTRA_LCD
int lcd_strlen(char *s);
int lcd_strlen_P(const char *s);
void lcd_update();
......@@ -15,17 +15,18 @@
void lcd_reset_alert_level();
bool lcd_detected(void);
#if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
#if defined(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
void dontExpireStatus();
#endif
#if ENABLED(DOGLCD) && LCD_CONTRAST >= 0
#if defined(DOGLCD) && LCD_CONTRAST >= 0
extern int lcd_contrast;
void lcd_setcontrast(uint8_t value);
#endif
#if !defined(DELTA) && !defined(Z_SAFE_HOMING) && Z_HOME_DIR < 0
void set_pageShowInfo(int value);
void set_ChangeScreen(boolean state);
#endif
#define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x))
#define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x))
......@@ -33,10 +34,10 @@
#define LCD_UPDATE_INTERVAL 100
#define LCD_TIMEOUT_TO_STATUS 15000
#if ENABLED(ULTIPANEL)
#ifdef ULTIPANEL
void lcd_buttons_update();
extern volatile uint8_t buttons; //the last checked buttons in a bit array.
#if ENABLED(REPRAPWORLD_KEYPAD)
#ifdef REPRAPWORLD_KEYPAD
extern volatile uint8_t buttons_reprapworld_keypad; // to store the keypad shift register values
#endif
#else
......@@ -65,17 +66,17 @@
void lcd_ignore_click(bool b=true);
#if ENABLED(NEWPANEL)
#ifdef NEWPANEL
#define EN_C BIT(BLEN_C)
#define EN_B BIT(BLEN_B)
#define EN_A BIT(BLEN_A)
#define LCD_CLICKED (buttons&EN_C)
#if ENABLED(BTN_BACK) && BTN_BACK > 0
#if defined(BTN_BACK) && BTN_BACK > 0
#define EN_D BIT(BLEN_D)
#define LCD_BACK_CLICKED (buttons&EN_D)
#endif
#if ENABLED(REPRAPWORLD_KEYPAD)
#ifdef REPRAPWORLD_KEYPAD
#define EN_REPRAPWORLD_KEYPAD_F3 (BIT(BLEN_REPRAPWORLD_KEYPAD_F3))
#define EN_REPRAPWORLD_KEYPAD_F2 (BIT(BLEN_REPRAPWORLD_KEYPAD_F2))
#define EN_REPRAPWORLD_KEYPAD_F1 (BIT(BLEN_REPRAPWORLD_KEYPAD_F1))
......
......@@ -19,7 +19,7 @@
// macro name. The mapping is independent of whether the button is directly connected or
// via a shift/i2c register.
#if ENABLED(ULTIPANEL)
#ifdef ULTIPANEL
// All UltiPanels might have an encoder - so this is always be mapped onto first two bits
#define BLEN_B 1
#define BLEN_A 0
......@@ -41,7 +41,7 @@
//
// Setup other button mappings of each panel
//
#if ENABLED(LCD_I2C_VIKI)
#if defined(LCD_I2C_VIKI)
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
// button and encoder bit positions within 'buttons'
......@@ -62,7 +62,7 @@
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
#define LCD_HAS_SLOW_BUTTONS
#elif ENABLED(LCD_I2C_PANELOLU2)
#elif defined(LCD_I2C_PANELOLU2)
// encoder click can be read through I2C if not directly connected
#if BTN_ENC <= 0
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
......@@ -77,7 +77,7 @@
#define LCD_CLICKED (buttons&EN_C)
#endif
#elif ENABLED(REPRAPWORLD_KEYPAD)
#elif defined(REPRAPWORLD_KEYPAD)
// define register bit values, don't change it
#define BLEN_REPRAPWORLD_KEYPAD_F3 0
#define BLEN_REPRAPWORLD_KEYPAD_F2 1
......@@ -104,7 +104,7 @@
//#define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons&EN_REPRAPWORLD_KEYPAD_UP)
//#define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons&EN_REPRAPWORLD_KEYPAD_MIDDLE)
#elif ENABLED(NEWPANEL)
#elif defined(NEWPANEL)
#define LCD_CLICKED (buttons&EN_C)
#if HAS_BTN_BACK
#define LCD_BACK_CLICKED (buttons&EN_D)
......@@ -135,7 +135,7 @@
////////////////////////////////////
// Create LCD class instance and chipset-specific information
#if ENABLED(LCD_I2C_TYPE_PCF8575)
#if defined(LCD_I2C_TYPE_PCF8575)
// note: these are register mapped pins on the PCF8575 controller not Arduino pins
#define LCD_I2C_PIN_BL 3
#define LCD_I2C_PIN_EN 2
......@@ -152,7 +152,7 @@
#define LCD_CLASS LiquidCrystal_I2C
LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7);
#elif ENABLED(LCD_I2C_TYPE_MCP23017)
#elif defined(LCD_I2C_TYPE_MCP23017)
//for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators())
#define LED_A 0x04 //100
#define LED_B 0x02 //010
......@@ -163,30 +163,30 @@
#include <Wire.h>
#include <LiquidTWI2.h>
#define LCD_CLASS LiquidTWI2
#if ENABLED(DETECT_DEVICE)
#if defined(DETECT_DEVICE)
LCD_CLASS lcd(LCD_I2C_ADDRESS, 1);
#else
LCD_CLASS lcd(LCD_I2C_ADDRESS);
#endif
#elif ENABLED(LCD_I2C_TYPE_MCP23008)
#elif defined(LCD_I2C_TYPE_MCP23008)
#include <Wire.h>
#include <LiquidTWI2.h>
#define LCD_CLASS LiquidTWI2
#if ENABLED(DETECT_DEVICE)
#if defined(DETECT_DEVICE)
LCD_CLASS lcd(LCD_I2C_ADDRESS, 1);
#else
LCD_CLASS lcd(LCD_I2C_ADDRESS);
#endif
#elif ENABLED(LCD_I2C_TYPE_PCA8574)
#elif defined(LCD_I2C_TYPE_PCA8574)
#include <LiquidCrystal_I2C.h>
#define LCD_CLASS LiquidCrystal_I2C
LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT);
// 2 wire Non-latching LCD SR from:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
#elif ENABLED(SR_LCD_2W_NL)
#elif defined(SR_LCD_2W_NL)
extern "C" void __cxa_pure_virtual() { while (1); }
#include <LCD.h>
#include <LiquidCrystal_SR.h>
......@@ -201,7 +201,7 @@
#include "utf_mapper.h"
#if ENABLED(LCD_PROGRESS_BAR)
#ifdef LCD_PROGRESS_BAR
static millis_t progress_bar_ms = 0;
#if PROGRESS_MSG_EXPIRE > 0
static millis_t expire_status_ms = 0;
......@@ -210,11 +210,11 @@
#endif
static void lcd_set_custom_characters(
#if ENABLED(LCD_PROGRESS_BAR)
#ifdef LCD_PROGRESS_BAR
bool progress_bar_set=true
#endif
) {
#if ENABLED(DELTA)
#ifdef DELTA
byte bedTemp[8] =
{
B00000,
......@@ -312,7 +312,7 @@ static void lcd_set_custom_characters(
B00000
}; //thanks Sonny Mounicou
#if ENABLED(LCD_PROGRESS_BAR)
#ifdef LCD_PROGRESS_BAR
static bool char_mode = false;
byte progress[3][8] = { {
B00000,
......@@ -373,28 +373,28 @@ static void lcd_set_custom_characters(
}
static void lcd_implementation_init(
#if ENABLED(LCD_PROGRESS_BAR)
#ifdef LCD_PROGRESS_BAR
bool progress_bar_set=true
#endif
) {
#if ENABLED(LCD_I2C_TYPE_PCF8575)
#if defined(LCD_I2C_TYPE_PCF8575)
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
#ifdef LCD_I2C_PIN_BL
lcd.setBacklightPin(LCD_I2C_PIN_BL, POSITIVE);
lcd.setBacklight(HIGH);
#endif
#elif ENABLED(LCD_I2C_TYPE_MCP23017)
#elif defined(LCD_I2C_TYPE_MCP23017)
lcd.setMCPType(LTI_TYPE_MCP23017);
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
lcd.setBacklight(0); //set all the LEDs off to begin with
#elif ENABLED(LCD_I2C_TYPE_MCP23008)
#elif defined(LCD_I2C_TYPE_MCP23008)
lcd.setMCPType(LTI_TYPE_MCP23008);
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
#elif ENABLED(LCD_I2C_TYPE_PCA8574)
#elif defined(LCD_I2C_TYPE_PCA8574)
lcd.init();
lcd.backlight();
......@@ -408,7 +408,7 @@ static void lcd_implementation_init(
#endif
lcd_set_custom_characters(
#if ENABLED(LCD_PROGRESS_BAR)
#ifdef LCD_PROGRESS_BAR
progress_bar_set
#endif
);
......@@ -530,7 +530,7 @@ static void lcd_implementation_status_screen() {
#if LCD_WIDTH < 20
#if ENABLED(SDSUPPORT)
#ifdef SDSUPPORT
lcd.setCursor(0, 2);
lcd_printPGM(PSTR("SD"));
if (IS_SD_PRINTING)
......@@ -550,38 +550,27 @@ static void lcd_implementation_status_screen() {
// show the heated bed temp on the left,
// since the first line is filled with extruder temps
LCD_TEMP(degBed(), degTargetBed(), LCD_STR_BEDTEMP[0]);
#else
lcd.print('X');
if (axis_known_position[X_AXIS])
#ifdef DELTA
lcd.print('X');
lcd.print(ftostr30(current_position[X_AXIS]));
#else
lcd.print(ftostr3(current_position[X_AXIS]));
#endif
else
lcd_printPGM(PSTR("---"));
lcd_printPGM(PSTR(" Y"));
if (axis_known_position[Y_AXIS])
#ifdef DELTA
lcd.print(ftostr30(current_position[Y_AXIS]));
#else
lcd.print('X');
lcd.print(ftostr3(current_position[X_AXIS]));
lcd_printPGM(PSTR(" Y"));
lcd.print(ftostr3(current_position[Y_AXIS]));
#endif
else
lcd_printPGM(PSTR("---"));
#endif // DELTA
#endif // HOTENDS > 1 || TEMP_SENSOR_BED != 0
#endif // LCD_WIDTH >= 20
lcd.setCursor(LCD_WIDTH - 8, 1);
lcd.print('Z');
if (axis_known_position[Z_AXIS])
lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001));
else
lcd_printPGM(PSTR("---.--"));
#endif // LCD_HEIGHT > 2
......@@ -596,7 +585,7 @@ static void lcd_implementation_status_screen() {
lcd.print(itostr3(feedrate_multiplier));
lcd.print('%');
#if LCD_WIDTH > 19 && ENABLED(SDSUPPORT)
#if LCD_WIDTH > 19 && defined(SDSUPPORT)
lcd.setCursor(7, 2);
lcd_printPGM(PSTR("SD"));
......@@ -643,7 +632,7 @@ static void lcd_implementation_status_screen() {
lcd.setCursor(0, LCD_HEIGHT - 1);
#if ENABLED(LCD_PROGRESS_BAR)
#ifdef LCD_PROGRESS_BAR
if (card.isFileOpen()) {
// Draw the progress bar if the message has shown long enough
......@@ -800,10 +789,10 @@ static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const
#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
#if ENABLED(LCD_HAS_STATUS_INDICATORS)
#ifdef LCD_HAS_STATUS_INDICATORS
static void lcd_implementation_update_indicators() {
#if ENABLED(LCD_I2C_PANELOLU2) || ENABLED(LCD_I2C_VIKI)
#if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI)
// Set the LEDS - referred to as backlights by the LiquidTWI2 library
static uint8_t ledsprev = 0;
uint8_t leds = 0;
......@@ -822,17 +811,17 @@ static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const
#endif // LCD_HAS_STATUS_INDICATORS
#if ENABLED(LCD_HAS_SLOW_BUTTONS)
#ifdef LCD_HAS_SLOW_BUTTONS
extern millis_t next_button_update_ms;
static uint8_t lcd_implementation_read_slow_buttons() {
#if ENABLED(LCD_I2C_TYPE_MCP23017)
#ifdef LCD_I2C_TYPE_MCP23017
uint8_t slow_buttons;
// Reading these buttons this is likely to be too slow to call inside interrupt context
// so they are called during normal lcd_update
slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET;
#if ENABLED(LCD_I2C_VIKI)
#ifdef LCD_I2C_VIKI
if ((slow_buttons & (B_MI|B_RI)) && millis() < next_button_update_ms) // LCD clicked
slow_buttons &= ~(B_MI|B_RI); // Disable LCD clicked buttons if screen is updated
#endif
......
......@@ -3,7 +3,7 @@
#include "Marlin.h"
#if ENABLED(U8GLIB_ST7920)
#ifdef U8GLIB_ST7920
//set optimization so ARDUINO optimizes this file
#pragma GCC optimize (3)
......
......@@ -3,23 +3,23 @@
#include "language.h"
#if ENABLED(DOGLCD)
#ifdef DOGLCD
#define HARDWARE_CHAR_OUT u8g.print
#else
#define HARDWARE_CHAR_OUT lcd.write
#endif
#if DISABLED(SIMULATE_ROMFONT) && ENABLED(DOGLCD)
#if ENABLED(DISPLAY_CHARSET_ISO10646_1)
#if !(defined( SIMULATE_ROMFONT )) && defined( DOGLCD )
#if defined( DISPLAY_CHARSET_ISO10646_1 )
#define MAPPER_ONE_TO_ONE
#elif ENABLED(DISPLAY_CHARSET_ISO10646_5)
#elif defined( DISPLAY_CHARSET_ISO10646_5 )
#define MAPPER_ONE_TO_ONE
#elif ENABLED(DISPLAY_CHARSET_ISO10646_KANA)
#elif defined( DISPLAY_CHARSET_ISO10646_KANA )
#define MAPPER_ONE_TO_ONE
#endif
#else // SIMULATE_ROMFONT
#if ENABLED(DISPLAY_CHARSET_HD44780_JAPAN)
#if ENABLED(MAPPER_C2C3)
#if defined( DISPLAY_CHARSET_HD44780_JAPAN )
#if defined( MAPPER_C2C3 )
const PROGMEM uint8_t utf_recode[] =
{ // 0 1 2 3 4 5 6 7 8 9 a b c d e f This is fair for symbols
0x20,0x3f,0xec,0xed,0x3f,0x5c,0x7c,0x3f,0x22,0x63,0x61,0x7f,0x3f,0x3f,0x52,0xb0, // c2a
......@@ -35,7 +35,7 @@
0x3f,0xee,0x3f,0x3f,0x3f,0x3f,0xef,0xfd,0x3f,0x3f,0x3f,0x3f,0xf5,0x3f,0x3f,0x3f // c3b
// n ö ÷ ü
};
#elif ENABLED(MAPPER_E382E383)
#elif defined( MAPPER_E382E383 )
const PROGMEM uint8_t utf_recode[] =
{ // 0 1 2 3 4 5 6 7 8 9 a b c d e f
0x3d,0xb1,0xb1,0xa8,0xb2,0xa9,0xb3,0xaa,0xb4,0xab,0xb5,0xb6,0xb6,0xb7,0xb7,0xb8, // e382a Please test and correct
......@@ -51,12 +51,12 @@
0xec,0xa7,0xa6,0xdd,0xcc,0x3f,0x3f,0x3f,0x3f,0x3f,0xa6,0xa5,0xb0,0xa4,0xa4,0x3f // e383b
// ヰ ヱ ヲ ン フ ? ? ? ? ? ヲ ・ ー ヽ ヽ ?
};
#elif ENABLED(MAPPER_D0D1)
#elif defined( MAPPER_D0D1 )
#error( "Cyrillic on a japanese dsplay makes no sense. There are no matching symbols.");
#endif
#elif ENABLED(DISPLAY_CHARSET_HD44780_WESTERN)
#if ENABLED(MAPPER_C2C3)
#elif defined( DISPLAY_CHARSET_HD44780_WESTERN )
#if defined( MAPPER_C2C3 )
:
const PROGMEM uint8_t utf_recode[] =
{ // 0 1 2 3 4 5 6 7 8 9 a b c d e f This is relative complete.
......@@ -73,7 +73,7 @@
0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff // c3b ðñóôõö÷øùúûüýþÿ
// ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ
};
#elif ENABLED(MAPPER_D0D1)
#elif defined( MAPPER_D0D1 )
#define MAPPER_D0D1_MOD
const PROGMEM uint8_t utf_recode[] =
{//0 1 2 3 4 5 6 7 8 9 a b c d e f
......@@ -86,12 +86,12 @@
0x70,0x63,0x54,0x79,0xd8,0x78,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x62,0x8f,0xac,0xad // d19
// p c T y Ф x Ч ч Ш Щ Ъ Ы b Э Ю Я
};
#elif ENABLED(MAPPER_E382E383)
#elif defined( MAPPER_E382E383 )
#error( "Katakana on a western display makes no sense. There are no matching symbols." );
#endif
#elif ENABLED(DISPLAY_CHARSET_HD44780_CYRILLIC)
#if ENABLED(MAPPER_D0D1)
#elif defined( DISPLAY_CHARSET_HD44780_CYRILLIC )
#if defined( MAPPER_D0D1 )
#define MAPPER_D0D1_MOD
// it is a Russian alphabet translation
// except 0401 --> 0xa2 = Ё, 0451 --> 0xb5 = ё
......@@ -113,9 +113,9 @@
0xc1,0xe6,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7 // Ѫ ѩ Ѫ ѫ Ѭ ѭ Ѯ ѯ
// ш щ ъ ы ь э ю я // 7 Ѱ ѱ Ѳ ѳ Ѵ ѵ Ѷ ѷ
}; // ѻ ѹ Ѻ ѻ Ѽ ѽ Ѿ ѿ
#elif ENABLED(MAPPER_C2C3)
#elif defined( MAPPER_C2C3 )
#error( "Western languages on a cyrillic display makes no sense. There are no matching symbols." );
#elif ENABLED(MAPPER_E382E383)
#elif defined( MAPPER_E382E383 )
#error( "Katakana on a cyrillic display makes no sense. There are no matching symbols." );
#endif
#else
......@@ -123,12 +123,12 @@
#endif // DISPLAY_CHARSET_HD44780_CYRILLIC
#endif // SIMULATE_ROMFONT
#if ENABLED(MAPPER_NON)
#if defined( MAPPER_NON )
char charset_mapper(char c){
HARDWARE_CHAR_OUT( c );
return 1;
}
#elif ENABLED(MAPPER_C2C3)
#elif defined( MAPPER_C2C3 )
uint8_t utf_hi_char; // UTF-8 high part
bool seen_c2 = false;
char charset_mapper(char c){
......@@ -157,7 +157,7 @@
seen_c2 = false;
return 1;
}
#elif ENABLED(MAPPER_D0D1_MOD)
#elif defined( MAPPER_D0D1_MOD )
uint8_t utf_hi_char; // UTF-8 high part
bool seen_d5 = false;
char charset_mapper(char c){
......@@ -188,7 +188,7 @@
seen_d5 = false;
return 1;
}
#elif ENABLED(MAPPER_D0D1)
#elif defined( MAPPER_D0D1 )
uint8_t utf_hi_char; // UTF-8 high part
bool seen_d5 = false;
char charset_mapper(char c){
......@@ -214,7 +214,7 @@
seen_d5 = false;
return 1;
}
#elif ENABLED(MAPPER_E382E383)
#elif defined( MAPPER_E382E383 )
uint8_t utf_hi_char; // UTF-8 high part
bool seen_e3 = false;
bool seen_82_83 = false;
......
......@@ -19,7 +19,7 @@
#include <math.h>
#include "Marlin.h"
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
#include "vector_3.h"
vector_3::vector_3() : x(0), y(0), z(0) { }
......
......@@ -19,7 +19,7 @@
#ifndef VECTOR_3_H
#define VECTOR_3_H
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#ifdef ENABLE_AUTO_BED_LEVELING
class matrix_3x3;
struct vector_3
......
#include "Marlin.h"
#if ENABLED(USE_WATCHDOG)
#ifdef USE_WATCHDOG
#include <avr/wdt.h>
#include "watchdog.h"
......@@ -18,15 +18,15 @@
/// intialise watch dog with a 4 sec interrupt time
void watchdog_init()
{
#if ENABLED(WATCHDOG_RESET_MANUAL)
#ifdef WATCHDOG_RESET_MANUAL
//We enable the watchdog timer, but only for the interrupt.
//Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details.
wdt_reset();
_WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE);
_WD_CONTROL_REG = _BV(WDIE) | WDTO_4S;
#else
#else
wdt_enable(WDTO_4S);
#endif
#endif
}
/// reset watchdog. MUST be called every 1s after init or avr will reset.
......@@ -40,7 +40,7 @@ void watchdog_reset()
//===========================================================================
// Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
#if ENABLED(WATCHDOG_RESET_MANUAL)
#ifdef WATCHDOG_RESET_MANUAL
ISR(WDT_vect) {
ECHO_LM(ER, MSG_WATCHDOG_RESET);
kill(PSTR("ERR:Please Reset")); // kill blocks //16 characters so it fits on a 16x2 display
......
......@@ -3,7 +3,7 @@
#include "Marlin.h"
#if ENABLED(USE_WATCHDOG)
#ifdef USE_WATCHDOG
// initialize watch dog with a 1 sec interrupt time
void watchdog_init();
// pad the dog/reset watchdog. MUST be called at least every second after the first watchdog_init or AVR will go into emergency procedures..
......
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