Class CanandcolorProximityConfig
java.lang.Object
com.reduxrobotics.sensors.canandcolor.CanandcolorProximityConfig
Class representing the internal configuration of the Canandcolor's proximity IC.
Generally passed to functions in
Canandcolor.Settings
which may be then used with
Canandcolor.setSettings(com.reduxrobotics.sensors.canandcolor.Canandcolor.Settings, double, int)
to configure the device.
The default values that ship with the Canandcolor are good for the vast majority of cases so tweaking these settings isn't necessary, especially as the distances that these settings really make a difference at are generally too small (think <1cm) to matter, and the power savings are generally not useful at FRC scales. However, we still include them for completeness as theoretically they may still be useful to someone -- please let us know if they are!
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Represents the valid integration periods for the proximity sensor.static enum
Determines how much current gets dumped into the IR LED and thus its intensity.static enum
Determines how many IR LED pulses get sent out during proximity reads.static enum
Represents the valid sampling periods for the proximity sensor. -
Constructor Summary
ConstructorDescriptionInitializes a new proximity config with the default recommended values.CanandcolorProximityConfig
(int field) Initializes the config with a long as returned by a report settings CAN message (used internally).Initializes the config with the values from anotherCanandcolorProximityConfig
object (copy constructor).CanandcolorProximityConfig
(CanandcolorProximityConfig.SamplingPeriod samplingPeriod, CanandcolorProximityConfig.IntegrationPeriod integrationPeriod, CanandcolorProximityConfig.LEDCurrent ledCurrent, CanandcolorProximityConfig.MultiPulse multiPulse, boolean highGainMode, boolean sunlightCancellation, int offsetCancellation) Initializes the config setting every possible field at once. -
Method Summary
Modifier and TypeMethodDescriptionint
getField()
Returns the internal integer representation of the proximity config which gets written over the wire to the device.boolean
Returns whether or not high gain mode is enabled or not.Returns the sensor integration period associated with this proximity configReturns the sensor LED current associated with this proximity configReturns the sensor multi-pulse value associated with this proximity configint
Returns the 12-bit offset that is subtracted from readings to compensate for ambient IR.Returns the sampling period associated with this proximity configboolean
Returns whether or not sunlight cancellation is enabled or not.setHighGainMode
(boolean hg) Sets whether to use high gain mode.Sets the proximity sensor integration period config.Sets the proximity sensor LED currentconfig.Sets the proximity sensor multi-pulse config.setOffsetCancellationValue
(int canc) Sets a fixed 12-bit value to subtract from readings to compensate for ambient IR.Sets the proximity sensor sampling period config.setSunlightCancellation
(boolean sunlight) Sets whether to use sunlight cancellation.
-
Constructor Details
-
CanandcolorProximityConfig
public CanandcolorProximityConfig()Initializes a new proximity config with the default recommended values. -
CanandcolorProximityConfig
public CanandcolorProximityConfig(int field) Initializes the config with a long as returned by a report settings CAN message (used internally).- Parameters:
field
- the raw data field from the report settings message (see the official Canandcolor device spec for more information)
-
CanandcolorProximityConfig
public CanandcolorProximityConfig(CanandcolorProximityConfig.SamplingPeriod samplingPeriod, CanandcolorProximityConfig.IntegrationPeriod integrationPeriod, CanandcolorProximityConfig.LEDCurrent ledCurrent, CanandcolorProximityConfig.MultiPulse multiPulse, boolean highGainMode, boolean sunlightCancellation, int offsetCancellation) Initializes the config setting every possible field at once.- Parameters:
samplingPeriod
- the sensor sampling periodintegrationPeriod
- the sensor integration periodledCurrent
- the sensor's led currentmultiPulse
- the sensor's multi-pulse confighighGainMode
- whether to enable high-gain modesunlightCancellation
- whether to enable sunlight cancellationoffsetCancellation
- the raw offset to subtract from the output
-
CanandcolorProximityConfig
Initializes the config with the values from anotherCanandcolorProximityConfig
object (copy constructor).- Parameters:
cfg
- the object to copy from.
-
-
Method Details
-
getSamplingPeriod
Returns the sampling period associated with this proximity config -
getIntegrationPeriod
Returns the sensor integration period associated with this proximity config -
getLEDCurrent
Returns the sensor LED current associated with this proximity config- Returns:
CanandcolorProximityConfig.LEDCurrent
- See Also:
-
getMultiPulse
Returns the sensor multi-pulse value associated with this proximity config- Returns:
CanandcolorProximityConfig.MultiPulse
- See Also:
-
getHighGainMode
public boolean getHighGainMode()Returns whether or not high gain mode is enabled or not.- Returns:
- high gain mode
-
getSunlightCancellation
public boolean getSunlightCancellation()Returns whether or not sunlight cancellation is enabled or not.- Returns:
- sunlight cancellation state
-
getOffsetCancellationValue
public int getOffsetCancellationValue()Returns the 12-bit offset that is subtracted from readings to compensate for ambient IR.- Returns:
- offset value
-
setSamplingPeriod
public CanandcolorProximityConfig setSamplingPeriod(CanandcolorProximityConfig.SamplingPeriod period) Sets the proximity sensor sampling period config. For more information seeCanandcolorProximityConfig.SamplingPeriod
- Parameters:
period
- theCanandcolorProximityConfig.SamplingPeriod
to use- Returns:
- calling object (so calls may be chained)
-
setIntegrationPeriod
public CanandcolorProximityConfig setIntegrationPeriod(CanandcolorProximityConfig.IntegrationPeriod period) Sets the proximity sensor integration period config. For more information seeCanandcolorProximityConfig.IntegrationPeriod
.- Parameters:
period
- theCanandcolorProximityConfig.IntegrationPeriod
to use.- Returns:
- calling object (so calls may be chained)
-
setLEDCurrent
Sets the proximity sensor LED currentconfig. For more information seeCanandcolorProximityConfig.LEDCurrent
.- Parameters:
current
- theCanandcolorProximityConfig.LEDCurrent
to use.- Returns:
- calling object (so calls may be chained)
-
setMultiPulse
Sets the proximity sensor multi-pulse config. For more information seeCanandcolorProximityConfig.MultiPulse
.- Parameters:
pulse
- theCanandcolorProximityConfig.MultiPulse
to use.- Returns:
- calling object (so calls may be chained)
-
setHighGainMode
Sets whether to use high gain mode.- Parameters:
hg
- true=high gain, false=disabled (default)- Returns:
- calling object (so calls may be chained)
-
setSunlightCancellation
Sets whether to use sunlight cancellation. May be useful on open air baseball fields with painfully loud speakers.- Parameters:
sunlight
- true=sunlight cancellation, false=disabled (default)- Returns:
- calling object (so calls may be chained)
-
setOffsetCancellationValue
Sets a fixed 12-bit value to subtract from readings to compensate for ambient IR.- Parameters:
canc
- the value to subtract- Returns:
- calling object (so calls may be chained)
-
getField
public int getField()Returns the internal integer representation of the proximity config which gets written over the wire to the device.- Returns:
- relevant integer.
-