arduino / arduino/ArduinoCore-API
force new enums for pinMode and pinStatus to 8 bits type instead of default int
- Lingua principale
- C++
- Stelle
- 306
- Fork
- 150
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
I've seen
```
typedef enum {
LOW = 0,
HIGH = 1,
CHANGE = 2,
FALLING = 3,
RISING = 4,
} PinStatus;
typedef enum {
INPUT = 0x0,
OUTPUT = 0x1,
INPUT_PULLUP = 0x2,
INPUT_PULLDOWN = 0x3,
} PinMode;
```
This will let the compiler decide how big the backend storage needs to be for those, and it will default to an int (16 or 32 bit depending on architecture). There is no need for this waste of memory and it prevents also some compiler optimization
I suggest forcing the uint8_t type, 256 values should be plenty to represent a pinMode or a pinStatus..
proposed changes:
```
typedef enum : uint8_t {
LOW = 0,
HIGH = 1,
CHANGE = 2,
FALLING = 3,
RISING = 4,
} PinStatus;
typedef enum : uint8_t {
INPUT = 0x0,
OUTPUT = 0x1,
INPUT_PULLUP = 0x2,
INPUT_PULLDOWN = 0x3,
} PinMode;
```
but in practice I would vote against getting these changes in production. There is no value added and tons of unwanted consequences for existing code out there to make this worthwhile.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia individuando le dichiarazioni degli enum PinMode e PinStatus nell’API ArduinoCore-API, quindi valuta le conseguenze sulla compatibilità del codice sorgente e binaria nel codice Arduino esistente. Il lavoro è completato quando esiste una decisione del progetto sull’accettabilità dei tipi sottostanti uint8_t proposti; l’issue stessa sconsiglia l’adozione in produzione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Ambito
- embedded-iot
- Tipo di issue
- Refactoring
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 18/100