Ver código fonte

Add a ZERO macro to clear arrays

Scott Lahteine 8 anos atrás
pai
commit
5f5a55a0de

+ 1
- 1
Marlin/Marlin_main.cpp Ver arquivo

3145
       if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
3145
       if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
3146
     #endif
3146
     #endif
3147
     // Init the current position of all carriages to 0,0,0
3147
     // Init the current position of all carriages to 0,0,0
3148
-    memset(current_position, 0, sizeof(current_position));
3148
+    ZERO(current_position);
3149
     sync_plan_position();
3149
     sync_plan_position();
3150
 
3150
 
3151
     // Move all carriages together linearly until an endstop is hit.
3151
     // Move all carriages together linearly until an endstop is hit.

+ 1
- 1
Marlin/SdBaseFile.cpp Ver arquivo

674
       index = 0;
674
       index = 0;
675
     }
675
     }
676
     // initialize as empty file
676
     // initialize as empty file
677
-    memset(p, 0, sizeof(dir_t));
677
+    ZERO(p);
678
     memcpy(p->name, dname, 11);
678
     memcpy(p->name, dname, 11);
679
 
679
 
680
     // set timestamps
680
     // set timestamps

+ 1
- 1
Marlin/cardreader.cpp Ver arquivo

36
   sdpos = 0;
36
   sdpos = 0;
37
   workDirDepth = 0;
37
   workDirDepth = 0;
38
   file_subcall_ctr = 0;
38
   file_subcall_ctr = 0;
39
-  memset(workDirParents, 0, sizeof(workDirParents));
39
+  ZERO(workDirParents);
40
 
40
 
41
   autostart_stilltocheck = true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software.
41
   autostart_stilltocheck = true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software.
42
   autostart_index = 0;
42
   autostart_index = 0;

+ 1
- 0
Marlin/macros.h Ver arquivo

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

+ 1
- 1
Marlin/mesh_bed_leveling.cpp Ver arquivo

31
   void mesh_bed_leveling::reset() {
31
   void mesh_bed_leveling::reset() {
32
     status = MBL_STATUS_NONE;
32
     status = MBL_STATUS_NONE;
33
     z_offset = 0;
33
     z_offset = 0;
34
-    memset(z_values, 0, sizeof(z_values));
34
+    ZERO(z_values);
35
   }
35
   }
36
 
36
 
37
 #endif  // MESH_BED_LEVELING
37
 #endif  // MESH_BED_LEVELING

+ 3
- 3
Marlin/planner.cpp Ver arquivo

137
 
137
 
138
 void Planner::init() {
138
 void Planner::init() {
139
   block_buffer_head = block_buffer_tail = 0;
139
   block_buffer_head = block_buffer_tail = 0;
140
-  memset(position, 0, sizeof(position));
141
-  memset(previous_speed, 0, sizeof(previous_speed));
140
+  ZERO(position);
141
+  ZERO(previous_speed);
142
   previous_nominal_speed = 0.0;
142
   previous_nominal_speed = 0.0;
143
   #if ABL_PLANAR
143
   #if ABL_PLANAR
144
     bed_level_matrix.set_to_identity();
144
     bed_level_matrix.set_to_identity();
1266
   stepper.set_position(na, nb, nc, ne);
1266
   stepper.set_position(na, nb, nc, ne);
1267
   previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
1267
   previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
1268
 
1268
 
1269
-  memset(previous_speed, 0, sizeof(previous_speed));
1269
+  ZERO(previous_speed);
1270
 }
1270
 }
1271
 
1271
 
1272
 void Planner::set_position_mm_kinematic(const float position[NUM_AXIS]) {
1272
 void Planner::set_position_mm_kinematic(const float position[NUM_AXIS]) {

Carregando…
Cancelar
Salvar