Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
rosflight_firmware::Params Class Reference

#include <param.h>

Classes

union  param_value_t
 
struct  params_t
 

Public Member Functions

void add_callback (std::function< void(int)> callback, uint16_t param_id)
 
void change_callback (uint16_t id)
 Callback for executing actions that need to be taken when a parameter value changes. More...
 
float get_param_float (uint16_t id) const
 Get the value of a floating point parameter by id. More...
 
int get_param_int (uint16_t id) const
 Get the value of an integer parameter by id. More...
 
const char * get_param_name (uint16_t id) const
 Get the name of a parameter. More...
 
param_type_t get_param_type (uint16_t id) const
 Get the type of a parameter. More...
 
void init ()
 Initialize parameter values. More...
 
uint16_t lookup_param_id (const char name[PARAMS_NAME_LENGTH])
 Gets the id of a parameter from its name. More...
 
 Params (ROSflight &_rf)
 
bool read (void)
 Read parameter values from non-volatile memory. More...
 
void set_defaults (void)
 Set all parameters to default values. More...
 
bool set_param_by_name_float (const char name[PARAMS_NAME_LENGTH], float value)
 Sets the value of a floating point parameter by name and calls the parameter change callback. More...
 
bool set_param_by_name_int (const char name[PARAMS_NAME_LENGTH], int32_t value)
 Sets the value of a parameter by name and calls the parameter change callback. More...
 
bool set_param_float (uint16_t id, float value)
 Sets the value of a floating point parameter by ID and calls the parameter callback. More...
 
bool set_param_int (uint16_t id, int32_t value)
 Sets the value of a parameter by ID and calls the parameter change callback. More...
 
bool write (void)
 Write current parameter values to non-volatile memory. More...
 

Static Public Attributes

static constexpr uint8_t PARAMS_NAME_LENGTH = 16
 

Private Member Functions

uint8_t compute_checksum (void)
 
void init_param_float (uint16_t id, const char name[PARAMS_NAME_LENGTH], float value)
 
void init_param_int (uint16_t id, const char name[PARAMS_NAME_LENGTH], int32_t value)
 

Private Attributes

std::function< void(int)> callbacks [PARAMS_COUNT]
 
params_t params
 
ROSflightRF_
 

Detailed Description

Definition at line 230 of file param.h.

Constructor & Destructor Documentation

rosflight_firmware::Params::Params ( ROSflight _rf)

Definition at line 48 of file param.cpp.

Member Function Documentation

void rosflight_firmware::Params::add_callback ( std::function< void(int)>  callback,
uint16_t  param_id 
)

Definition at line 308 of file param.cpp.

void rosflight_firmware::Params::change_callback ( uint16_t  id)

Callback for executing actions that need to be taken when a parameter value changes.

Parameters
idThe ID of the parameter that was changed

Definition at line 344 of file param.cpp.

uint8_t rosflight_firmware::Params::compute_checksum ( void  )
private

Definition at line 70 of file param.cpp.

float rosflight_firmware::Params::get_param_float ( uint16_t  id) const
inline

Get the value of a floating point parameter by id.

Parameters
idThe ID of the parameter
Returns
The value of the parameter

Definition at line 326 of file param.h.

int rosflight_firmware::Params::get_param_int ( uint16_t  id) const
inline

Get the value of an integer parameter by id.

Parameters
idThe ID of the parameter
Returns
The value of the parameter

Definition at line 316 of file param.h.

const char* rosflight_firmware::Params::get_param_name ( uint16_t  id) const
inline

Get the name of a parameter.

Parameters
idThe ID of the parameter
Returns
The name of the parameter

Definition at line 336 of file param.h.

param_type_t rosflight_firmware::Params::get_param_type ( uint16_t  id) const
inline

Get the type of a parameter.

Parameters
idThe ID of the parameter
Returns
The type of the parameter This returns one of three possible types PARAM_TYPE_INT32, PARAM_TYPE_FLOAT, or PARAM_TYPE_INVALID See line 165

Definition at line 349 of file param.h.

void rosflight_firmware::Params::init ( )

Initialize parameter values.

Definition at line 90 of file param.cpp.

void rosflight_firmware::Params::init_param_float ( uint16_t  id,
const char  name[PARAMS_NAME_LENGTH],
float  value 
)
private

Definition at line 63 of file param.cpp.

void rosflight_firmware::Params::init_param_int ( uint16_t  id,
const char  name[PARAMS_NAME_LENGTH],
int32_t  value 
)
private

Definition at line 56 of file param.cpp.

uint16_t rosflight_firmware::Params::lookup_param_id ( const char  name[PARAMS_NAME_LENGTH])

Gets the id of a parameter from its name.

Parameters
nameThe name of the parameter
Returns
The ID of the parameter if the name is valid, PARAMS_COUNT otherwise (invalid ID)

Definition at line 351 of file param.cpp.

bool rosflight_firmware::Params::read ( void  )

Read parameter values from non-volatile memory.

Returns
True if successful, false otherwise

Definition at line 314 of file param.cpp.

void rosflight_firmware::Params::set_defaults ( void  )

Set all parameters to default values.

Definition at line 100 of file param.cpp.

bool rosflight_firmware::Params::set_param_by_name_float ( const char  name[PARAMS_NAME_LENGTH],
float  value 
)

Sets the value of a floating point parameter by name and calls the parameter change callback.

Parameters
nameThe name of the parameter
valueThe new value
Returns
True if a parameter value was changed, false otherwise

Definition at line 407 of file param.cpp.

bool rosflight_firmware::Params::set_param_by_name_int ( const char  name[PARAMS_NAME_LENGTH],
int32_t  value 
)

Sets the value of a parameter by name and calls the parameter change callback.

Parameters
nameThe name of the parameter
valueThe new value
Returns
True if a parameter value was changed, false otherwise

Definition at line 401 of file param.cpp.

bool rosflight_firmware::Params::set_param_float ( uint16_t  id,
float  value 
)

Sets the value of a floating point parameter by ID and calls the parameter callback.

Parameters
idThe ID of the parameter
valueThe new value
Returns
True if a parameter was changed, false otherwise

Definition at line 389 of file param.cpp.

bool rosflight_firmware::Params::set_param_int ( uint16_t  id,
int32_t  value 
)

Sets the value of a parameter by ID and calls the parameter change callback.

Parameters
idThe ID of the parameter
valueThe new value
Returns
True if a parameter value was changed, false otherwise

Definition at line 377 of file param.cpp.

bool rosflight_firmware::Params::write ( void  )

Write current parameter values to non-volatile memory.

Returns
True if successful, false otherwise

Definition at line 331 of file param.cpp.

Member Data Documentation

std::function<void(int)> rosflight_firmware::Params::callbacks[PARAMS_COUNT]
private

Definition at line 257 of file param.h.

params_t rosflight_firmware::Params::params
private

Definition at line 259 of file param.h.

constexpr uint8_t rosflight_firmware::Params::PARAMS_NAME_LENGTH = 16
static

Definition at line 234 of file param.h.

ROSflight& rosflight_firmware::Params::RF_
private

Definition at line 260 of file param.h.


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


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:31