From 7c6162b90a24fad8f3d769d6a1fabbc8aedc9db2 Mon Sep 17 00:00:00 2001 From: Alexander Danilov Date: Thu, 10 Jan 2013 02:22:45 +0400 Subject: [PATCH] Replace some constants with N_AXIS. --- gcode.c | 2 +- gcode.h | 2 +- limits.c | 2 +- planner.c | 4 ++-- report.c | 10 +++++----- settings.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gcode.c b/gcode.c index 5d3404f..d67ace0 100644 --- a/gcode.c +++ b/gcode.c @@ -98,7 +98,7 @@ uint8_t gc_execute_line(char *line) uint8_t absolute_override = false; // true(1) = absolute motion for this block only {G53} uint8_t non_modal_action = NON_MODAL_NONE; // Tracks the actions of modal group 0 (non-modal) - float target[3], offset[3]; + float target[N_AXIS], offset[N_AXIS]; clear_vector(target); // XYZ(ABC) axes parameters. clear_vector(offset); // IJK Arc offsets are incremental. Value of zero indicates no change. diff --git a/gcode.h b/gcode.h index 1cfd3d0..50b4228 100644 --- a/gcode.h +++ b/gcode.h @@ -72,7 +72,7 @@ typedef struct { int8_t spindle_direction; // 1 = CW, -1 = CCW, 0 = Stop {M3, M4, M5} uint8_t coolant_mode; // 0 = Disable, 1 = Flood Enable {M8, M9} float feed_rate; // Millimeters/min - float position[3]; // Where the interpreter considers the tool to be at this point in the code + float position[N_AXIS]; // Where the interpreter considers the tool to be at this point in the code uint8_t tool; // uint16_t spindle_speed; // RPM/100 uint8_t plane_axis_0, diff --git a/limits.c b/limits.c index 79405e8..efcc73b 100644 --- a/limits.c +++ b/limits.c @@ -96,7 +96,7 @@ static void homing_cycle(uint8_t cycle_mask, int8_t pos_dir, bool invert_pin, fl // and speedy homing routine. // NOTE: For each axes enabled, the following calculations assume they physically move // an equal distance over each time step until they hit a limit switch, aka dogleg. - uint32_t steps[3]; + uint32_t steps[N_AXIS]; uint8_t dist = 0; clear_vector(steps); if (cycle_mask & (1<step_event_count == 0) { return; }; // Compute path vector in terms of absolute step target and current positions - float delta_mm[3]; + float delta_mm[N_AXIS]; delta_mm[X_AXIS] = x-pl.last_x; delta_mm[Y_AXIS] = y-pl.last_y; delta_mm[Z_AXIS] = z-pl.last_z; diff --git a/report.c b/report.c index 2953393..0ab85b3 100644 --- a/report.c +++ b/report.c @@ -292,9 +292,9 @@ void report_realtime_status() // to be added are distance to go on block, processed block id, and feed rate. Also a settings bitmask // for a user to select the desired real-time data. uint8_t i; - int32_t current_position[3]; // Copy current state of the system position variable + int32_t current_position[N_AXIS]; // Copy current state of the system position variable memcpy(current_position,sys.position,sizeof(sys.position)); - float print_position[3]; + float print_position[N_AXIS]; // Report current machine state switch (sys.state) { @@ -310,7 +310,7 @@ void report_realtime_status() // Report machine position printPgmString(PSTR(",MPos:")); - for (i=0; i<= 2; i++) { + for (i=0; i< N_AXIS; i++) { print_position[i] = current_position[i]/settings.steps_per_mm[i]; if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { print_position[i] *= INCH_PER_MM; } printFloat(print_position[i]); @@ -319,14 +319,14 @@ void report_realtime_status() // Report work position printPgmString(PSTR("WPos:")); - for (i=0; i<= 2; i++) { + for (i=0; i< N_AXIS; i++) { if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { print_position[i] -= (gc.coord_system[i]+gc.coord_offset[i])*INCH_PER_MM; } else { print_position[i] -= gc.coord_system[i]+gc.coord_offset[i]; } printFloat(print_position[i]); - if (i < 2) { printPgmString(PSTR(",")); } + if (i < N_AXIS-1) { printPgmString(PSTR(",")); } } printPgmString(PSTR(">\r\n")); diff --git a/settings.c b/settings.c index a781409..2f75e6e 100644 --- a/settings.c +++ b/settings.c @@ -32,7 +32,7 @@ settings_t settings; // Version 4 outdated settings record typedef struct { - float steps_per_mm[3]; + float steps_per_mm[N_AXIS]; uint8_t microsteps; uint8_t pulse_microseconds; float default_feed_rate;