// Parse line
char *p = cmd + 1; // Skip `$`
int argc = 0;
- char *argv[MAX_ARGS] = {};
+ char *argv[MAX_ARGS] = {0};
if (cmd[1] == '$' && !cmd[2]) {
report_request_full(); // Full report
bool bootloader; // flag to enter the bootloader
} hw_t;
-static hw_t hw = {};
+static hw_t hw = {{0}};
#define PROD_SIGS (*(NVM_PROD_SIGNATURES_t *)0x0000)
static void _homing_axis_start(int8_t axis);
-typedef enum { // applies to mach.homing_state
+typedef enum {
HOMING_NOT_HOMED, // machine is not homed
HOMING_HOMED, // machine is homed
HOMING_WAITING, // machine waiting to be homed
};
-static struct hmHomingSingleton hm = {0,};
+static struct hmHomingSingleton hm = {0};
// G28.2 homing cycle
/// helper that actually executes the above moves
static void _homing_axis_move(int8_t axis, float target, float velocity) {
- float vect[] = {};
- float flags[] = {};
+ float vect[AXES] = {0};
+ float flags[AXES] = {0};
vect[axis] = target;
flags[axis] = true;
} huanyang_t;
-static huanyang_t ha = {};
+static huanyang_t ha = {0};
#define CTRL_STATUS_RESPONSE(R) ((uint16_t)R[4] << 8 | R[5])
*
* Functions to get, set and report coordinate systems and work offsets
* These functions are not part of the NIST defined functions
- */
-/*
+ *
* Notes on Coordinate System and Offset functions
*
* All positional information in the machine is kept as
}
}
- for (uint8_t axis = 0; axis < AXES; axis++) {
+ for (int axis = 0; axis < AXES; axis++) {
if (mach.gm.motion_mode == MOTION_MODE_STRAIGHT_TRAVERSE)
tmp_time = fabs(axis_length[axis]) / mach.a[axis].velocity_max;
void machine_init() {
// Init 1/jerk
- for (uint8_t axis = 0; axis < AXES; axis++)
- mach.a[axis].recip_jerk = 1 / (mach.a[axis].jerk_max * JERK_MULTIPLIER);
+ for (int axis = 0; axis < AXES; axis++)
+ mach_set_axis_jerk(axis, mach.a[axis].jerk_max);
// Set gcode defaults
mach_set_units_mode(GCODE_DEFAULT_UNITS);
/// M2, M30
void mach_program_end() {
- float value[AXES] = {};
+ float value[AXES] = {0};
mp_queue_command(_exec_program_end, value, value);
}
float g30_position[AXES]; // stored machine position for G30
AxisConfig_t a[AXES]; // settings for axes
-
- // Model states
MoveState_t ms;
GCodeState_t gm; // core gcode model state
GCodeState_t gn; // gcode input values
MoveState_t ms;
} arc_t;
-arc_t arc = {};
+arc_t arc = {0};
/* Returns a naive estimate of arc execution time to inform segment
} else arc.arc_time = arc.length / mach.gm.feed_rate;
// Downgrade the time if there is a rate-limiting axis
- arc.arc_time =
- max(arc.arc_time, arc.planar_travel/mach.a[arc.plane_axis_0].feedrate_max);
- arc.arc_time =
- max(arc.arc_time, arc.planar_travel/mach.a[arc.plane_axis_1].feedrate_max);
+ arc.arc_time = max(arc.arc_time,
+ arc.planar_travel / mach.a[arc.plane_axis_0].feedrate_max);
+ arc.arc_time = max(arc.arc_time,
+ arc.planar_travel / mach.a[arc.plane_axis_1].feedrate_max);
if (0 < fabs(arc.linear_travel))
arc.arc_time =
max(arc.arc_time,
- fabs(arc.linear_travel/mach.a[arc.linear_axis].feedrate_max));
+ fabs(arc.linear_travel / mach.a[arc.linear_axis].feedrate_max));
}
/// Stop arc movement without maintaining position
/// OK to call if no arc is running
-void mach_abort_arc() {
- arc.run_state = MOVE_OFF;
-}
+void mach_abort_arc() {arc.run_state = MOVE_OFF;}
uint16_t stallguard;
} calibrate_t;
-static calibrate_t cal = {};
+static calibrate_t cal = {0};
static stat_t _exec_calibrate(mpBuf_t *bf) {
if (!cal.velocity) return STAT_OK;
// Compute travel
- float travel[AXES] = {}; // In mm
+ float travel[AXES] = {0}; // In mm
travel[cal.axis] = time * cal.velocity * (cal.reverse ? -1 : 1);
// Convert to steps
copy_vector(mr.final_target, bf->ms.target); // save move final target
// generate the waypoints for position correction at section ends
- for (uint8_t axis = 0; axis < AXES; axis++) {
+ for (int axis = 0; axis < AXES; axis++) {
mr.waypoint[SECTION_HEAD][axis] =
mr.position[axis] + mr.unit[axis] * mr.head_length;
} mpMoveMasterSingleton_t;
-mpMoveMasterSingleton_t mm = {}; // context for line planning
+mpMoveMasterSingleton_t mm = {{0}}; // context for line planning
/// Set planner position for a single axis
float axis_square[AXES];
float length_square = 0;
- for (uint8_t axis = 0; axis < AXES; axis++) {
+ for (int axis = 0; axis < AXES; axis++) {
axis_length[axis] = ms->target[axis] - mm.position[axis];
axis_square[axis] = square(axis_length[axis]);
length_square += axis_square[axis];
#include <stdio.h>
-mpMoveRuntimeSingleton_t mr = {}; // context for line runtime
+mpMoveRuntimeSingleton_t mr = {0}; // context for line runtime
void planner_init() {
// convert lengths to steps in floating point
mp_kinematics(mr.position, step_position);
- for (uint8_t motor = 0; motor < MOTORS; motor++) {
+ for (int motor = 0; motor < MOTORS; motor++) {
mr.target_steps[motor] = step_position[motor];
mr.position_steps[motor] = step_position[motor];
mr.commanded_steps[motor] = step_position[motor];
#define MINIMUM_PROBE_TRAVEL 0.254
-typedef enum { // applies to mach.probe_state
+typedef enum {
PROBE_FAILED, // probe reached endpoint without triggering
PROBE_SUCCEEDED, // probe was triggered, pb.results has position
PROBE_WAITING, // probe is waiting to be started
};
-static struct pbProbingSingleton pb = {0,};
+static struct pbProbingSingleton pb = {0};
/* Note: When coding a cycle (like this one) you get to perform one
} stepper_t;
-static stepper_t st = {};
+static stepper_t st = {0};
void stepper_init() {
volatile uint32_t in;
} spi_t;
-static spi_t spi = {};
+static spi_t spi = {0};