From bd8ae6221128d4faeeb68a90062c9d1b60e73b4a Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 6 Jul 2021 16:09:05 +0200 Subject: [PATCH] PulseGen: cleanup AxisData initialization --- src/modules/motion.h | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/modules/motion.h b/src/modules/motion.h index 6af6313..95e1a07 100644 --- a/src/modules/motion.h +++ b/src/modules/motion.h @@ -132,23 +132,19 @@ private: pulse_gen::PulseGen ctrl; ///< Motor controller }; + /// Helper to initialize AxisData members + static AxisData DataForAxis(Axis axis) { + return { + .drv = { axisParams[axis].params, axisParams[axis].currents, axisParams[axis].mode }, + .ctrl = { axisParams[axis].jerk, axisParams[axis].accel }, + }; + } + /// Dynamic axis data AxisData axisData[NUM_AXIS] = { - // Idler - { - .drv = { axisParams[Idler].params, axisParams[Idler].currents, axisParams[Idler].mode }, - .ctrl = { axisParams[Idler].jerk, axisParams[Idler].accel }, - }, - // Pulley - { - .drv = { axisParams[Pulley].params, axisParams[Pulley].currents, axisParams[Pulley].mode }, - .ctrl = { axisParams[Pulley].jerk, axisParams[Pulley].accel }, - }, - // Selector - { - .drv = { axisParams[Selector].params, axisParams[Selector].currents, axisParams[Selector].mode }, - .ctrl = { axisParams[Selector].jerk, axisParams[Selector].accel }, - } + DataForAxis(Idler), + DataForAxis(Pulley), + DataForAxis(Selector), }; };