Skip to content

Commit

Permalink
Fix EXTRUDERS > 1
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndere1 committed May 3, 2020
1 parent 33a7d78 commit b93d322
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 17 deletions.
22 changes: 16 additions & 6 deletions Marlin/src/core/serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,20 @@ void print_bin(uint16_t val) {
}
}

extern const char SP_X_STR[], SP_Y_STR[], SP_Z_STR[];
#if ENABLED(E_AXIS_HOMING)
extern const char SP_X_STR[], SP_Y_STR[], SP_Z_STR[], SP_E_STR[];

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_P(SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z);
if (suffix) serialprintPGM(suffix); else SERIAL_EOL();
}
void print_xyz(const float &x, const float &y, const float &z, const float &e, PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) {
serialprintPGM(prefix);
SERIAL_ECHOPAIR_P(SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z, SP_E_STR, e);
if (suffix) serialprintPGM(suffix); else SERIAL_EOL();
}
#else
extern const char SP_X_STR[], SP_Y_STR[], SP_Z_STR[];

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_P(SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z);
if (suffix) serialprintPGM(suffix); else SERIAL_EOL();
}
#endif
15 changes: 12 additions & 3 deletions Marlin/src/core/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,20 @@ void serialprint_truefalse(const bool tf);
void serial_spaces(uint8_t count);

void print_bin(const uint16_t val);
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);
#if ENABLED(E_AXIS_HOMING)
void print_xyz(const float &x, const float &y, const float &z, const float &e, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr);

inline void print_xyz(const xyze_pos_t &xyz, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr) {
print_xyz(xyz.x, xyz.y, xyz.z, xyz.e, prefix, suffix);
}
#else
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);
}
#endif

#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)
14 changes: 7 additions & 7 deletions Marlin/src/module/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ xyze_pos_t destination; // {0}
#endif

// TODO (DerAndere1): Test
// #if ENABLED(E_AXIS_HOMING)
//// The active extruder (tool). Set with T<extruder> command.
// #if EXTRUDERS > 1
// uint8_t active_extruder = 0; // = 0
// float extruder_position[EXTRUDERS];//variable to store individual e pos
// #endif
//#endif
// The active extruder (tool). Set with T<extruder> command.
#if EXTRUDERS > 1
uint8_t active_extruder = 0; // = 0
#if ENABLED(E_AXIS_HOMING)
float extruder_position[EXTRUDERS]; // {0} (variable to store individual e pos)
#endif
#endif

#if ENABLED(LCD_SHOW_E_TOTAL)
float e_move_accumulator; // = 0
Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/module/motion.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ extern int16_t feedrate_percentage;
// The active extruder (tool). Set with T<extruder> command.
#if EXTRUDERS > 1
extern uint8_t active_extruder;
extern float extruder_position[EXTRUDERS];
#if ENABLED(E_AXIS_HOMING)
extern float extruder_position[EXTRUDERS];
#endif
#else
constexpr uint8_t active_extruder = 0;
#endif
Expand Down

0 comments on commit b93d322

Please sign in to comment.