adkron / grovepi

Use the GrovePi in Elixir
Apache License 2.0
47 stars 9 forks source link

Support sensors without polling #14

Closed adkron closed 7 years ago

adkron commented 7 years ago

Some sensors we might want to have polling only part of the time. Like the DHT. I think the DHT is a good candidate to have polling so that events can be fired when a certain humidity is reached, like in a dehumidifier. Sometimes, for resource management or other applications we may not want a continuous polling. I propose that we allow a poll_interval of 0 to be passed to any sensor and have that sensor only work with read. We can even have a stop function that sets the polling interval to 0 so that after the next poll it will not poll any more. There could also be a start_polling function that takes in a new poll_interval and starts up the polling again.

Thoughts?

fhunleth commented 7 years ago

I think this makes sense. Even for buttons, I could imagine people wanting to modify the polling rate if they feel like they're missing events or manually polling if they have a game loop-style application.

adkron commented 7 years ago

Right now the polling rate can be modified by passing in poll_inteval: x as an option to start_link