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
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100