Interface DigoutSlot
- All Known Implementing Classes:
DigoutSlot.CompareAffine
,DigoutSlot.CompareImmidiate
,DigoutSlot.Disabled
,DigoutSlot.PrevClauseTrueFor
,DigoutSlot.PrevSlotTrueFor
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.DataSource
s 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:
-
DigoutSlot.Disabled
for disabled/unused slots -
DigoutSlot.CompareImmidiate
for comparing against constants -
DigoutSlot.CompareAffine
for comparing between data sources -
DigoutSlot.PrevSlotTrueFor
for checking duration -
DigoutSlot.PrevClauseTrueFor
for similar purposes
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()
.
Canandcolor.setDigoutSlot(com.reduxrobotics.sensors.canandcolor.Canandcolor.Digout, int, com.reduxrobotics.sensors.canandcolor.digout.DigoutSlot, double)
to configure the Canandcolor's slots.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final record
ADigoutSlot
that compares two data sources against each other, while scaling and offsetting the first data slot's value.static final record
ADigoutSlot
that compares a data source against a constant value.static final record
A disabled and unconfiguredDigoutSlot
.static final record
ADigoutSlot
that is true if the preceding clause has been true for at least a certain period of time.static final record
ADigoutSlot
that is true if the previous lower-indexed slot has been true for at least a certain period of time. -
Method Summary
Modifier and TypeMethodDescriptionstatic long
encodeSlot
(ClauseAction clause, boolean invert, SlotOpcode opcode, int arg1, int arg2) Encodes a slot that can be written in a set settings packet.static DigoutSlot
fromSettingData
(long data) Deserializes a 48-bit setting value into aDigoutSlot
object.long
Serializes the digout slot into a value writeable to device settings.
-
Method Details
-
fromSettingData
Deserializes a 48-bit setting value into aDigoutSlot
object.- Parameters:
data
- setting data- Returns:
DigoutSlot
object
-
encodeSlot
Encodes a slot that can be written in a set settings packet. The record classes use this to serialize themselves for transmission intoSettingData()
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.- Parameters:
clause
- the clause behavior of the slotinvert
- whether to invert the opcode's resultopcode
- the opcode the slot should executearg1
- 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.- Returns:
- 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.- Returns:
- 48-bit long
-