Group all universal variables

This commit is contained in:
Scott Lahteine 2015-04-03 15:45:41 -07:00
parent 21cd2e4fae
commit 6b919e14c1

View File

@ -202,10 +202,6 @@
#endif #endif
float homing_feedrate[] = HOMING_FEEDRATE; float homing_feedrate[] = HOMING_FEEDRATE;
#ifdef ENABLE_AUTO_BED_LEVELING
int xy_travel_speed = XY_TRAVEL_SPEED;
float zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
#endif
int homing_bump_divisor[] = HOMING_BUMP_DIVISOR; int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
bool axis_relative_modes[] = AXIS_RELATIVE_MODES; bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
int feedmultiply = 100; //100->1 200->2 int feedmultiply = 100; //100->1 200->2
@ -216,15 +212,49 @@ float filament_size[EXTRUDERS] = ARRAY_BY_EXTRUDERS(DEFAULT_NOMINAL_FILAMENT_DIA
float volumetric_multiplier[EXTRUDERS] = ARRAY_BY_EXTRUDERS(1.0, 1.0, 1.0, 1.0); float volumetric_multiplier[EXTRUDERS] = ARRAY_BY_EXTRUDERS(1.0, 1.0, 1.0, 1.0);
float current_position[NUM_AXIS] = { 0.0 }; float current_position[NUM_AXIS] = { 0.0 };
float home_offset[3] = { 0 }; float home_offset[3] = { 0 };
#ifdef DELTA
float endstop_adj[3] = { 0 };
#elif defined(Z_DUAL_ENDSTOPS)
float z_endstop_adj = 0;
#endif
float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }; float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS }; float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
bool axis_known_position[3] = { false }; bool axis_known_position[3] = { false };
uint8_t active_extruder = 0;
int fanSpeed = 0;
bool cancel_heatup = false;
const char errormagic[] PROGMEM = "Error:";
const char echomagic[] PROGMEM = "echo:";
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
static float destination[NUM_AXIS] = { 0 };
static float offset[3] = { 0 };
static float feedrate = 1500.0, next_feedrate, saved_feedrate;
static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
static bool relative_mode = false; //Determines Absolute or Relative Coordinates
static char cmdbuffer[BUFSIZE][MAX_CMD_SIZE];
static int bufindr = 0;
static int bufindw = 0;
static int buflen = 0;
static char serial_char;
static int serial_count = 0;
static boolean comment_mode = false;
static char *strchr_pointer; ///< A pointer to find chars in the command string (X, Y, Z, E, etc.)
const char* queued_commands_P= NULL; /* pointer to the current line in the active sequence of commands, or NULL when none */
const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42
// Inactivity shutdown
static unsigned long previous_millis_cmd = 0;
static unsigned long max_inactive_time = 0;
static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
unsigned long starttime = 0; ///< Print job start time
unsigned long stoptime = 0; ///< Print job stop time
static uint8_t tmp_extruder;
bool Stopped = false;
bool CooldownNoWait = true;
bool target_direction;
#ifdef ENABLE_AUTO_BED_LEVELING
int xy_travel_speed = XY_TRAVEL_SPEED;
float zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
#endif
#if defined(Z_DUAL_ENDSTOPS) && !defined(DELTA)
float z_endstop_adj = 0;
#endif
// Extruder offsets // Extruder offsets
#if EXTRUDERS > 1 #if EXTRUDERS > 1
@ -243,9 +273,6 @@ bool axis_known_position[3] = { false };
}; };
#endif #endif
uint8_t active_extruder = 0;
int fanSpeed = 0;
#ifdef SERVO_ENDSTOPS #ifdef SERVO_ENDSTOPS
int servo_endstops[] = SERVO_ENDSTOPS; int servo_endstops[] = SERVO_ENDSTOPS;
int servo_endstop_angles[] = SERVO_ENDSTOP_ANGLES; int servo_endstop_angles[] = SERVO_ENDSTOP_ANGLES;
@ -282,33 +309,36 @@ int fanSpeed = 0;
; ;
#endif #endif
#ifdef DELTA #if defined(DELTA) || defined(SCARA)
float delta[3] = { 0, 0, 0 }; static float delta[3] = { 0, 0, 0 };
#define SIN_60 0.8660254037844386 #ifdef DELTA
#define COS_60 0.5 #define SIN_60 0.8660254037844386
// these are the default values, can be overriden with M665 #define COS_60 0.5
float delta_radius = DELTA_RADIUS; float endstop_adj[3] = { 0 };
float delta_tower1_x = -SIN_60 * delta_radius; // front left tower // these are the default values, can be overriden with M665
float delta_tower1_y = -COS_60 * delta_radius; float delta_radius = DELTA_RADIUS;
float delta_tower2_x = SIN_60 * delta_radius; // front right tower float delta_tower1_x = -SIN_60 * delta_radius; // front left tower
float delta_tower2_y = -COS_60 * delta_radius; float delta_tower1_y = -COS_60 * delta_radius;
float delta_tower3_x = 0; // back middle tower float delta_tower2_x = SIN_60 * delta_radius; // front right tower
float delta_tower3_y = delta_radius; float delta_tower2_y = -COS_60 * delta_radius;
float delta_diagonal_rod = DELTA_DIAGONAL_ROD; float delta_tower3_x = 0; // back middle tower
float delta_diagonal_rod_2 = sq(delta_diagonal_rod); float delta_tower3_y = delta_radius;
float delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND; float delta_diagonal_rod = DELTA_DIAGONAL_ROD;
#ifdef ENABLE_AUTO_BED_LEVELING float delta_diagonal_rod_2 = sq(delta_diagonal_rod);
int delta_grid_spacing[2] = { 0, 0 }; float delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
float bed_level[AUTO_BED_LEVELING_GRID_POINTS][AUTO_BED_LEVELING_GRID_POINTS]; #ifdef ENABLE_AUTO_BED_LEVELING
int delta_grid_spacing[2] = { 0, 0 };
float bed_level[AUTO_BED_LEVELING_GRID_POINTS][AUTO_BED_LEVELING_GRID_POINTS];
#endif
#endif #endif
#endif
#ifdef SCARA #ifdef SCARA
float axis_scaling[3] = { 1, 1, 1 }; // Build size scaling, default to 1 float axis_scaling[3] = { 1, 1, 1 }; // Build size scaling, default to 1
static float delta[3] = { 0, 0, 0 }; #endif
#endif
bool cancel_heatup = false; #elif !defined(DELTA)
static bool home_all_axis = true;
#endif
#ifdef FILAMENT_SENSOR #ifdef FILAMENT_SENSOR
//Variables for Filament Sensor input //Variables for Filament Sensor input
@ -326,67 +356,21 @@ bool cancel_heatup = false;
static bool filrunoutEnqued = false; static bool filrunoutEnqued = false;
#endif #endif
const char errormagic[] PROGMEM = "Error:";
const char echomagic[] PROGMEM = "echo:";
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
static float destination[NUM_AXIS] = { 0 };
static float offset[3] = { 0 };
#ifndef DELTA
static bool home_all_axis = true;
#endif
static float feedrate = 1500.0, next_feedrate, saved_feedrate;
static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
static bool relative_mode = false; //Determines Absolute or Relative Coordinates
static char cmdbuffer[BUFSIZE][MAX_CMD_SIZE];
#ifdef SDSUPPORT #ifdef SDSUPPORT
static bool fromsd[BUFSIZE]; static bool fromsd[BUFSIZE];
#endif #endif
static int bufindr = 0;
static int bufindw = 0;
static int buflen = 0;
static char serial_char;
static int serial_count = 0;
static boolean comment_mode = false;
static char *strchr_pointer; ///< A pointer to find chars in the command string (X, Y, Z, E, etc.)
const char* queued_commands_P= NULL; /* pointer to the current line in the active sequence of commands, or NULL when none */
const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42
// Inactivity shutdown
static unsigned long previous_millis_cmd = 0;
static unsigned long max_inactive_time = 0;
static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l;
unsigned long starttime = 0; ///< Print job start time
unsigned long stoptime = 0; ///< Print job stop time
static uint8_t tmp_extruder;
bool Stopped = false;
#if NUM_SERVOS > 0 #if NUM_SERVOS > 0
Servo servos[NUM_SERVOS]; Servo servos[NUM_SERVOS];
#endif #endif
bool CooldownNoWait = true;
bool target_direction;
#ifdef CHDK #ifdef CHDK
unsigned long chdkHigh = 0; unsigned long chdkHigh = 0;
boolean chdkActive = false; boolean chdkActive = false;
#endif #endif
//=========================================================================== //===========================================================================
//=============================Routines====================================== //================================ Functions ================================
//=========================================================================== //===========================================================================
void get_arc_coordinates(); void get_arc_coordinates();
@ -5707,21 +5691,11 @@ void disable_all_axes() {
*/ */
void manage_inactivity(bool ignore_stepper_queue/*=false*/) { void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
#if HAS_KILL
static int killCount = 0; // make the inactivity button a bit less responsive
const int KILL_DELAY = 750;
#endif
#if HAS_FILRUNOUT #if HAS_FILRUNOUT
if (card.sdprinting && !(READ(FILRUNOUT_PIN) ^ FIL_RUNOUT_INVERTING)) if (card.sdprinting && !(READ(FILRUNOUT_PIN) ^ FIL_RUNOUT_INVERTING))
filrunout(); filrunout();
#endif #endif
#if HAS_HOME
static int homeDebounceCount = 0; // poor man's debouncing count
const int HOME_DEBOUNCE_DELAY = 750;
#endif
if (buflen < BUFSIZE - 1) get_command(); if (buflen < BUFSIZE - 1) get_command();
unsigned long ms = millis(); unsigned long ms = millis();
@ -5744,6 +5718,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
// Check if the kill button was pressed and wait just in case it was an accidental // Check if the kill button was pressed and wait just in case it was an accidental
// key kill key press // key kill key press
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
static int killCount = 0; // make the inactivity button a bit less responsive
const int KILL_DELAY = 750;
if (!READ(KILL_PIN)) if (!READ(KILL_PIN))
killCount++; killCount++;
else if (killCount > 0) else if (killCount > 0)
@ -5758,6 +5734,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
#if HAS_HOME #if HAS_HOME
// Check to see if we have to home, use poor man's debouncer // Check to see if we have to home, use poor man's debouncer
// --------------------------------------------------------- // ---------------------------------------------------------
static int homeDebounceCount = 0; // poor man's debouncing count
const int HOME_DEBOUNCE_DELAY = 750;
if (!READ(HOME_PIN)) { if (!READ(HOME_PIN)) {
if (!homeDebounceCount) { if (!homeDebounceCount) {
enquecommands_P(PSTR("G28")); enquecommands_P(PSTR("G28"));
@ -5797,7 +5775,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
if (delayed_move_time && ms > delayed_move_time + 1000 && !Stopped) { if (delayed_move_time && ms > delayed_move_time + 1000 && !Stopped) {
// travel moves have been received so enact them // travel moves have been received so enact them
delayed_move_time = 0xFFFFFFFFUL; // force moves to be done delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
memcpy(destination,current_position, sizeof(destination)); memcpy(destination, current_position, sizeof(destination));
prepare_move(); prepare_move();
} }
#endif #endif
@ -5814,13 +5792,7 @@ void kill()
cli(); // Stop interrupts cli(); // Stop interrupts
disable_heater(); disable_heater();
disable_x(); disable_all_axes();
disable_y();
disable_z();
disable_e0();
disable_e1();
disable_e2();
disable_e3();
#if HAS_POWER_SWITCH #if HAS_POWER_SWITCH
pinMode(PS_ON_PIN, INPUT); pinMode(PS_ON_PIN, INPUT);