Package crackers.kobots.devices.io
        Class QwiicTwist
- 
                    
                    
- All Implemented Interfaces:
 - 
                            
                            
com.diozero.api.DeviceInterface,com.diozero.api.DigitalInputDeviceInterface,java.lang.AutoCloseable 
public final class QwiicTwist implements DigitalInputDeviceInterfaceA loose Kotlin translation of Python code from https://github.com/fourstix/Sparkfun_CircuitPython_QwiicTwist for the Sparkfun Qwiic Twist.
The basic operation is:
the pretty light is exposed as a WS2811 device
this class is a DigitalInputDeviceInterface device for the button
along with some DSL functions for readability
the encoder can be read (and reset) via several properties
 
- 
                
                    
                    
- 
                                
                            
                                
Nested Class Summary
Nested Classes Modifier and Type Class Description public classQwiicTwist.Companion 
- 
                                
                            
                                
Field Summary
Fields Modifier and Type Field Description public final static IntegerDEFAULT_I2C_BUSpublic final static IntegerDEFAULT_I2C_ADDRESSpublic final static IntegerALTERNATE_I2C_ADDRESSpublic final static BooleanPRESSEDpublic final static ByteIDpublic final static ByteREG_IDpublic final static ByteREG_STATUSpublic final static ByteREG_VERSIONpublic final static ByteREG_ENABLE_INTpublic final static ByteREG_COUNTpublic final static ByteREG_DIFFERENCEpublic final static ByteREG_LAST_ENCODER_EVENTpublic final static ByteREG_LAST_BUTTON_EVENTpublic final static ByteREG_REDpublic final static ByteREG_GREENpublic final static ByteREG_BLUEpublic final static ByteREG_RED_CONNECTpublic final static ByteREG_GREEN_CONNECTpublic final static ByteREG_BLUE_CONNECTpublic final static ByteTURN_INT_TIMEOUTpublic final static ByteCHANGE_ADDRESSpublic final static IntegerBUTTON_CLICKED_BITpublic final static IntegerBUTTON_PRESSED_BITpublic final static IntegerENCODER_MOVED_BITpublic final static IntegerBUTTON_INT_ENABLEpublic final static IntegerENCODER_INT_ENABLEprivate final WS2811pixelprivate Integercountprivate Triple<Integer, Integer, Integer>colorConnectionprivate IntegerencoderInterruptTimeoutprivate final Integerversionprivate final Booleanmovedprivate final Booleanpressedprivate final Booleanclickedprivate final Integerdifferenceprivate final IntegertimeSinceLastMovementprivate final IntegertimeSinceLastPresspublic final static QwiicTwist.CompanionCompanion 
- 
                                
                            
                                
Constructor Summary
Constructors Constructor Description QwiicTwist(I2CDeviceInterface device) 
- 
                                
                            
                                
Method Summary
Modifier and Type Method Description final WS2811getPixel()The on-board RGB LED. final IntegergetCount()final UnitsetCount(Integer count)final Triple<Integer, Integer, Integer>getColorConnection()final UnitsetColorConnection(Triple<Integer, Integer, Integer> colorConnection)final IntegergetEncoderInterruptTimeout()final UnitsetEncoderInterruptTimeout(Integer encoderInterruptTimeout)final IntegergetVersion()final BooleangetMoved()final BooleangetPressed()final BooleangetClicked()final IntegergetDifference()final IntegergetTimeSinceLastMovement()final IntegergetTimeSinceLastPress()Unitclose()BooleangetValue()final Booleanbutton(Boolean test)DSL to test the button state. final UnitclearInterrupts()Clear all the interrupt registers. final UnitchangeAddress(Integer newAddress)Changes the address of the board. - 
                    
                    
                    
- 
                                
                            
                                
Method Detail
- 
                                        
getColorConnection
final Triple<Integer, Integer, Integer> getColorConnection()
 
- 
                                        
getEncoderInterruptTimeout
final Integer getEncoderInterruptTimeout()
 
- 
                                        
setEncoderInterruptTimeout
final Unit setEncoderInterruptTimeout(Integer encoderInterruptTimeout)
 
- 
                                        
getVersion
final Integer getVersion()
 
- 
                                        
getPressed
final Boolean getPressed()
 
- 
                                        
getClicked
final Boolean getClicked()
 
- 
                                        
getDifference
final Integer getDifference()
 
- 
                                        
getTimeSinceLastMovement
final Integer getTimeSinceLastMovement()
 
- 
                                        
getTimeSinceLastPress
final Integer getTimeSinceLastPress()
 
- 
                                        
button
final Boolean button(Boolean test)
DSL to test the button state. Note this is only intended for readability. Example:
if (twist button PRESSED) println("True") ``` 
- 
                                        
clearInterrupts
final Unit clearInterrupts()
Clear all the interrupt registers.
 
- 
                                        
changeAddress
final Unit changeAddress(Integer newAddress)
Changes the address of the board. This will close the connection to this board. It is up to the caller of this method to reconnect to the new address.
 
 - 
                                        
 
 - 
                                
                            
                                
 
 - 
                    
                    
                    
 
 -