arduino / arduino/ArduinoCore-API

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

未关闭
#109 6 条评论 0 个 reaction 已指派 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
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
18/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。