Skip to content

Commit

Permalink
Improvement of enums in some cases. Now it is coded that they must oc…
Browse files Browse the repository at this point in the history
…cupy 1 byte instead of 4.
  • Loading branch information
KOLANICH committed Feb 24, 2023
1 parent 844e4bf commit b453a05
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions api/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@
extern "C"{
#endif

#ifdef __cplusplus
#define ARD_CHAR_ENUM_XWEZPiBoACuGnH : char
#else
#define ARD_CHAR_ENUM_XWEZPiBoACuGnH __attribute__ ((__packed__))
#endif

void yield(void);

typedef enum {
typedef enum ARD_CHAR_ENUM_XWEZPiBoACuGnH{
LOW = 0,
HIGH = 1,
CHANGE = 2,
FALLING = 3,
RISING = 4,
} PinStatus;

typedef enum {
typedef enum ARD_CHAR_ENUM_XWEZPiBoACuGnH{
INPUT = 0x0,
OUTPUT = 0x1,
INPUT_PULLUP = 0x2,
INPUT_PULLDOWN = 0x3,
OUTPUT_OPENDRAIN = 0x4,
} PinMode;

typedef enum {
typedef enum ARD_CHAR_ENUM_XWEZPiBoACuGnH{
LSBFIRST = 0,
MSBFIRST = 1,
} BitOrder;
Expand Down
2 changes: 1 addition & 1 deletion api/HardwareSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

namespace arduino {

typedef enum {
typedef enum ARD_CHAR_ENUM_XWEZPiBoACuGnH {
SPI_MODE0 = 0,
SPI_MODE1 = 1,
SPI_MODE2 = 2,
Expand Down
4 changes: 2 additions & 2 deletions api/Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace arduino {
// This enumeration provides the lookahead options for parseInt(), parseFloat()
// The rules set out here are used until either the first valid character is found
// or a time out occurs due to lack of input.
enum LookaheadMode{
enum LookaheadMode: uint8_t {
SKIP_ALL, // All invalid characters are ignored.
SKIP_NONE, // Nothing is skipped, and the stream is not touched unless the first waiting character is valid.
SKIP_WHITESPACE // Only tabs, spaces, line feeds & carriage returns are skipped.
Expand Down Expand Up @@ -130,4 +130,4 @@ class Stream : public Print

}

using arduino::Stream;
using arduino::Stream;

0 comments on commit b453a05

Please sign in to comment.