Skip to content

General Canandcolor Settings

The CanandcolorSettings object is used to reconfigure the Canandcolor.

// Create a blank object with no values.
// Only values that are changed will be updated on the device.
CanandcolorSettings settings = new CanandcolorSettings();
// Copy the values to a new settings object.
CanandcolorSettings copiedSettings = new CanandcolorSettings(settings);

Values are fetched and updated using the getter and setter functions in CanandcolorSettings.

When you are ready to send and save the settings to the device, you can use Canandcolor.setSettings to transmit the contents of a CanandcolorSettings object to the Canandcolor.

// A canandcolor object with CAN ID 0
Canandcolor canandcolor = new Canandcolor(0);
// Create a new settings object
CanandcolorSettings settings = new CanandcolorSettings();
// Setup some settings to write:
// set lamp LED brightness to 40%
settings.setLampLEDBrightness(0.4);
// Write the settings to the Canandcolor with a timeout of 50 milliseconds per setting.
// By default the settings will be written to flash -- they will persist on reboots.
// If this is not desired, one can use
//
// settings.setEphemeral(true);
//
// to flag the settings as ephemeral (and not persist in flash on reboot).
canandcolor.setSettings(settings);

Settings can be fetched from the end device in both a synchronous and asynchronous manner. Due to the synchronous method blocking for 0.15-0.25 seconds, it is recommended to use it only in robot initialization or on a separate thread.

The blocking method, Canandcolor.getSettings will always return a CanandcolorSettings object. The object returned will hold all the settings that were able to be successfully received. To check if all settings were successfully received, use the CanandcolorSettings.allSettingsReceived() method.

The async method, Canandcolor.getSettingsAsync will return the most recent set of settings that have been sent by the device since a preceding Canandcolor.startFetchSettings(). Similarly to getSettings, one can use the CanandcolorSettings.allSettingsReceived() method to check for the receipt of all settings.

The getters on CanandcolorSettings objects either return a value if one was received, or null (Java)/std::nullopt (C++) if one was not.

The status frame period is the time between status packets being sent by the Phosphorus Canandcolor over the CAN Bus. By default, this value is 1 second, meaning a status packet is sent every 1000 milliseconds. Lower values will mean packets get sent more frequently, but will correspondingly increase CAN bus utilization. This value cannot be set to zero or disabled. The maximum value of this value is 16.383 seconds (16383 milliseconds). This value is set with a resolution of 0.001 seconds (1 millisecond).

Default value: 1 second

Minimum value: 1 second

Maximum value: 16.383 seconds

// Sets the status frame period to 1 second
settings.setStatusFramePeriod(1);

The proximity frame period is the time between proximity packets being sent by the Phosphorus Canandcolor over the CAN Bus. By default, this value is 0.010 seconds, meaning a proximity packet is sent every 10 milliseconds (for a total of 100 times a second).

This frame period supports aligning the frame to the integration period, which will automatically transmit early when new sensor data is available. In this mode, the frame period is the maximum allowed latency between packets.

Lower values will mean packets get sent more frequently, but will correspondingly increase CAN bus utilization. This value can be set to 0, which disables the proximity output. The maximum value of this value is 65.535 seconds (65535 milliseconds). This value is set with a resolution of 0.001 seconds (1 millisecond).

Default value: 0.010 seconds

Minimum value: 0 seconds (disables proximity output)

Maximum value: 65.535 seconds

// Sets the proximity frame period to 10 milliseconds
settings.setProximityFramePeriod(0.010);
//Optional, aligns the proximity sensor frames to the integration period
//This will cause the sensor to immediately transmit new data when available.
settings.setAlignProximityFramesToIntegrationPeriod(true);

The color frame period is the time between color packets being sent by the Phosphorus Canandcolor over the CAN Bus. By default, this value is 0.040 seconds, meaning a color packet is sent every 40 milliseconds (for a total of 25 times a second).

This frame period supports aligning the frame to the integration period, which will automatically transmit early when new sensor data is available. In this mode, the frame period is the maximum allowed latency between packets.

Lower values will mean packets get sent more frequently, but will correspondingly increase CAN bus utilization. This value can be set to 0, which disables the color output. The maximum value of this value is 65.535 seconds (65535 milliseconds). This value is set with a resolution of 0.001 seconds (1 millisecond).

Default value: 0.040 seconds

Minimum value: 0 seconds (disables color output)

Maximum value: 65.535 seconds

// Sets the color frame period to 40 milliseconds
settings.setColorFramePeriod(0.040);
//Optional, aligns the color sensor frames to the integration period
//This will cause the sensor to immediately transmit new data when available.
settings.setAlignColorFramesToIntegrationPeriod(true);

The digout frame period is the time between digital output status packets being sent by the Phosphorus Canandcolor over the CAN Bus.

The digout packets contain the status of the two digital output lines.

This frame supports emitting packets early on state change. This allows the user code to immediately react to changes in the digital output state instead of needing to wait for the next frames.

By default, this value is 0.100 seconds, meaning a digout packet is sent every 100 milliseconds (for a total of 10 times a second).

Lower values will mean packets get sent more frequently, but will correspondingly increase CAN bus utilization. This value can be set to 0, which disables the digout packet. The maximum value of this value is 65.535 seconds (65535 milliseconds). This value is set with a resolution of 0.001 seconds (1 millisecond).

Default value: 0.100 seconds

Minimum value: 0 seconds (disables digout output)

Maximum value: 65.535 seconds

// Sets the digout frame period to 40 milliseconds
settings.setDigoutFramePeriod(0.040);
//Optional: Tells the device to early transmit a digital output packet if the status changes at all
//This example shows setting it for digital output 1
settings.setDigoutFrameTrigger(DigoutChannel.Index.kDigout1, DigoutFrameTrigger.kRisingAndFalling);

Turns the onboard lamp LED on or off.

Default value: false

// Turn on lamp
settings.setLampLED(true);

Sets the brightness of the onboard lamp LED. The lamp can still be turned on and off via setLampLED and the onboard switch. A value of 1.0 is full brightness, and a value of 0.0 is minimum brightness (off). For example, a value of 0.5 will be half of max brightness.

Default value: 1.0

// Set lamp to full brightness
settings.setLampLEDBrightness(1.0);

See: Canandcolor Proximity Settings

See: Canandcolor Color Settings

See: Canandcolor Digital Ports