7 #define M_PI 3.14159265358979323846 13 : internal_(internal), field_(field) {}
20 ret = std::numeric_limits<float>::quiet_NaN();
40 return std::numeric_limits<double>::quiet_NaN();
42 return (static_cast<double>(revolutions) * 2.0 *
M_PI + static_cast<double>(radian_offset));
48 *radian_offset = std::numeric_limits<float>::quiet_NaN();
53 double revolutions_raw = radians / 2.0 /
M_PI;
54 double revolutions_int_d;
55 double radian_offset_d = std::modf(revolutions_raw, &revolutions_int_d);
56 radian_offset_d = radian_offset_d * 2.0 *
M_PI;
58 int64_t revolutions_int = std::isnan(revolutions_int_d) ? 0 :
static_cast<int64_t
>(revolutions_int_d);
59 float radian_offset =
static_cast<float>(radian_offset_d);
79 ret = std::numeric_limits<float>::quiet_NaN();
100 return static_cast<bool>(ret);
104 auto val =
static_cast<int>(value);
124 auto buffer =
new char[length];
126 std::string tmp(buffer, length - 1);
132 const char* buffer = value.c_str();
133 size_t length = value.size();
197 return Color(r, g, b, a);
void clear()
Removes any currently set value for this field.
void set(const Color &color)
Commands a color that overrides the module's control of the LED (if the alpha channel is 255)...
void clear()
Removes any currently set value for this field.
void hebiCommandSetBool(HebiCommandRef &command, HebiCommandBoolField field, const int32_t *value)
HebiCommandBoolField const field_
HebiStatusCode ledGetter(const RefT &ref, MetadataT &metadata, int field, uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *a)
HebiStatusCode hebiCommandGetString(HebiCommandPtr command, HebiCommandStringField field, char *buffer, size_t *length)
Command API.
HighResAngleField(HebiCommandRef &internal, HebiCommandHighResAngleField field)
HebiCommandHighResAngleField
void hebiCommandSetIoPinFloat(HebiCommandRef &command, HebiCommandIoPinBank bank, size_t pin_number, const float *value)
void hebiCommandSetNumberedFloat(HebiCommandRef &command, HebiCommandNumberedFloatField field, size_t number, const float *value)
Boot the module from bootloader into application.
void clear()
Removes any currently set value for this field.
HebiCommandIoPinBank const bank_
HebiCommandRef & internal_
HebiStatusCode numberedFloatGetter(const RefT &ref, MetadataT &metadata, int field, size_t number, float *value)
bool get() const
If the field has a value, returns that value; otherwise, returns false.
bool has() const
True if (and only if) the field has a value.
IoBank(HebiCommandRef &internal, HebiCommandIoPinBank bank)
struct HebiCommand_ * HebiCommandPtr
Typedefs.
void hebiCommandSetString(HebiCommandPtr command, HebiCommandStringField field, const char *buffer, const size_t *length)
void setInt(size_t pinNumber, int64_t value)
Sets the particular pin to a integer value (representing a digital output).
Command objects have various fields that can be set; when sent to the module, these fields control in...
Command(HebiCommandPtr)
Wraps an existing C-style object that is managed by its parent. NOTE: this should not be used except ...
void hebiCommandSetHighResAngle(HebiCommandRef &command, HebiCommandHighResAngleField field, const int64_t *int_part, const float *dec_part)
void clear(size_t fieldNumber)
Removes any currently set value for the numbered subvalue of this field.
void set(size_t fieldNumber, float value)
Sets the particular numbered subvalue of this field to a given value.
std::string get() const
If the field has a value, returns a copy of that value; otherwise, returns a default.
FlagField(HebiCommandRef &internal, HebiCommandFlagField field)
void set()
Sets this flag.
The family for this module. The string must be null-terminated and less than 21 characters.
HebiCommandRef internal_ref_
HebiCommandNumberedFloatField const field_
HebiCommandRef & internal_
HebiStatusCode floatGetter(const RefT &ref, MetadataT &metadata, int field, float *value)
HebiCommandHighResAngleField const field_
Stop the module from automatically booting into application.
LedField(HebiCommandRef &internal, HebiCommandLedField field)
HebiCommandFloatField const field_
BoolField(HebiCommandRef &internal, HebiCommandBoolField field)
bool has() const
True if (and only if) the field has a value.
HebiStatusCode boolGetter(const RefT &ref, MetadataT &metadata, int field, bool *value)
bool has() const
Returns true if the flag is set, false if it is cleared.
HebiCommandFlagField const field_
HebiCommandPtr const internal_
HebiStatusCode highResAngleGetter(const RefT &ref, MetadataT &metadata, int field, int64_t *revs, float *offset)
HebiCommandFloatField
Command Enums.
Color get() const
Returns the current LED command.
int64_t getInt(size_t pinNumber) const
If this numbered pin in this bank has an integer (e.g., digital) value, returns that value; otherwise...
double get() const
If the field has a value, returns that value as a double; otherwise, returns a default.
HebiCommandNumberedFloatField
void hebiCommandGetReference(HebiCommandPtr command, HebiCommandRef *ref)
HebiCommandRef & internal_
float getFloat(size_t pinNumber) const
If this numbered pin in this bank has an floating point (e.g., analog or PWM) value, returns that value; otherwise returns a default.
HebiCommandLedField const field_
void hebiCommandSetLed(HebiCommandRef &command, HebiCommandLedField field, const Color *color)
void hebiCommandSetFlag(HebiCommandRef &command, HebiCommandFlagField field, int32_t value)
float get() const
If the field has a value, returns that value; otherwise, returns a default.
bool flagGetter(const RefT &ref, MetadataT &metadata, int field)
HebiCommandRef & internal_
NumberedFloatField(HebiCommandRef &internal, HebiCommandNumberedFloatField field)
void clear()
Removes any currently set value for this field, so that the module maintains its previous state of LE...
void set(double radians)
Sets the field to a given double value (in radians). Note that double precision floating point number...
void clear()
Removes any currently set value for this field.
StringField(HebiCommandPtr internal, HebiCommandStringField field)
void set(float value)
Sets the field to a given value.
bool has() const
True if (and only if) the field has a value.
HebiCommandRef & internal_
void set(bool value)
Sets the field to a given value.
HebiStatusCode floatIoPinGetter(const RefT &ref, MetadataT &metadata, int index, size_t pin_number, float *value)
void hebiCommandSetIoPinInt(HebiCommandRef &command, HebiCommandIoPinBank bank, size_t pin_number, const int64_t *value)
float get(size_t fieldNumber) const
If the particular numbered subvalue of this field has a value, returns that value; otherwise returns ...
NumberedFloatField debug_
HebiStatusCode intIoPinGetter(const RefT &ref, MetadataT &metadata, int index, size_t pin_number, int64_t *value)
HebiCommandStringField const field_
void setFloat(size_t pinNumber, float value)
Sets the particular pin to a floating point value (representing a PWM output).
HebiCommandRef & internal_
bool has() const
Returns true if the LED command has been set, and false otherwise.
bool hasFloat(size_t pinNumber) const
True if (and only if) the particular numbered pin in this bank has an floating point (e...
HebiCommandRef & internal_
bool hasInt(size_t pinNumber) const
True if (and only if) the particular numbered pin in this bank has an integer (e.g., digital) value.
void hebiCommandSetFloat(HebiCommandRef &command, HebiCommandFloatField field, const float *value)
Structure to describe an RGB color.
Indicates if the module should save the current values of all of its settings.
bool has(size_t fieldNumber) const
True if (and only if) the particular numbered subvalue of this field has a value. ...
void clear()
Clears this flag (e.g., sets it to false/off).
bool has() const
True if (and only if) the field has a value.
void clear(size_t pinNumber)
Removes any currently set value for this pin.
void set(const std::string &value)
Sets the field to a given value.
FloatField(HebiCommandRef &internal, HebiCommandFloatField field)