arduino / arduino/ArduinoCore-API
Add API to advance millis() and micros()
- 主要语言
- C++
- 星标
- 306
- 派生
- 150
- PR 合并指标
- 30 天内没有已合并 PR
描述
When an AVR MCU sleeps in power-down mode, it's clock stops running. Typically time is being kept using the watchdog timer, or an asynchronous timer2, to allow waking up after a specified time. However, the `millis()` and `micros()` counters are not updated during sleep, meaning that the sketch needs to jump through hoops (manually offsetting these counters, or modifying Arduino's global variables) to make various timing work. The former only works with sketch code, not libraries that rely on both counters, and the latter is obviously very ugly and non-portable.
Ideally, there would be an API that allows modifying the millis() and micros() timers by adding (or perhaps also subtracting?) a specified time from both. Most obvious would be an int32_t specifying the number of microseconds. This allows offsetting the time by about 35 minutes in one call. Alternatively, specifying both millis and micros separately would increase the range, but also complicate the code a bit (needing actual division instead of just bitshifting, I think). In either case, I'd say that both counters are always updated at the same time and stay in sync, not being updated individually.
贡献指南
这个仓库没有索引到贡献指南
调研方向
首先定位 millis() 和 micros() 的声明与实现。检查两个计数器如何保持同步,然后确定 API 应该加上或减去一个共享的 int32_t 微秒偏移量,还是接受分别传入的毫秒值和微秒值。完成的标准是,与 sleep 相关的代码可以在不修改 Arduino 全局变量的情况下同时推进两个计时器。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- cpp
- 领域
- embedded-iot
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100