ReduxLib C++ 2024.1.1-beta0
Loading...
Searching...
No Matches
redux::sensors::canandcolor::CanandcolorSettings Class Reference

#include <CanandcolorSettings.h>

Inheritance diagram for redux::sensors::canandcolor::CanandcolorSettings:
redux::canand::CanandSettings

Public Member Functions

const std::vector< uint8_t > & SettingAddresses () const override
 
void SetStatusFramePeriod (units::second_t period)
 
void SetProximityFramePeriod (units::second_t period)
 
void SetColorFramePeriod (units::second_t period)
 
void SetDigoutFramePeriod (units::second_t period)
 
void SetFramePeriodLatencyAdjustment (bool adjust)
 
void SetLampLED (bool lamp)
 
void SetLampLEDBrightness (double brightness)
 
void SetProximityConfig (CanandcolorProximityConfig &cfg)
 
void SetColorConfig (CanandcolorColorPeriod period)
 
void SetDigoutOutputMode (CanandcolorDigout digout, DigoutMode config)
 
std::optional< units::second_t > GetStatusFramePeriod ()
 
std::optional< units::second_t > GetProximityFramePeriod ()
 
std::optional< units::second_t > GetColorFramePeriod ()
 
std::optional< units::second_t > GetDigoutFramePeriod ()
 
std::optional< bool > GetFramePeriodLatencyAdjustment ()
 
std::optional< bool > GetLampLED ()
 
std::optional< double > GetLampLEDBrightness ()
 
std::optional< CanandcolorProximityConfigGetProximityConfig ()
 
std::optional< CanandcolorColorPeriodGetColorConfig ()
 
std::optional< DigoutModeGetDigoutOutputMode (CanandcolorDigout digout)
 
- Public Member Functions inherited from redux::canand::CanandSettings
 CanandSettings ()=default
 
 CanandSettings (CanandSettings &stg)
 
 ~CanandSettings ()=default
 
std::unordered_map< uint8_t, uint64_t > FilteredMap ()
 
bool AllSettingsReceived () const
 
virtual const std::vector< uint8_t > & SettingAddresses () const
 
std::unordered_map< uint8_t, uint64_t > & GetMap ()
 
bool IsEmpty () const
 
bool IsEphemeral () const
 
void SetEphemeral (bool value)
 
std::string ToString ()
 

Additional Inherited Members

- Protected Attributes inherited from redux::canand::CanandSettings
std::unordered_map< uint8_t, uint64_t > values
 
bool ephemeral = false
 

Detailed Description

The settings class for the Canandcolor.

This class holds settings values that can be used to reconfigure Canandcolor via Canandcolor::SetSettings. Additionally, objects of this class are returned from Canandcolor::GetSettings which can be used to read the device's settings.

Canandcolor canandcolor{0};
// Only settings that are explicitly set here will be edited, so other settings
// such as the status frame period will remain untouched.
stg.SetProximityFramePeriod(0_ms); // disables proximity reading updates
stg.SetColorFramePeriod(0.020_ms); // sets the rate of color measurements to every 20 ms
stg.SetColorConfig(CanandcolorColorPeriod::k80ms); // sets the color integration period to 80 milliseconds
// canandcolor.SetSettings will block by default for up to 500 ms to confirm all values were set.
canandcolor.SetSettings(stg);
Definition: CanandcolorSettings.h:53
void SetProximityFramePeriod(units::second_t period)
Definition: Canandcolor.h:77
@ k80ms
Definition: CanandcolorData.h:103

Note that all Get[setting name] functions may return -1 if they're not populated as CanandcolorSettings objects may not always have a value set for a setting. This is particularly true of instances returned by Canandcolor::GetSettingsAsync(), and you will need to use CanandcolorSettings::AllSettingsReceived() to check if all are present.

However, objects returned by the blocking Canandcolor::GetSettings method will always have all setting values populated.

Example blocking fetch:

Canandcolor canandcolor{0};
CanandcolorSettings stg = canandcolor.GetSettings(0.5_s); // wait up to 500 ms
if (stg.AllSettingsReceived()) { // check if settings received properly. if so, none of the getters will return std::nullopt
fmt::print("status frame period: {}\n", *stg.GetStatusFramePeriod()); // print the status frame period (usually 1000 ms)
}
bool AllSettingsReceived() const
Definition: CanandSettings.h:55
std::optional< units::second_t > GetStatusFramePeriod()

Member Function Documentation

◆ GetColorConfig()

std::optional< CanandcolorColorPeriod > redux::sensors::canandcolor::CanandcolorSettings::GetColorConfig ( )

Gets the device's sampling/integration period for the color sensor, if set.

Returns
CanandcolorColorPeriod enum or std::nullopt if unset

◆ GetColorFramePeriod()

std::optional< units::second_t > redux::sensors::canandcolor::CanandcolorSettings::GetColorFramePeriod ( )

Gets the color frame period in seconds [0..65.535], or std::nullopt if the value has not been set on this object. A value of 0 means color messages are disabled.

Returns
the frame period in seconds [0..65.535], or std::nullopt if the value has not been set on this object.

◆ GetDigoutFramePeriod()

std::optional< units::second_t > redux::sensors::canandcolor::CanandcolorSettings::GetDigoutFramePeriod ( )

Gets the digout status frame period in seconds [0..65.535], or std::nullopt if the value has not been set on this object. A value of 0 means digout status messages are disabled.

Returns
the frame period in seconds [0..65.535], or std::nullopt if the value has not been set on this object.

◆ GetDigoutOutputMode()

std::optional< DigoutMode > redux::sensors::canandcolor::CanandcolorSettings::GetDigoutOutputMode ( CanandcolorDigout  digout)

Sets the output mode configuration of a digital output pad.

Parameters
digoutthe digital output config to fetch
Returns
DigoutMode or null if unset

◆ GetFramePeriodLatencyAdjustment()

std::optional< bool > redux::sensors::canandcolor::CanandcolorSettings::GetFramePeriodLatencyAdjustment ( )

Gets whether or not to transmit frame periods early if data has just been received. By factory default this setting is enabled.

Returns
true if on, false if off, std::nullopt if unset

◆ GetLampLED()

std::optional< bool > redux::sensors::canandcolor::CanandcolorSettings::GetLampLED ( )

Gets whether or not the onboard lamp LED setting is to be on.

Returns
true if on, false if off, std::nullopt if unset

◆ GetLampLEDBrightness()

std::optional< double > redux::sensors::canandcolor::CanandcolorSettings::GetLampLEDBrightness ( )

Gets the lamp LED's brightness, scaled from 0.0 (off) to 1.0 (max)

Returns
the brightness factor [0.0..1.0] or std::nullopt if unset

◆ GetProximityConfig()

std::optional< CanandcolorProximityConfig > redux::sensors::canandcolor::CanandcolorSettings::GetProximityConfig ( )

Gets whether or not the onboard lamp LED setting is to be on.

Returns
true if on, false if off, std::nullopt if unset

◆ GetProximityFramePeriod()

std::optional< units::second_t > redux::sensors::canandcolor::CanandcolorSettings::GetProximityFramePeriod ( )

Gets the proximity frame period in seconds [1..65.535], or std::nullopt if the value has not been set on this object. A value of 0 means proximity messages are disabled.

Returns
the frame period in seconds [0..65.535], or std::nullopt if the value has not been set on this object.

◆ GetStatusFramePeriod()

std::optional< units::second_t > redux::sensors::canandcolor::CanandcolorSettings::GetStatusFramePeriod ( )

Gets the status frame period in seconds [1..65.535], or std::nullopt if the value has not been set on this object.

Returns
the status frame period in seconds [1..65.535], or std::nullopt if the value has not been set on this object.

◆ SetColorConfig()

void redux::sensors::canandcolor::CanandcolorSettings::SetColorConfig ( CanandcolorColorPeriod  period)

Sets the sampling/integration period for the color sensor.

Parameters
periodthe CanandcolorColorPeriod to apply

◆ SetColorFramePeriod()

void redux::sensors::canandcolor::CanandcolorSettings::SetColorFramePeriod ( units::second_t  period)

Sets the color frame period in seconds. By factory default, color frames are broadcast every 40 milliseconds (period=0.04). If 0 is passed in, color frames will be disabled and Canandcolor::GetColor() and other color-reading methods will not return new values.

Parameters
periodthe new period for color frames in seconds in range [0_s, 65.535_s].

◆ SetDigoutFramePeriod()

void redux::sensors::canandcolor::CanandcolorSettings::SetDigoutFramePeriod ( units::second_t  period)

Sets the digital output (digout) frame period in seconds. By factory default, digout frames are broadcast every 100 milliseconds (period=0.10). If 0 is passed in, digout frames will be disabled and Canandcolor::GetDigoutState() will not return new values.

Parameters
periodthe new period for digout frames in seconds in range [0_s, 65.535_s].

◆ SetDigoutOutputMode()

void redux::sensors::canandcolor::CanandcolorSettings::SetDigoutOutputMode ( CanandcolorDigout  digout,
DigoutMode  config 
)

Sets the output mode of a digital output pad.

Digout pins can be set into one of three modes:

  • disabled, by passing in DigoutMode::Disabled()
  • high or low via digout slots, by passing in DigoutMode::DigoutSlot() and using Canandcolor::SetDigoutSlot
  • a duty cycle (PWM) output of values from either the color or proximity sensor, by passing in DigoutMode::DutyCycle)
Parameters
digoutthe digout to configure (either CanandcolorDigout::kDigout1 or CanandcolorDigout::kDigout2)
configa DigoutMode specifying how the digital output should output if at all. See DigoutMode for example usage.

◆ SetFramePeriodLatencyAdjustment()

void redux::sensors::canandcolor::CanandcolorSettings::SetFramePeriodLatencyAdjustment ( bool  adjust)

Sets whether or not to transmit frame periods early if data has just been received. This applies only in the case where frame periods for color and proximity are equal to or less than the configured sampling periods of their corresponding ICs, which is true by default.

This increases CAN utilization a little, but minimizes latency.

By factory default this setting is enabled.

Parameters
adjustWhether to enable latency adjustment

◆ SetLampLED()

void redux::sensors::canandcolor::CanandcolorSettings::SetLampLED ( bool  lamp)

Sets whether or not the onboard lamp LED is to be powered.

The LED can als be physically turned off regardless of setting with the onboard switch.

The LED is useful for measuring the color of objects that do not themselves emit light (e.g. most game pieces) or for using the white channel to estimate very close proximity.

By factory default this setting is enabled.

Parameters
lampwhether to enable or disable the lamp LED

◆ SetLampLEDBrightness()

void redux::sensors::canandcolor::CanandcolorSettings::SetLampLEDBrightness ( double  brightness)

Sets the brightness of the onboard lamp LED.

The LED can als be physically turned off regardless of setting with the onboard switch.

By factory default this setting is set to max brightness (1.0)

Parameters
brightnessscaled brightness from 0.0 (off) to 1.0 (max brightness)

◆ SetProximityConfig()

void redux::sensors::canandcolor::CanandcolorSettings::SetProximityConfig ( CanandcolorProximityConfig cfg)

Sets fine-tuned settings for the proximity sensor through values in a CanandcolorProximityConfig object.

Parameters
cfgthe configruation object to apply setings from

◆ SetProximityFramePeriod()

void redux::sensors::canandcolor::CanandcolorSettings::SetProximityFramePeriod ( units::second_t  period)

Sets the proximity frame period in seconds. By factory default, proximity frames are broadcast every 10 milliseconds (period=0.01). If 0 is passed in, proximity frames will be disabled and Canandcolor::GetProximity() will not return new values.

Parameters
periodthe new period for proximity frames in seconds in range [0_s, 65.535_s].

◆ SetStatusFramePeriod()

void redux::sensors::canandcolor::CanandcolorSettings::SetStatusFramePeriod ( units::second_t  period)

Sets the status frame period in seconds. By factory default, the device will broadcast 1 status message every second (period=1.0).

Parameters
periodthe new period for status frames in seconds in range [1.0_s, 65.535_s].

◆ SettingAddresses()

const std::vector< uint8_t > & redux::sensors::canandcolor::CanandcolorSettings::SettingAddresses ( ) const
overridevirtual

Gets the array of settings addresses this settings class records.

Returns
DetailsKey array

Reimplemented from redux::canand::CanandSettings.


The documentation for this class was generated from the following file: