Helper class that supports the Hue and Saturation colour mode.
More...
#include <colour_control.h>
|
static int32_t | invert_angle (int32_t angle, uint16_t max_value) |
| Helper method to invert a traveling angle. More...
|
|
static int32_t | get_travel_distance (const Direction dir, uint16_t initial, uint16_t final, uint16_t max) |
| Helper method to get the angle between two hue/saturation values. More...
|
|
|
static constexpr uint16_t | min_size |
| Minimum pack/unpack required data size.
|
|
Helper class that supports the Hue and Saturation colour mode.
This class implements the necessary functions for message serialization.
Definition at line 117 of file colour_control.h.
◆ HS_Colour()
HF::Interfaces::ColourControl::HS_Colour::HS_Colour |
( |
uint16_t |
_hue, |
|
|
uint8_t |
_saturation |
|
) |
| |
|
inline |
Constructor.
- Parameters
-
[in] | _hue | hue colour value. |
[in] | _saturation | saturation colour value. |
Definition at line 130 of file colour_control.h.
131 saturation(_saturation)
133 hue = _hue < HUE ? _hue : HUE - 1;
◆ changed()
float HF::Interfaces::ColourControl::HS_Colour::changed |
( |
const HS_Colour & |
other | ) |
const |
|
inline |
This method is used to get the percentage of change that the attribute has in relation to the value present in other
.
- Parameters
-
[in] | other | attribute holding a previous value. |
- Returns
- float indicating the percentage of change.
Definition at line 210 of file colour_control.h.
212 if (this->hue != other.hue)
214 return (100 * (this->hue - other.hue) / static_cast<float>(this->hue));
218 if (this->hue != other.hue)
220 return (100 * (this->hue - other.hue) / static_cast<float>(this->hue));
◆ compare()
int HF::Interfaces::ColourControl::HS_Colour::compare |
( |
const HS_Colour & |
other | ) |
const |
|
inline |
Compare this attribute with the given attribute in other
.
This method should return < 0 if this attribute is less that, 0 if it is equal and > 0 if greater that the other
attribute.
- Parameters
-
[in] | other | attribute to compare to. |
- Return values
-
<0 | if attribute less than other ; |
0 | if attribute equal to other ; |
>0 | if attribute greater than other . |
Definition at line 190 of file colour_control.h.
192 if (this->hue != other.hue)
194 return (this->hue - other.hue);
198 if (this->hue != other.hue)
200 return (this->hue - other.hue);
◆ get_travel_distance()
static int32_t HF::Interfaces::ColourControl::HS_Colour::get_travel_distance |
( |
const Direction |
dir, |
|
|
uint16_t |
initial, |
|
|
uint16_t |
final, |
|
|
uint16_t |
max |
|
) |
| |
|
static |
Helper method to get the angle between two hue/saturation values.
This method takes in consideration the direction of travel from the initial to the final value.
- Parameters
-
[in] | dir | the travel direction. |
[in] | initial | the initial value. |
[in] | final | the final value. |
[in] | max | the maximum value. |
- Returns
- the angle between the final and initial value.
◆ invert_angle()
static int32_t HF::Interfaces::ColourControl::HS_Colour::invert_angle |
( |
int32_t |
angle, |
|
|
uint16_t |
max_value |
|
) |
| |
|
static |
Helper method to invert a traveling angle.
This method returns the exterior angle from an internal one, or an interior from an exterior angle.
- Note
- This also inverts the angle signal. If the input angle is positive (CW rotation), the output is negative (CCW rotation).
- Parameters
-
[in] | angle | the angle to invert. |
[in] | max_value | the max value for the angle. |
- Returns
- the inverted angle.
◆ pack()
uint16_t HF::Interfaces::ColourControl::HS_Colour::pack |
( |
Common::ByteArray & |
array, |
|
|
uint16_t |
offset = 0 |
|
) |
| const |
Write the object on to a ByteArray so it can be sent over the network.
The buffer passed in MUST have enough size to hold the serialized object, e.g.,
Serializable obj;
ByteArray payload(obj.size());
obj.pack(payload);
- Parameters
-
[in,out] | array | ByteArray reference to write the object to. |
[in] | offset | offset to start writing to. |
- Returns
- the number of bytes written.
◆ size()
uint16_t HF::Interfaces::ColourControl::HS_Colour::size |
( |
| ) |
const |
|
inline |
Number bytes needed to serialize the message.
- Returns
- number of bytes the message requires to be serialized.
Definition at line 178 of file colour_control.h.
References min_size.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
◆ unpack()
uint16_t HF::Interfaces::ColourControl::HS_Colour::unpack |
( |
const Common::ByteArray & |
array, |
|
|
uint16_t |
offset = 0 |
|
) |
| |
Read a message from a ByteArray.
- Parameters
-
[in] | array | ByteArray reference to read the message from. |
[in] | offset | offset to start reading from. |
- Returns
- the number of bytes read.
The documentation for this struct was generated from the following file: