Interface DigoutSlot

All Known Implementing Classes:
DigoutSlot.CompareAffine, DigoutSlot.CompareImmidiate, DigoutSlot.Disabled, DigoutSlot.PrevClauseTrueFor, DigoutSlot.PrevSlotTrueFor

Represents a digout "slot" which helps determine the digital output's value.

When a Canandcolor.Digout is set in the DigoutMode.DigoutSlot mode, the value of the digital output pin (high or low) is determined by a set of up to 16 "digout slots". These slots can each evaluate a single boolean expression, e.g. "Is the proximity sensor reading above 0.5" or "Is the blue channel reading greater than the red channel minus an offset", and are often able to read from Canandcolor.DataSources to accomplish this.

Each slot can be chained by logical AND, OR, or XOR to form compound expressions of "clauses". All clauses have to evaluate to true for the digital output pin's value to be true. If a slot is not joined to the next indexed slot, it terminates a clause -- terminating slots without any preceding joining slots are single-slot or "singleton" clauses.

Digout slots can take one of a few forms:

While the boolean outputs are to the digital output pads, the boolean state of each slot is also available over CAN. This DigoutSlotState can be retreived using Canandcolor.getDigoutState().

Implementing records can be passed to Canandcolor.setDigoutSlot(com.reduxrobotics.sensors.canandcolor.Canandcolor.Digout, int, com.reduxrobotics.sensors.canandcolor.digout.DigoutSlot, double) to configure the Canandcolor's slots.
  • Method Details

    • fromSettingData

      static DigoutSlot fromSettingData(long data)
      Deserializes a 48-bit setting value into a DigoutSlot object.
      data - setting data
      DigoutSlot object
    • encodeSlot

      static long encodeSlot(ClauseAction clause, boolean invert, SlotOpcode opcode, int arg1, int arg2)
      Encodes a slot that can be written in a set settings packet. The record classes use this to serialize themselves for transmission in toSettingData() For more information on the exact binary format, see the Canandcolor CAN spec. This function assumes you're encoding a slot that's enabled -- a value of 0L will encode a disabled slot anyway.
      clause - the clause behavior of the slot
      invert - whether to invert the opcode's result
      opcode - the opcode the slot should execute
      arg1 - the arg1 of the slot's operation. Only the lowest 16 bits are used.
      arg2 - the arg2 of the slot's operation. Only the lowest 16 bits are used.
      long value that can be written to settings (only lower 48 bits are relevant)
    • toSettingData

      long toSettingData()
      Serializes the digout slot into a value writeable to device settings.
      48-bit long