Skip to content

Implement polling for internal devices#941

Merged
waveform80 merged 7 commits into
masterfrom
sample-internal
Mar 14, 2021
Merged

Implement polling for internal devices#941
waveform80 merged 7 commits into
masterfrom
sample-internal

Conversation

@waveform80
Copy link
Copy Markdown
Member

And clean up event handling generally. All the logic to do with wrapping callbacks, and ensuring watch threads is set up should be handled by the EventsMixin or other helper classes (in this case a property analogue called "event").

Fixes #393

@waveform80 waveform80 requested a review from bennuttall March 13, 2021 18:47
@waveform80 waveform80 added this to the v1.6 milestone Mar 13, 2021
Comment thread gpiozero/mixins.py Outdated
@bennuttall

This comment has been minimized.

@bennuttall

This comment has been minimized.

@bennuttall
Copy link
Copy Markdown
Member

I've added an intro to the internal devices docs page, added when_activated and when_deactivated to each class to precisely document what causes them to fire, and exposed the new PolledInternalDevice class at module top-level (partly because the docs couldn't find it when I included it, but still it could be useful there).

I've also switched some source/values examples to when_activated/deactivated.

A couple of thoughts:

  • We could add aliases like when_available (or something) as google.when_activated doesn't quite seem right
  • Should we expose event_delay in subclasses, so people can overwrite it? Or should we at least document what it's set to for each one.

@bennuttall
Copy link
Copy Markdown
Member

Is wait_for_active hooked up?

bennuttall and others added 5 commits March 14, 2021 03:26
And clean up event handling generally. All the logic to do with wrapping
callbacks, and ensuring watch threads is set up should be handled by the
EventsMixin or other helper classes (in this case a property analogue
called "event").

Fixes #393
@waveform80
Copy link
Copy Markdown
Member Author

Is wait_for_active hooked up?

It should be implicitly by EventsMixin._fire_events - if it doesn't work, that's a bug.

Comment thread docs/api_internal.rst Outdated
Comment thread docs/faq.rst
waveform80 and others added 2 commits March 14, 2021 17:51
In my zeal for efficiency the background thread wasn't running when only
the wait-for methods were called!
@waveform80 waveform80 merged commit 9506ac1 into master Mar 14, 2021
@waveform80 waveform80 deleted the sample-internal branch March 14, 2021 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal Device events don't fire

2 participants