arduino / arduino/ArduinoCore-API

force new enums for pinMode and pinStatus to 8 bits type instead of default int

オープン
#109 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C++
スター
306
フォーク
150
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

まず ArduinoCore-API API 内の PinMode と PinStatus の enum 宣言を見つけ、既存の Arduino コード全体におけるソース互換性およびバイナリ互換性への影響を評価します。完了条件は、提案されている基底型 uint8_t を受け入れ可能かどうかについてプロジェクトとして判断することです。なお、issue 自体は本番環境での採用を推奨していません。

索引モデルが issue の本文から書いたものです。

評価

領域
embedded-iot
issue の種類
リファクタリング
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
18/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。