@@ -185,12 +185,72 @@ methods:
185185 signal events. The stream yields ` <struct-name><method-name-in-pascal-case>Args ` structs
186186 (e.g., ` ControllerPowerErrorArgs ` ) containing all signal arguments as public fields.
187187
188+ ## Poll Methods
189+
190+ Methods can be marked for periodic execution using poll attributes. These methods are called
191+ automatically by the controller's ` run() ` loop at the specified interval.
192+
193+ Three time unit attributes are supported:
194+ * ` #[controller(poll_seconds = N)] ` - Poll every N seconds.
195+ * ` #[controller(poll_millis = N)] ` - Poll every N milliseconds.
196+ * ` #[controller(poll_micros = N)] ` - Poll every N microseconds.
197+
198+ Example:
199+ ``` rust,no_run
200+ use firmware_controller::controller;
201+
202+ #[controller]
203+ mod sensor_controller {
204+ pub struct Controller {
205+ #[controller(publish)]
206+ temperature: f32,
207+ }
208+
209+ impl Controller {
210+ // Called every 5 seconds.
211+ #[controller(poll_seconds = 5)]
212+ pub async fn read_temperature(&mut self) {
213+ // Read from sensor and update state.
214+ self.set_temperature(42.0).await;
215+ }
216+
217+ // Called every 100ms.
218+ #[controller(poll_millis = 100)]
219+ pub async fn check_watchdog(&mut self) {
220+ // Pet the watchdog.
221+ }
222+
223+ // Both called every second (grouped together).
224+ #[controller(poll_seconds = 1)]
225+ pub async fn log_status(&self) {
226+ // Log current status.
227+ }
228+
229+ #[controller(poll_seconds = 1)]
230+ pub async fn blink_led(&mut self) {
231+ // Toggle LED.
232+ }
233+ }
234+ }
235+
236+ fn main() {}
237+ ```
238+
239+ Key characteristics:
240+ * Poll methods are ** not** exposed in the client API. They are internal periodic tasks managed
241+ entirely by the controller's ` run() ` loop.
242+ * Methods with the same timeout value (same unit and value) are grouped into a single timer arm
243+ and called sequentially when the timer fires (in declaration order).
244+ * Uses ` embassy_time::Ticker ` for timing, which ensures consistent intervals regardless of method
245+ execution time.
246+
188247## Dependencies assumed
189248
190249The ` controller ` macro assumes that you have the following dependencies in your ` Cargo.toml ` :
191250
192251* ` futures ` with ` async-await ` feature enabled.
193252* ` embassy-sync `
253+ * ` embassy-time ` (only required if using poll methods)
194254
195255## Known limitations & Caveats
196256
0 commit comments