REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
|
The Lucidac Coefficient Block (C-Block) is represented by this class. More...
#include <cblock.h>


Public Member Functions | |
CBlock (CBlockHAL *hardware) | |
CBlock () | |
metadata::eui_t | get_entity_eui () const override |
float | get_factor (uint8_t idx) |
Set a particular digital potentiometer. | |
const std::array< float, NUM_COEFF > & | get_factors () const |
void | set_factors (const std::array< float, NUM_COEFF > &factors) |
bool | set_factor (uint8_t idx, float factor) |
float | get_gain_correction (uint8_t idx) const |
const std::array< float, NUM_COEFF > & | get_gain_corrections () const |
bool | set_gain_correction (uint8_t coeff_idx, const float correction) |
void | set_gain_corrections (const std::array< float, NUM_COEFF > &corrections) |
void | reset_gain_corrections () |
utils::status | write_to_hardware () override |
returns true in case of success | |
void | reset (entities::ResetAction action) override |
utils::status | config_self_from_json (JsonObjectConst cfg) override |
Deserialize a new configuration for this entity from a JsonObject. | |
![]() | |
FunctionBlock (std::string entity_id) | |
std::vector< Entity * > | get_child_entities () override |
Entity * | get_child_entity (const std::string &child_id) override |
![]() | |
Entity ()=default | |
Entity (std::string entityId) | |
const std::string & | get_entity_id () const |
void | rename_entity (const std::string entityId) |
EntityClassifier | get_entity_classifier () const |
EntityClass | get_entity_class () const |
uint8_t | get_entity_type () const |
Version | get_entity_version () const |
uint8_t | get_entity_variant () const |
bool | is_entity_class (EntityClass class_) const |
bool | is_entity_type (uint8_t type_) const |
bool | is_entity_version (Version version_) const |
bool | is_entity_variant (uint8_t variant_) const |
Entity * | resolve_child_entity (std::string paths[], size_t len) |
Entity * | resolve_child_entity (JsonArrayConstIterator begin, JsonArrayConstIterator end) |
Entity * | resolve_child_entity (JsonArrayConst path) |
virtual bool | init () |
returns true in case of success | |
utils::status | config_from_json (JsonObjectConst cfg) |
Deserialize a new configuration for this entity and all its children from a JsonObject. | |
void | config_to_json (JsonObject &cfg, bool recursive=true) |
Serialize the configuration for this entity to a JsonObject. | |
utils::status | user_set_config (JsonObjectConst msg_in, JsonObject &msg_out) |
utils::status | user_get_config (JsonObjectConst msg_in, JsonObject &msg_out) |
utils::status | user_reset_config (JsonObjectConst msg_in, JsonObject &msg_out) |
void | classifier_to_json (JsonObject &out) |
Provide recursive entity information in a tree. | |
Static Public Member Functions | |
static CBlock * | from_entity_classifier (entities::EntityClassifier classifier, bus::addr_t block_address) |
static constexpr std::array< uint8_t, NUM_COEFF > | INPUT_IDX_RANGE () |
static constexpr std::array< uint8_t, NUM_COEFF > | OUTPUT_IDX_RANGE () |
Static Public Attributes | |
static constexpr auto | CLASS_ = entities::EntityClass::C_BLOCK |
static constexpr uint8_t | TYPE = 1 |
static constexpr uint8_t | BLOCK_IDX = bus::C_BLOCK_IDX |
static constexpr uint8_t | COEFF_BASE_FUNC_IDX = 1 |
static constexpr uint8_t | NUM_COEFF = 32 |
static constexpr float | MIN_FACTOR = -1.01f |
static constexpr float | MAX_FACTOR = +1.01f |
static constexpr float | MAX_GAIN_CORRECTION_ABS = 0.1f |
Protected Member Functions | |
bool | write_factors_to_hardware () |
void | config_self_to_json (JsonObject &cfg) override |
Serialize the configuration of this entity to a JsonObject. | |
utils::status | _config_elements_form_json (const JsonVariantConst &cfg) |
![]() | |
utils::status | config_children_from_json (JsonObjectConst &cfg) |
Deserialize a new configuration for all child entities from a JsonObject. | |
void | config_children_to_json (JsonObject &cfg) |
Serialize the configuration of the child entities of this entity to a JsonObject. | |
Protected Attributes | |
CBlockHAL * | hardware |
std::array< float, NUM_COEFF > | factors_ |
std::array< float, NUM_COEFF > | gain_corrections_ |
![]() | |
std::string | entity_id |
EntityClassifier | classifier |
Friends | |
class | ::platform::Calibration |
Detailed Description
The Lucidac Coefficient Block (C-Block) is represented by this class.
This class provides a neat interface for setting digital potentiometers without having to worry for "raw" DPT values or upscaling factors (allowing the DPTs to take values between [-20,+20] instead of only [-1,+1]).
As a Lucidac can only have a single C-Block, this is kind of a singleton. Typical usage happens via the Lucidac class.
Constructor & Destructor Documentation
◆ CBlock() [1/2]
FLASHMEM blocks::CBlock::CBlock | ( | CBlockHAL * | hardware | ) |
Definition at line 9 of file cblock.cpp.
References CLASS_, and entities::Entity::classifier.
◆ CBlock() [2/2]
FLASHMEM blocks::CBlock::CBlock | ( | ) |
Definition at line 13 of file cblock.cpp.
Member Function Documentation
◆ _config_elements_form_json()
|
protected |
I think this is debug code?
Definition at line 114 of file cblock.cpp.
References utils::status::success().
◆ config_self_from_json()
|
overridevirtual |
Deserialize a new configuration for this entity from a JsonObject.
Implementations shall not traverse to children,
- See also
- config_children_from_json() instead.
- Returns
- true in case of success, else false
Implements entities::Entity.
Definition at line 98 of file cblock.cpp.
References utils::status::success().
◆ config_self_to_json()
|
overrideprotectedvirtual |
Serialize the configuration of this entity to a JsonObject.
Implementations shall not traverse to children,
- See also
- config_children_to_json() instead.
Reimplemented from entities::Entity.
Definition at line 153 of file cblock.cpp.
◆ from_entity_classifier()
|
static |
Definition at line 161 of file cblock.cpp.
◆ get_entity_eui()
|
overridevirtual |
Implements entities::Entity.
Definition at line 21 of file cblock.cpp.
◆ get_factor()
FLASHMEM float blocks::CBlock::get_factor | ( | uint8_t | idx | ) |
Set a particular digital potentiometer.
idx means the coefficient ID and is between [0,31]. factor is the actual analog value between [-20,20].
Note that calling this function only stores the value in the in-memory representation of the hybrid controller. The in-memory representation is flushed to hardware by calling write_to_hardware().
- Returns
- false in case of invalid input, true else.
Definition at line 15 of file cblock.cpp.
◆ get_factors()
FLASHMEM const std::array< float, blocks::CBlock::NUM_COEFF > & blocks::CBlock::get_factors | ( | ) | const |
Definition at line 27 of file cblock.cpp.
◆ get_gain_correction()
FLASHMEM float blocks::CBlock::get_gain_correction | ( | uint8_t | idx | ) | const |
Definition at line 70 of file cblock.cpp.
◆ get_gain_corrections()
FLASHMEM const std::array< float, blocks::CBlock::NUM_COEFF > & blocks::CBlock::get_gain_corrections | ( | ) | const |
Definition at line 76 of file cblock.cpp.
◆ INPUT_IDX_RANGE()
|
inlinestaticconstexpr |
◆ OUTPUT_IDX_RANGE()
|
inlinestaticconstexpr |
◆ reset()
|
overridevirtual |
Reimplemented from entities::Entity.
Definition at line 59 of file cblock.cpp.
References entities::ResetAction::CALIBRATION_RESET, entities::ResetAction::CIRCUIT_RESET, entities::ResetAction::has(), and entities::Entity::reset().
◆ reset_gain_corrections()
FLASHMEM void blocks::CBlock::reset_gain_corrections | ( | ) |
Definition at line 80 of file cblock.cpp.
◆ set_factor()
|
nodiscard |
Definition at line 31 of file cblock.cpp.
Referenced by blocks::MMulBlock::calibrate(), and blocks::MMulBlock_FullAutoCalibration::calibrate().
◆ set_factors()
FLASHMEM void blocks::CBlock::set_factors | ( | const std::array< float, NUM_COEFF > & | factors | ) |
Definition at line 41 of file cblock.cpp.
◆ set_gain_correction()
FLASHMEM bool blocks::CBlock::set_gain_correction | ( | uint8_t | coeff_idx, |
const float | correction ) |
Definition at line 88 of file cblock.cpp.
◆ set_gain_corrections()
FLASHMEM void blocks::CBlock::set_gain_corrections | ( | const std::array< float, NUM_COEFF > & | corrections | ) |
Definition at line 84 of file cblock.cpp.
◆ write_factors_to_hardware()
|
nodiscardprotected |
Definition at line 51 of file cblock.cpp.
◆ write_to_hardware()
|
nodiscardoverridevirtual |
returns true in case of success
Reimplemented from entities::Entity.
Definition at line 43 of file cblock.cpp.
References utils::status::failure(), LOG, and utils::status::success().
Referenced by blocks::MMulBlock::calibrate(), and blocks::MMulBlock_FullAutoCalibration::calibrate().
Friends And Related Symbol Documentation
◆ ::platform::Calibration
Member Data Documentation
◆ BLOCK_IDX
|
staticconstexpr |
◆ CLASS_
|
staticconstexpr |
◆ COEFF_BASE_FUNC_IDX
|
staticconstexpr |
◆ factors_
|
protected |
◆ gain_corrections_
|
protected |
◆ hardware
◆ MAX_FACTOR
◆ MAX_GAIN_CORRECTION_ABS
|
staticconstexpr |
◆ MIN_FACTOR
◆ NUM_COEFF
◆ TYPE
The documentation for this class was generated from the following files:
- lib/platform-lucidac/src/block/cblock.h
- lib/platform-lucidac/src/block/cblock.cpp