arduino / arduino/ArduinoCore-API
Add API to advance millis() and micros()
- Lenguaje dominante
- C++
- Estrellas
- 306
- Forks
- 150
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Comienza localizando las declaraciones e implementaciones de millis() y micros(). Revisa cómo se mantienen sincronizados ambos contadores y, después, resuelve si la API debe sumar o restar un desplazamiento compartido de microsegundos de tipo int32_t, o aceptar valores separados de milisegundos y microsegundos. Se considera terminado cuando el código relacionado con sleep pueda avanzar ambos temporizadores a la vez sin modificar las variables globales de Arduino.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- cpp
- Área
- embedded-iot
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100