iota  1.0.0
Flexible, pipeline-based input handling.
Public Member Functions | List of all members
iota.Poller Class Reference

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...
 

Detailed Description

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.

Definition at line 38 of file iota.py.

Member Function Documentation

◆ on()

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.

Parameters
input_callbackThe callback for getting the input. This can be a function that returns wpilib.Joystick.getRawAxis(x), for example.
event_nameAn Events enum value describing what to listen for.
pipelineThe pipeline. This is passed directly into a Pipeline constructor. Thus, this value can be of any type supported by the Pipeline.add() function.
taplengthDefine 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.

Definition at line 63 of file iota.py.

◆ tick()

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.

Definition at line 92 of file iota.py.


The documentation for this class was generated from the following file: