Skip to content

Commit

Permalink
Add custom types for position (#15204)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored Sep 29, 2019
1 parent 43d6e9f commit 50e4545
Show file tree
Hide file tree
Showing 227 changed files with 3,151 additions and 3,268 deletions.
4 changes: 1 addition & 3 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,7 @@
//#define Z_STEPPER_AUTO_ALIGN
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
// Define probe X and Y positions for Z1, Z2 [, Z3]
#define Z_STEPPER_ALIGN_X { 10, 150, 290 }
#define Z_STEPPER_ALIGN_Y { 290, 10, 290 }
// Set number of iterations to align
#define Z_STEPPER_ALIGN_XY { { 10, 290 }, { 150, 10 }, { 290, 290 } } // Set number of iterations to align
#define Z_STEPPER_ALIGN_ITERATIONS 3
// Enable to restore leveling setup after operation
#define RESTORE_LEVELING_AFTER_G34
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/Marlin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,10 +582,10 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
}
#endif // !SWITCHING_EXTRUDER

const float olde = current_position[E_AXIS];
current_position[E_AXIS] += EXTRUDER_RUNOUT_EXTRUDE;
planner.buffer_line(current_position, MMM_TO_MMS(EXTRUDER_RUNOUT_SPEED), active_extruder);
current_position[E_AXIS] = olde;
const float olde = current_position.e;
current_position.e += EXTRUDER_RUNOUT_EXTRUDE;
line_to_current_position(MMM_TO_MMS(EXTRUDER_RUNOUT_SPEED));
current_position.e = olde;
planner.set_e_position_mm(olde);
planner.synchronize();

Expand Down Expand Up @@ -629,7 +629,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
if (delayed_move_time && ELAPSED(ms, delayed_move_time + 1000UL) && IsRunning()) {
// travel moves have been received so enact them
delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
set_destination_from_current();
destination = current_position;
prepare_move_to_destination();
}
#endif
Expand Down Expand Up @@ -1002,7 +1002,7 @@ void setup() {

#if HAS_M206_COMMAND
// Initialize current position based on home_offset
LOOP_XYZ(a) current_position[a] += home_offset[a];
current_position += home_offset;
#endif

// Vital to init stepper/planner equivalent for current_position
Expand Down
63 changes: 0 additions & 63 deletions Marlin/src/core/enum.h

This file was deleted.

7 changes: 1 addition & 6 deletions Marlin/src/core/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define XYZE 4
#define ABC 3
#define XYZ 3
#define XY 2

#define _AXIS(A) (A##_AXIS)

Expand Down Expand Up @@ -252,12 +253,6 @@
#define DECREMENT_(n) DEC_##n
#define DECREMENT(n) DECREMENT_(n)

// Feedrate
typedef float feedRate_t;
#define MMM_TO_MMS(MM_M) ((MM_M)/60.0f)
#define MMS_TO_MMM(MM_S) ((MM_S)*60.0f)
#define MMS_SCALED(V) ((V) * 0.01f * feedrate_percentage)

#define NOOP (void(0))

#define CEILING(x,y) (((x) + (y) - 1) / (y))
Expand Down
7 changes: 1 addition & 6 deletions Marlin/src/core/serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "serial.h"
#include "language.h"
#include "enum.h"

uint8_t marlin_debug_flags = MARLIN_DEBUG_NONE;

Expand Down Expand Up @@ -68,12 +67,8 @@ void print_bin(const uint16_t val) {
}
}

void print_xyz(PGM_P const prefix, PGM_P const suffix, const float &x, const float &y, const float &z) {
void print_xyz(const float &x, const float &y, const float &z, PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) {
serialprintPGM(prefix);
SERIAL_ECHOPAIR(" " MSG_X, x, " " MSG_Y, y, " " MSG_Z, z);
if (suffix) serialprintPGM(suffix); else SERIAL_EOL();
}

void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]) {
print_xyz(prefix, suffix, xyz[X_AXIS], xyz[Y_AXIS], xyz[Z_AXIS]);
}
12 changes: 8 additions & 4 deletions Marlin/src/core/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ void serial_spaces(uint8_t count);

void print_bin(const uint16_t val);

void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]);
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float &x, const float &y, const float &z);
#define SERIAL_POS(SUFFIX,VAR) do { print_xyz(PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); }while(0)
#define SERIAL_XYZ(PREFIX,V...) do { print_xyz(PSTR(PREFIX), nullptr, V); }while(0)
void print_xyz(const float &x, const float &y, const float &z, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr);

inline void print_xyz(const xyz_pos_t &xyz, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr) {
print_xyz(xyz.x, xyz.y, xyz.z, prefix, suffix);
}

#define SERIAL_POS(SUFFIX,VAR) do { print_xyz(VAR, PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n")); }while(0)
#define SERIAL_XYZ(PREFIX,V...) do { print_xyz(V, PSTR(PREFIX), nullptr); }while(0)
Loading

0 comments on commit 50e4545

Please sign in to comment.