From 19d418cd6a343688cb5b433205eafd08e9586dda Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 27 Mar 2015 00:32:58 -0700 Subject: [PATCH] Fix up the code to eliminate warnings --- Marlin/Marlin_main.cpp | 29 ++++++++++----------- Marlin/cardreader.cpp | 2 +- Marlin/configurator/config/language.h | 3 ++- Marlin/language.h | 1 + Marlin/pins.h | 6 +++++ Marlin/planner.cpp | 36 +++++++++++++-------------- Marlin/qr_solve.cpp | 1 - Marlin/stepper.cpp | 36 ++++++++++++++++----------- Marlin/ultralcd.h | 3 +-- 9 files changed, 65 insertions(+), 52 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 084dea197..2391b8b50 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -388,7 +388,11 @@ const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'}; static float destination[NUM_AXIS] = { 0, 0, 0, 0 }; static float offset[3] = { 0, 0, 0 }; -static bool home_all_axis = true; + +#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; @@ -396,8 +400,8 @@ static bool relative_mode = false; //Determines Absolute or Relative Coordinate static char cmdbuffer[BUFSIZE][MAX_CMD_SIZE]; #ifdef SDSUPPORT -static bool fromsd[BUFSIZE]; -#endif //!SDSUPPORT + static bool fromsd[BUFSIZE]; +#endif static int bufindr = 0; static int bufindw = 0; static int buflen = 0; @@ -1233,10 +1237,6 @@ static void do_blocking_move_to(float x, float y, float z) { feedrate = oldFeedRate; } -static void do_blocking_move_relative(float offset_x, float offset_y, float offset_z) { - do_blocking_move_to(current_position[X_AXIS] + offset_x, current_position[Y_AXIS] + offset_y, current_position[Z_AXIS] + offset_z); -} - static void setup_for_endstop_move() { saved_feedrate = feedrate; saved_feedmultiply = feedmultiply; @@ -2150,7 +2150,6 @@ inline void gcode_G28() { } int verbose_level = 1; - float x_tmp, y_tmp, z_tmp, real_z; if (code_seen('V') || code_seen('v')) { verbose_level = code_value_long(); @@ -2436,6 +2435,7 @@ inline void gcode_G28() { // When the bed is uneven, this height must be corrected. if (!dryrun) { + float x_tmp, y_tmp, z_tmp, real_z; real_z = float(st_get_position(Z_AXIS)) / axis_steps_per_unit[Z_AXIS]; //get the real Z (since the auto bed leveling is already correcting the plane) x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER; y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER; @@ -3545,7 +3545,6 @@ inline void gcode_M200() { } } - float area = .0; if (code_seen('D')) { float diameter = code_value(); // setting any extruder filament size disables volumetric on the assumption that @@ -4283,7 +4282,7 @@ inline void gcode_M502() { * M503: print settings currently in memory */ inline void gcode_M503() { - Config_PrintSettings(code_seen('S') && code_value == 0); + Config_PrintSettings(code_seen('S') && code_value() == 0); } #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED @@ -4580,9 +4579,13 @@ inline void gcode_T() { SERIAL_ECHOLN(MSG_INVALID_EXTRUDER); } else { - boolean make_move = false; + #if EXTRUDERS > 1 + bool make_move = false; + #endif if (code_seen('F')) { - make_move = true; + #if EXTRUDERS > 1 + make_move = true; + #endif next_feedrate = code_value(); if (next_feedrate > 0.0) feedrate = next_feedrate; } @@ -5181,12 +5184,10 @@ void ClearToSend() void get_coordinates() { - bool seen[4]={false,false,false,false}; for(int8_t i=0; i < NUM_AXIS; i++) { if(code_seen(axis_codes[i])) { destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i]; - seen[i]=true; } else destination[i] = current_position[i]; //Are these else lines really needed? } diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index 125caab01..fae6c1be6 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -489,7 +489,7 @@ void CardReader::updir() { if (workDirDepth > 0) { --workDirDepth; workDir = workDirParents[0]; - for (int d = 0; d < workDirDepth; d++) + for (uint16_t d = 0; d < workDirDepth; d++) workDirParents[d] = workDirParents[d+1]; } } diff --git a/Marlin/configurator/config/language.h b/Marlin/configurator/config/language.h index e13fc3176..a1c47133f 100644 --- a/Marlin/configurator/config/language.h +++ b/Marlin/configurator/config/language.h @@ -62,11 +62,12 @@ #endif #ifdef CUSTOM_MENDEL_NAME + #undef MACHINE_NAME #define MACHINE_NAME CUSTOM_MENDEL_NAME #endif #ifndef MACHINE_UUID - #define MACHINE_UUID "00000000-0000-0000-0000-000000000000" + #define MACHINE_UUID "00000000-0000-0000-0000-000000000000" #endif diff --git a/Marlin/language.h b/Marlin/language.h index 9e348c929..a7692bd80 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -62,6 +62,7 @@ #endif #ifdef CUSTOM_MENDEL_NAME + #undef MACHINE_NAME #define MACHINE_NAME CUSTOM_MENDEL_NAME #endif diff --git a/Marlin/pins.h b/Marlin/pins.h index 939dab5e6..1e79a0cad 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -167,12 +167,18 @@ #endif #ifdef DISABLE_MAX_ENDSTOPS + #undef X_MAX_PIN + #undef Y_MAX_PIN + #undef Z_MAX_PIN #define X_MAX_PIN -1 #define Y_MAX_PIN -1 #define Z_MAX_PIN -1 #endif #ifdef DISABLE_MIN_ENDSTOPS + #undef X_MIN_PIN + #undef Y_MIN_PIN + #undef Z_MIN_PIN #define X_MIN_PIN -1 #define Y_MIN_PIN -1 #define Z_MIN_PIN -1 diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index a1ef453c0..958941f58 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -701,26 +701,26 @@ float junction_deviation = 0.1; int moves_queued = movesplanned(); - // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill - bool mq = moves_queued > 1 && moves_queued < BLOCK_BUFFER_SIZE / 2; - #ifdef OLD_SLOWDOWN - if (mq) feed_rate *= 2.0 * moves_queued / BLOCK_BUFFER_SIZE; - #endif - - #ifdef SLOWDOWN - // segment time im micro seconds - unsigned long segment_time = lround(1000000.0/inverse_second); - if (mq) { - if (segment_time < minsegmenttime) { - // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more. - inverse_second = 1000000.0 / (segment_time + lround(2 * (minsegmenttime - segment_time) / moves_queued)); - #ifdef XY_FREQUENCY_LIMIT - segment_time = lround(1000000.0 / inverse_second); - #endif + // Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill + #if defined(OLD_SLOWDOWN) || defined(SLOWDOWN) + bool mq = moves_queued > 1 && moves_queued < BLOCK_BUFFER_SIZE / 2; + #ifdef OLD_SLOWDOWN + if (mq) feed_rate *= 2.0 * moves_queued / BLOCK_BUFFER_SIZE; + #endif + #ifdef SLOWDOWN + // segment time im micro seconds + unsigned long segment_time = lround(1000000.0/inverse_second); + if (mq) { + if (segment_time < minsegmenttime) { + // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more. + inverse_second = 1000000.0 / (segment_time + lround(2 * (minsegmenttime - segment_time) / moves_queued)); + #ifdef XY_FREQUENCY_LIMIT + segment_time = lround(1000000.0 / inverse_second); + #endif + } } - } + #endif #endif - // END OF SLOW DOWN SECTION 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 diff --git a/Marlin/qr_solve.cpp b/Marlin/qr_solve.cpp index f19d989d4..4202db067 100644 --- a/Marlin/qr_solve.cpp +++ b/Marlin/qr_solve.cpp @@ -607,7 +607,6 @@ double dnrm2 ( int n, double x[], int incx ) double norm; double scale; double ssq; - double value; if ( n < 1 || incx < 1 ) { diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 8be4b98af..add20d5f4 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -85,18 +85,24 @@ static volatile bool endstop_z_hit = false; int motor_current_setting[3] = DEFAULT_PWM_MOTOR_CURRENT; #endif -static bool old_x_min_endstop = false, - old_x_max_endstop = false, - old_y_min_endstop = false, - old_y_max_endstop = false, - old_z_min_endstop = false, - #ifndef Z_DUAL_ENDSTOPS - old_z_max_endstop = false; - #else - old_z_max_endstop = false, - old_z2_min_endstop = false, - old_z2_max_endstop = false; - #endif +#if defined(X_MIN_PIN) && X_MIN_PIN >= 0 + static bool old_x_min_endstop = false; +#endif +#if defined(X_MAX_PIN) && X_MAX_PIN >= 0 + static bool old_x_max_endstop = false; +#endif +#if defined(Y_MIN_PIN) && Y_MIN_PIN >= 0 + static bool old_y_min_endstop = false; +#endif +#if defined(Y_MAX_PIN) && Y_MAX_PIN >= 0 + static bool old_y_max_endstop = false; +#endif + +static bool old_z_min_endstop = false, old_z_max_endstop = false; + +#ifdef Z_DUAL_ENDSTOPS + static bool old_z2_min_endstop = false, old_z2_max_endstop = false; +#endif static bool check_endstops = true; @@ -1176,8 +1182,6 @@ void digipot_current(uint8_t driver, int current) { } void microstep_init() { - const uint8_t microstep_modes[] = MICROSTEP_MODES; - #if defined(E1_MS1_PIN) && E1_MS1_PIN >= 0 pinMode(E1_MS1_PIN,OUTPUT); pinMode(E1_MS2_PIN,OUTPUT); @@ -1192,7 +1196,9 @@ void microstep_init() { pinMode(Z_MS2_PIN,OUTPUT); pinMode(E0_MS1_PIN,OUTPUT); pinMode(E0_MS2_PIN,OUTPUT); - for (int i = 0; i <= 4; i++) microstep_mode(i, microstep_modes[i]); + const uint8_t microstep_modes[] = MICROSTEP_MODES; + for (int i = 0; i < sizeof(microstep_modes) / sizeof(microstep_modes[0]); i++) + microstep_mode(i, microstep_modes[i]); #endif } diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index befe8fd1e..b699b8a5d 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -17,10 +17,9 @@ #ifdef DOGLCD extern int lcd_contrast; void lcd_setcontrast(uint8_t value); + static unsigned char blink = 0; // Variable for visualization of fan rotation in GLCD #endif - static unsigned char blink = 0; // Variable for visualization of fan rotation in GLCD - #define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x)) #define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x))