Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimisation: set enum types explictly to uint8_t #328

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/logic/feed_to_bondtech.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace logic {
/// To prevent constant EEPROM updates only significant changes are recorded.
struct FeedToBondtech {
/// internal states of the state machine
enum {
enum : uint8_t {
EngagingIdler,
PushingFilamentFast,
PushingFilamentToFSensor,
Expand Down
2 changes: 1 addition & 1 deletion src/logic/feed_to_finda.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace logic {
/// Leaves the Pulley axis enabled for chaining potential next operations
struct FeedToFinda {
/// internal states of the state machine
enum {
enum : uint8_t {
EngagingIdler,
PushingFilament,
PushingFilamentUnlimited,
Expand Down
2 changes: 1 addition & 1 deletion src/logic/hw_sanity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool HWSanity::Reset(uint8_t param) {
return true;
}

enum pin_bits {
enum pin_bits : uint8_t {
BIT_STEP = 0b001,
BIT_DIR = 0b010,
BIT_ENA = 0b100,
Expand Down
2 changes: 1 addition & 1 deletion src/logic/result_codes.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/// therefore the error codes have been extracted to one place.
///
/// Please note that currently only LoadFilament can return something else than "OK"
enum class ResultCode : uint_fast16_t {
enum class ResultCode : uint_fast8_t {
OK = 0,
Cancelled = 1
};
2 changes: 1 addition & 1 deletion src/logic/retract_from_finda.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace logic {
/// - leaves idler engaged for chaining operations
struct RetractFromFinda {
/// internal states of the state machine
enum {
enum : uint8_t {
EngagingIdler,
UnloadBackToPTFE,
OK,
Expand Down
2 changes: 1 addition & 1 deletion src/logic/unload_to_finda.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace logic {
/// - load/unload to finda
struct UnloadToFinda {
/// internal states of the state machine
enum {
enum : uint8_t {
EngagingIdler,
UnloadingToFinda,
WaitingForFINDA,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/buttons.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct Button : public debounce::Debouncer {
};

/// Enum of buttons - used also as indices in an array of buttons to keep the code size tight.
enum {
enum : uint8_t {
Right = 0,
Middle,
Left
Expand Down
2 changes: 1 addition & 1 deletion src/modules/debouncer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Debouncer {
/// Intentionally not modeled as an enum class
/// as it would impose additional casts which do not play well with the struct Flags
/// and would make the code less readable
enum State {
enum State : uint8_t {
Waiting = 0,
Detected,
WaitForRelease,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/leds.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ namespace leds {

/// Enum of LED modes
/// blink0 and blink1 allow for interlaced blinking of LEDs (one is on and the other off)
enum Mode {
enum Mode : uint8_t {
off,
on,
blink0, ///< start blinking at even periods
blink1 ///< start blinking at odd periods
};

/// Enum of LEDs color - green or red
enum Color {
enum Color : uint8_t {
red = 0,
green = 1
};
Expand Down
2 changes: 1 addition & 1 deletion src/modules/movable_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace motion {
class MovableBase {
public:
/// Internal states of the state machine
enum {
enum : uint8_t {
Ready = 0, // intentionally set as zero in order to allow zeroing the Idler structure upon startup -> avoid explicit initialization code
Moving = 1,
PlannedHome = 2,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/permanent_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class FilamentLoaded {
static bool set(uint8_t filament);

private:
enum Key {
enum Key : uint8_t {
KeyFront1,
KeyReverse1,
KeyFront2,
Expand Down
Loading