iota
1.0.0
Flexible, pipeline-based input handling.
|
Poll inputs and listen for changes. More...
Public Member Functions | |
def | on (input_callback, event_name, pipeline, callback, taplength=150) |
Add an input to the poller. More... | |
def | tick () |
Poll all the inputs. More... | |
Poll inputs and listen for changes.
This class will poll inputs and listen for changes, and then run pipelines and callbacks once a change is detected. This class is also responsible for detecting and recognizing different, more high-level types of inputs, which are defined in the Events
class.
def iota.Poller.on | ( | input_callback, | |
event_name, | |||
pipeline, | |||
callback, | |||
taplength = 150 |
|||
) |
Add an input to the poller.
When the poller recognizes the event, it will pass the input through the pipeline and call the callback with the resulting value.
input_callback | The callback for getting the input. This can be a function that returns wpilib.Joystick.getRawAxis(x) , for example. |
event_name | An Events enum value describing what to listen for. |
pipeline | The pipeline. This is passed directly into a Pipeline constructor. Thus, this value can be of any type supported by the Pipeline.add() function. |
taplength | Define how long, in milliseconds, a tap is. This is by default 150ms. You can also set taplength to 0ms to make the poller call Events.PRESSED immediately, if you really don't care for the distinction between tapping and pressing. |
def iota.Poller.tick | ( | ) |
Poll all the inputs.
This function probably shouldn't be called anywhere besides in a specialized Command class that is run over and over again by the main Robot class. However, it should be called often, as much of the functionality depends on millisecond speeds to measure and detect high-level input patterns. TODO: Perhaps consider polling and executing pipelines asynchronously. This isn't implemented yet because it might not be necessary (I doubt it will be), and it might not even be a performance boost depending on the roborio hardware.