Browse Source

Add a ZERO macro to clear arrays

pull/1/head
Scott Lahteine 8 years ago
parent
commit
5f5a55a0de
  1. 2
      Marlin/Marlin_main.cpp
  2. 2
      Marlin/SdBaseFile.cpp
  3. 2
      Marlin/cardreader.cpp
  4. 1
      Marlin/macros.h
  5. 2
      Marlin/mesh_bed_leveling.cpp
  6. 6
      Marlin/planner.cpp

2
Marlin/Marlin_main.cpp

@ -3145,7 +3145,7 @@ inline void gcode_G4() {
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
#endif #endif
// Init the current position of all carriages to 0,0,0 // Init the current position of all carriages to 0,0,0
memset(current_position, 0, sizeof(current_position)); ZERO(current_position);
sync_plan_position(); sync_plan_position();
// Move all carriages together linearly until an endstop is hit. // Move all carriages together linearly until an endstop is hit.

2
Marlin/SdBaseFile.cpp

@ -674,7 +674,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile,
index = 0; index = 0;
} }
// initialize as empty file // initialize as empty file
memset(p, 0, sizeof(dir_t)); ZERO(p);
memcpy(p->name, dname, 11); memcpy(p->name, dname, 11);
// set timestamps // set timestamps

2
Marlin/cardreader.cpp

@ -36,7 +36,7 @@ CardReader::CardReader() {
sdpos = 0; sdpos = 0;
workDirDepth = 0; workDirDepth = 0;
file_subcall_ctr = 0; file_subcall_ctr = 0;
memset(workDirParents, 0, sizeof(workDirParents)); ZERO(workDirParents);
autostart_stilltocheck = true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software. autostart_stilltocheck = true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software.
autostart_index = 0; autostart_index = 0;

1
Marlin/macros.h

@ -78,6 +78,7 @@
#define NUMERIC(a) ((a) >= '0' && '9' >= (a)) #define NUMERIC(a) ((a) >= '0' && '9' >= (a))
#define NUMERIC_SIGNED(a) (NUMERIC(a) || (a) == '-') #define NUMERIC_SIGNED(a) (NUMERIC(a) || (a) == '-')
#define COUNT(a) (sizeof(a)/sizeof(*a)) #define COUNT(a) (sizeof(a)/sizeof(*a))
#define ZERO(a) memset(a,0,sizeof(a))
// Macros for initializing arrays // Macros for initializing arrays
#define ARRAY_6(v1, v2, v3, v4, v5, v6, args...) { v1, v2, v3, v4, v5, v6 } #define ARRAY_6(v1, v2, v3, v4, v5, v6, args...) { v1, v2, v3, v4, v5, v6 }

2
Marlin/mesh_bed_leveling.cpp

@ -31,7 +31,7 @@
void mesh_bed_leveling::reset() { void mesh_bed_leveling::reset() {
status = MBL_STATUS_NONE; status = MBL_STATUS_NONE;
z_offset = 0; z_offset = 0;
memset(z_values, 0, sizeof(z_values)); ZERO(z_values);
} }
#endif // MESH_BED_LEVELING #endif // MESH_BED_LEVELING

6
Marlin/planner.cpp

@ -137,8 +137,8 @@ Planner::Planner() { init(); }
void Planner::init() { void Planner::init() {
block_buffer_head = block_buffer_tail = 0; block_buffer_head = block_buffer_tail = 0;
memset(position, 0, sizeof(position)); ZERO(position);
memset(previous_speed, 0, sizeof(previous_speed)); ZERO(previous_speed);
previous_nominal_speed = 0.0; previous_nominal_speed = 0.0;
#if ABL_PLANAR #if ABL_PLANAR
bed_level_matrix.set_to_identity(); bed_level_matrix.set_to_identity();
@ -1266,7 +1266,7 @@ void Planner::_set_position_mm(const float &a, const float &b, const float &c, c
stepper.set_position(na, nb, nc, ne); stepper.set_position(na, nb, nc, ne);
previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest. previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
memset(previous_speed, 0, sizeof(previous_speed)); ZERO(previous_speed);
} }
void Planner::set_position_mm_kinematic(const float position[NUM_AXIS]) { void Planner::set_position_mm_kinematic(const float position[NUM_AXIS]) {

Loading…
Cancel
Save