Optimisation: make constructors constexpr
Cppcheck was complaining some member variables are not initialised in the constructor. Change in memory: Flash: -186 bytes SRAM: -15 bytespull/292/head
parent
0d76a0ea23
commit
fff1c471b4
|
|
@ -28,7 +28,7 @@ ErrorCode AddErrorAxisBit(ErrorCode ec, uint8_t axis);
|
|||
/// These tasks report their progress and only one of these tasks is allowed to run at once.
|
||||
class CommandBase {
|
||||
public:
|
||||
inline CommandBase()
|
||||
inline constexpr CommandBase()
|
||||
: state(ProgressCode::OK)
|
||||
, error(ErrorCode::OK)
|
||||
, deferredErrorCode(ErrorCode::OK)
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ namespace logic {
|
|||
/// @brief A high-level command state machine - handles the complex logic of cutting filament
|
||||
class CutFilament : public CommandBase {
|
||||
public:
|
||||
inline CutFilament()
|
||||
: CommandBase() {}
|
||||
inline constexpr CutFilament()
|
||||
: CommandBase()
|
||||
, cutSlot(0)
|
||||
, savedSelectorFeedRate_mm_s(0) {}
|
||||
|
||||
/// Restart the automaton
|
||||
/// @param param index of filament slot to perform cut onto
|
||||
|
|
|
|||
|
|
@ -26,8 +26,9 @@ static constexpr modules::motion::P_speed_t ejectSpeed = 1000.0_P_mm_s; //@@TODO
|
|||
/// The Eject message is not an error, but we'll leverage existing infrastructure of error screens + user input to model a nice UI dialog.
|
||||
class EjectFilament : public CommandBase {
|
||||
public:
|
||||
inline EjectFilament()
|
||||
: CommandBase() {}
|
||||
inline constexpr EjectFilament()
|
||||
: CommandBase()
|
||||
, slot(0) {}
|
||||
|
||||
/// Restart the automaton
|
||||
/// @param param index of filament slot to eject
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ struct FeedToBondtech {
|
|||
// PulleyStalled
|
||||
};
|
||||
|
||||
inline FeedToBondtech()
|
||||
inline constexpr FeedToBondtech()
|
||||
: state(OK)
|
||||
, maxRetries(1) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,10 @@ struct FeedToFinda {
|
|||
Stopped
|
||||
};
|
||||
|
||||
inline FeedToFinda()
|
||||
inline constexpr FeedToFinda()
|
||||
: state(OK)
|
||||
, feedPhaseLimited(true) {}
|
||||
, feedPhaseLimited(true)
|
||||
, haltAtEnd(0) {}
|
||||
|
||||
/// Restart the automaton
|
||||
/// @param feedPhaseLimited
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace logic {
|
|||
/// This high-level command is just a way to invoke re-homing from the printer while all safety measures are kept.
|
||||
class Home : public CommandBase {
|
||||
public:
|
||||
inline Home()
|
||||
inline constexpr Home()
|
||||
: CommandBase() {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace logic {
|
|||
|
||||
class HWSanity : public CommandBase {
|
||||
public:
|
||||
inline HWSanity()
|
||||
inline constexpr HWSanity()
|
||||
: CommandBase() {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
@ -44,7 +44,7 @@ private:
|
|||
static void PrepareAxis(config::Axis axis);
|
||||
|
||||
uint8_t test_step = 0;
|
||||
config::Axis axis;
|
||||
config::Axis axis = config::Axis::Pulley;
|
||||
uint8_t fault_masks[3] = { 0 };
|
||||
ProgressCode next_state = ProgressCode::HWTestBegin;
|
||||
uint16_t wait_start = 0;
|
||||
|
|
|
|||
|
|
@ -10,9 +10,10 @@ namespace logic {
|
|||
/// @brief A high-level command state machine - handles the complex logic of loading filament into a filament slot.
|
||||
class LoadFilament : public CommandBase {
|
||||
public:
|
||||
inline LoadFilament()
|
||||
inline constexpr LoadFilament()
|
||||
: CommandBase()
|
||||
, verifyLoadedFilament(0) {}
|
||||
, verifyLoadedFilament(0)
|
||||
, result(ResultCode::OK) {}
|
||||
|
||||
/// Restart the automaton - performs unlimited rotation of the Pulley
|
||||
/// @param param index of filament slot to load
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace logic {
|
|||
/// and/or from the MMU's buttons while all safety measures are kept.
|
||||
class MoveSelector : public CommandBase {
|
||||
public:
|
||||
inline MoveSelector()
|
||||
inline constexpr MoveSelector()
|
||||
: CommandBase() {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace logic {
|
|||
/// @brief A dummy No-command operation just to make the init of the firmware consistent (and cleaner code during processing).
|
||||
class NoCommand : public CommandBase {
|
||||
public:
|
||||
inline NoCommand()
|
||||
inline constexpr NoCommand()
|
||||
: CommandBase() {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ struct RetractFromFinda {
|
|||
Failed
|
||||
};
|
||||
|
||||
inline RetractFromFinda()
|
||||
inline constexpr RetractFromFinda()
|
||||
: state(OK) {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace logic {
|
|||
/// (regardless of how long it takes it to finish) - that implies no motor moves are being performed while M0/M1 is being applied.
|
||||
class SetMode : public CommandBase {
|
||||
public:
|
||||
inline SetMode()
|
||||
inline constexpr SetMode()
|
||||
: CommandBase() {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace logic {
|
|||
/// @brief Firmware start up sequence with error handling & reporting
|
||||
class StartUp : public CommandBase {
|
||||
public:
|
||||
inline StartUp()
|
||||
inline constexpr StartUp()
|
||||
: CommandBase() {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@ namespace logic {
|
|||
/// @brief A high-level command state machine - handles the complex logic of tool change - which is basically a chain of an Unload and a Load operation.
|
||||
class ToolChange : public CommandBase {
|
||||
public:
|
||||
inline ToolChange()
|
||||
: CommandBase() {}
|
||||
inline constexpr ToolChange()
|
||||
: CommandBase()
|
||||
, plannedSlot(-1) {}
|
||||
|
||||
/// Restart the automaton
|
||||
/// @param param index of filament slot to change to - i.e. to load
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace logic {
|
|||
/// @brief A high-level command state machine - handles the complex logic of unloading filament
|
||||
class UnloadFilament : public CommandBase {
|
||||
public:
|
||||
inline UnloadFilament()
|
||||
inline constexpr UnloadFilament()
|
||||
: CommandBase() {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@ struct UnloadToFinda {
|
|||
FailedFINDA,
|
||||
FailedFSensor
|
||||
};
|
||||
inline UnloadToFinda()
|
||||
: maxTries(3) {}
|
||||
inline constexpr UnloadToFinda()
|
||||
: state(OK)
|
||||
, maxTries(3)
|
||||
, unloadStart_mm(0) {}
|
||||
|
||||
/// Restart the automaton
|
||||
/// @param maxTries maximum number of retried attempts before reporting a fail
|
||||
|
|
|
|||
Loading…
Reference in New Issue