Hi James,

Callouts are perfect for this type of function. I’d recommend multiplexing this within the task context you are running out of. Essentially the logic works like:

- Turn the LED on
- Set a callout for 1 second to turn the LED back off

If your task is waiting on an event queue, it will process that event in one second.

More information on callouts and event queues can be found here:

- Tutorial on using these: http://mynewt.apache.org/os/tutorials/event_queue/
- Callouts: http://mynewt.apache.org/os/core_os/callout/callout/
- Event Queues: http://mynewt.apache.org/os/core_os/event_queue/event_queue/

You don’t need to add a specific task for the LED function, you can just multiplex it as an event. If you want to create a separate task (so that it has higher priority, or doesn’t block/isn’t blocked by other functions), you can.

Sterling

On 28 May 2016, at 14:39, James Howarth wrote:

Hi,

I want to be able to flash an LED on for ~1 second when some condition
occurs.  I don't want this to be flashing all the time like the blinky
example.

What's the right way to add a task that runs only once? Or should I not be
using a task at all for this?

Cheers
James

Reply via email to