diff --git a/zephyr/modules/owntech_data_acquisition/zephyr/public_api/DataAcquisition.cpp b/zephyr/modules/owntech_data_acquisition/zephyr/public_api/DataAcquisition.cpp index 5fec1e775632775c4a466a50ce4990c1a7d46fa4..7b2afac44293d6caa78987c94029df759033c776 100644 --- a/zephyr/modules/owntech_data_acquisition/zephyr/public_api/DataAcquisition.cpp +++ b/zephyr/modules/owntech_data_acquisition/zephyr/public_api/DataAcquisition.cpp @@ -37,7 +37,6 @@ // Current module private functions #include "../adc_to_mem/data_dispatch.h" -#include "../data_conversion/data_conversion.h" ///// @@ -47,67 +46,16 @@ DataAcquisition dataAcquisition; ///// -// Public static configuration functions - -void DataAcquisition::setChannnelAssignment(uint8_t adc_number, const char* channel_name, uint8_t channel_rank) -{ - if (strcmp(channel_name, "V1_LOW") == 0) - { - v1_low_assignement.adc_number = adc_number; - v1_low_assignement.channel_rank = channel_rank; - } - else if (strcmp(channel_name, "V2_LOW") == 0) - { - v2_low_assignement.adc_number = adc_number; - v2_low_assignement.channel_rank = channel_rank; - } - else if (strcmp(channel_name, "V_HIGH") == 0) - { - v_high_assignement.adc_number = adc_number; - v_high_assignement.channel_rank = channel_rank; - } - else if (strcmp(channel_name, "I1_LOW") == 0) - { - i1_low_assignement.adc_number = adc_number; - i1_low_assignement.channel_rank = channel_rank; - } - else if (strcmp(channel_name, "I2_LOW") == 0) - { - i2_low_assignement.adc_number = adc_number; - i2_low_assignement.channel_rank = channel_rank; - } - else if (strcmp(channel_name, "I_HIGH") == 0) - { - i_high_assignement.adc_number = adc_number; - i_high_assignement.channel_rank = channel_rank; - } - else if (strcmp(channel_name, "TEMP_SENSOR") == 0) - { - temp_sensor_assignement.adc_number = adc_number; - temp_sensor_assignement.channel_rank = channel_rank; - } - else if (strcmp(channel_name, "EXTRA_MEAS") == 0) - { - extra_sensor_assignement.adc_number = adc_number; - extra_sensor_assignement.channel_rank = channel_rank; - } - else if (strcmp(channel_name, "ANALOG_COMM") == 0) - { - analog_comm_assignement.adc_number = adc_number; - analog_comm_assignement.channel_rank = channel_rank; - } -} +// Public configuration functions int8_t DataAcquisition::start(dispatch_method_t dispatch_method) { if (this->is_started == true) return -1; - scheduling_interrupt_source_t int_source; if (dispatch_method == dispatch_method_t::at_uninterruptible_task_start) { - int_source = scheduling_get_uninterruptible_synchronous_task_interrupt_source(); - if (int_source == scheduling_interrupt_source_t::source_uninitialized) + if (scheduling_get_uninterruptible_synchronous_task_interrupt_source() == scheduling_interrupt_source_t::source_uninitialized) { return -1; } @@ -123,9 +71,45 @@ int8_t DataAcquisition::start(dispatch_method_t dispatch_method) { const char* channel_name = adc_get_channel_name(adc_num, channel_rank); - if (channel_name != NULL) + if (channel_name != nullptr) { - setChannnelAssignment(adc_num, channel_name, channel_rank); + if (strcmp(channel_name, "V1_LOW") == 0) + { + _setAssignment(v1_low_assignement, adc_num, channel_rank); + } + else if (strcmp(channel_name, "V2_LOW") == 0) + { + _setAssignment(v2_low_assignement, adc_num, channel_rank); + } + else if (strcmp(channel_name, "V_HIGH") == 0) + { + _setAssignment(v_high_assignement, adc_num, channel_rank); + } + else if (strcmp(channel_name, "I1_LOW") == 0) + { + _setAssignment(i1_low_assignement, adc_num, channel_rank); + } + else if (strcmp(channel_name, "I2_LOW") == 0) + { + _setAssignment(i2_low_assignement, adc_num, channel_rank); + } + else if (strcmp(channel_name, "I_HIGH") == 0) + { + _setAssignment(i_high_assignement, adc_num, channel_rank); + } + else if (strcmp(channel_name, "TEMP_SENSOR") == 0) + { + _setAssignment(temp_sensor_assignement, adc_num, channel_rank); + } + else if (strcmp(channel_name, "EXTRA_MEAS") == 0) + { + _setAssignment(extra_sensor_assignement, adc_num, channel_rank); + } + else if (strcmp(channel_name, "ANALOG_COMM") == 0) + { + _setAssignment(analog_comm_assignement, adc_num, channel_rank); + } + channel_rank++; } else @@ -136,7 +120,7 @@ int8_t DataAcquisition::start(dispatch_method_t dispatch_method) } // Initialize data dispatch - dispatch_t dispatch_type = dispatch_method == on_dma_interrupt ? interrupt : task; + dispatch_t dispatch_type = (dispatch_method == on_dma_interrupt) ? interrupt : task; data_dispatch_init(dispatch_type); // Launch ADC conversion @@ -154,7 +138,7 @@ bool DataAcquisition::started() ///// -// Public static accessors +// Public accessors // Get raw values @@ -207,193 +191,199 @@ uint16_t* DataAcquisition::getAnalogCommRawValues(uint32_t& number_of_values_acq float32_t DataAcquisition::peekV1Low() { - return _peek(v1_low_assignement, data_conversion_convert_v1_low); + return _peek(v1_low_assignement); } float32_t DataAcquisition::peekV2Low() { - return _peek(v2_low_assignement, data_conversion_convert_v2_low); + return _peek(v2_low_assignement); } float32_t DataAcquisition::peekVHigh() { - return _peek(v_high_assignement, data_conversion_convert_v_high); + return _peek(v_high_assignement); } float32_t DataAcquisition::peekI1Low() { - return _peek(i1_low_assignement, data_conversion_convert_i1_low); + return _peek(i1_low_assignement); } float32_t DataAcquisition::peekI2Low() { - return _peek(i2_low_assignement, data_conversion_convert_i2_low); + return _peek(i2_low_assignement); } float32_t DataAcquisition::peekIHigh() { - return _peek(i_high_assignement, data_conversion_convert_i_high); + return _peek(i_high_assignement); } float32_t DataAcquisition::peekTemperature() { - return _peek(temp_sensor_assignement, data_conversion_convert_temp); + return _peek(temp_sensor_assignement); } float32_t DataAcquisition::peekExtra() { - return _peek(extra_sensor_assignement, data_conversion_convert_extra); + return _peek(extra_sensor_assignement); } float32_t DataAcquisition::peekAnalogComm() { - return _peek(analog_comm_assignement, data_conversion_convert_analog_comm); + return _peek(analog_comm_assignement); } // Get latest value float32_t DataAcquisition::getV1Low(uint8_t* dataValid) { - return this->_getChannel(v1_low_assignement, data_conversion_convert_v1_low, dataValid); + return _getLatest(v1_low_assignement, dataValid); } float32_t DataAcquisition::getV2Low(uint8_t* dataValid) { - return this->_getChannel(v2_low_assignement, data_conversion_convert_v2_low, dataValid); + return _getLatest(v2_low_assignement, dataValid); } float32_t DataAcquisition::getVHigh(uint8_t* dataValid) { - return this->_getChannel(v_high_assignement, data_conversion_convert_v_high, dataValid); + return _getLatest(v_high_assignement, dataValid); } float32_t DataAcquisition::getI1Low(uint8_t* dataValid) { - return this->_getChannel(i1_low_assignement, data_conversion_convert_i1_low, dataValid); + return _getLatest(i1_low_assignement, dataValid); } float32_t DataAcquisition::getI2Low(uint8_t* dataValid) { - return this->_getChannel(i2_low_assignement, data_conversion_convert_i2_low, dataValid); + return _getLatest(i2_low_assignement, dataValid); } float32_t DataAcquisition::getIHigh(uint8_t* dataValid) { - return this->_getChannel(i_high_assignement, data_conversion_convert_i_high, dataValid); + return _getLatest(i_high_assignement, dataValid); } float32_t DataAcquisition::getTemperature(uint8_t* dataValid) { - return this->_getChannel(temp_sensor_assignement, data_conversion_convert_temp, dataValid); + return _getLatest(temp_sensor_assignement, dataValid); } float32_t DataAcquisition::getExtra(uint8_t* dataValid) { - return this->_getChannel(extra_sensor_assignement, data_conversion_convert_extra, dataValid); + return _getLatest(extra_sensor_assignement, dataValid); } float32_t DataAcquisition::getAnalogComm(uint8_t* dataValid) { - return this->_getChannel(analog_comm_assignement, data_conversion_convert_analog_comm, dataValid); + return _getLatest(analog_comm_assignement, dataValid); } // Convertion float32_t DataAcquisition::convertV1Low(uint16_t raw_value) { - return data_conversion_convert_v1_low(raw_value); + return _convert(v1_low_assignement, raw_value); } float32_t DataAcquisition::convertV2Low(uint16_t raw_value) { - return data_conversion_convert_v2_low(raw_value); + return _convert(v2_low_assignement, raw_value); } float32_t DataAcquisition::convertVHigh(uint16_t raw_value) { - return data_conversion_convert_v_high(raw_value); + return _convert(v_high_assignement, raw_value); } float32_t DataAcquisition::convertI1Low(uint16_t raw_value) { - return data_conversion_convert_i1_low(raw_value); + return _convert(i1_low_assignement, raw_value); } float32_t DataAcquisition::convertI2Low(uint16_t raw_value) { - return data_conversion_convert_i2_low(raw_value); + return _convert(i2_low_assignement, raw_value); } float32_t DataAcquisition::convertIHigh(uint16_t raw_value) { - return data_conversion_convert_i_high(raw_value); + return _convert(i_high_assignement, raw_value); } float32_t DataAcquisition::convertTemperature(uint16_t raw_value) { - return data_conversion_convert_temp(raw_value); + return _convert(temp_sensor_assignement, raw_value); } float32_t DataAcquisition::convertExtra(uint16_t raw_value) { - return data_conversion_convert_extra(raw_value); + return _convert(extra_sensor_assignement, raw_value); } float32_t DataAcquisition::convertAnalogComm(uint16_t raw_value) { - return data_conversion_convert_analog_comm(raw_value); + return _convert(analog_comm_assignement, raw_value); } // Parameter setters void DataAcquisition::setV1LowParameters(float32_t gain, float32_t offset) { - data_conversion_set_v1_low_parameters(gain, offset); + _setParameters(v1_low_assignement, gain, offset); } void DataAcquisition::setV2LowParameters(float32_t gain, float32_t offset) { - data_conversion_set_v2_low_parameters(gain, offset); + _setParameters(v2_low_assignement, gain, offset); } void DataAcquisition::setVHighParameters(float32_t gain, float32_t offset) { - data_conversion_set_v_high_parameters(gain, offset); + _setParameters(v_high_assignement, gain, offset); } void DataAcquisition::setI1LowParameters(float32_t gain, float32_t offset) { - data_conversion_set_i1_low_parameters(gain, offset); + _setParameters(i1_low_assignement, gain, offset); } void DataAcquisition::setI2LowParameters(float32_t gain, float32_t offset) { - data_conversion_set_i2_low_parameters(gain, offset); + _setParameters(i2_low_assignement, gain, offset); } void DataAcquisition::setIHighParameters(float32_t gain, float32_t offset) { - data_conversion_set_i_high_parameters(gain, offset); + _setParameters(i_high_assignement, gain, offset); } void DataAcquisition::setTemperatureParameters(float32_t gain, float32_t offset) { - data_conversion_set_temp_parameters(gain, offset); + _setParameters(temp_sensor_assignement, gain, offset); } void DataAcquisition::setExtraParameters(float32_t gain, float32_t offset) { - data_conversion_set_extra_parameters(gain, offset); + _setParameters(extra_sensor_assignement, gain, offset); } void DataAcquisition::setAnalogCommParameters(float32_t gain, float32_t offset) { - data_conversion_set_analog_comm_parameters(gain, offset); + _setParameters(analog_comm_assignement, gain, offset); } -// Internal private functions +// Private helper functions -float32_t DataAcquisition::_getChannel(channel_assignment_t assignment, float32_t(*convert)(uint16_t), uint8_t* dataValid) +void DataAcquisition::_setAssignment(channel_assignment_t& assignment, uint8_t adc_number, uint8_t channel_rank) +{ + assignment.adc_number = adc_number; + assignment.channel_rank = channel_rank; +} + +float32_t DataAcquisition::_getLatest(channel_assignment_t assignment, uint8_t* dataValid) { if (this->is_started == false) { @@ -414,7 +404,7 @@ float32_t DataAcquisition::_getChannel(channel_assignment_t assignment, float32_ { *dataValid = DATA_IS_OK; } - return convert(raw_value); + return assignment.convert(raw_value); } else { @@ -423,7 +413,7 @@ float32_t DataAcquisition::_getChannel(channel_assignment_t assignment, float32_ float32_t peekValue; if (rawValue != PEEK_NO_VALUE) { - peekValue = convert(rawValue); + peekValue = assignment.convert(rawValue); } else { @@ -458,14 +448,14 @@ uint16_t* DataAcquisition::_getRawValues(channel_assignment_t assignment, uint32 } } -float32_t DataAcquisition::_peek(channel_assignment_t assignment, float32_t(*convert)(uint16_t)) +float32_t DataAcquisition::_peek(channel_assignment_t assignment) { if (this->is_started == true) { uint16_t rawValue = data_dispatch_peek_acquired_value(assignment.adc_number, assignment.channel_rank); if (rawValue != PEEK_NO_VALUE) { - return convert(rawValue); + return assignment.convert(rawValue); } else { @@ -477,3 +467,13 @@ float32_t DataAcquisition::_peek(channel_assignment_t assignment, float32_t(*con return NO_VALUE; } } + +float32_t DataAcquisition::_convert(channel_assignment_t assignment, uint16_t raw_value) +{ + return assignment.convert(raw_value); +} + +void DataAcquisition::_setParameters(channel_assignment_t assignment, float32_t gain, float32_t offset) +{ + assignment.set_parameters(gain, offset); +} diff --git a/zephyr/modules/owntech_data_acquisition/zephyr/public_api/DataAcquisition.h b/zephyr/modules/owntech_data_acquisition/zephyr/public_api/DataAcquisition.h index 78c085cd0a09ffbf4d17d89754cac9ed3ac92d03..d559e942cc1107577bcdf2ef8a8e0981f008fd36 100644 --- a/zephyr/modules/owntech_data_acquisition/zephyr/public_api/DataAcquisition.h +++ b/zephyr/modules/owntech_data_acquisition/zephyr/public_api/DataAcquisition.h @@ -34,6 +34,9 @@ // ARM CMSIS library #include <arm_math.h> +// Current module private functions +#include "../data_conversion/data_conversion.h" + ///// // Public definitions @@ -59,20 +62,22 @@ class DataAcquisition public: /** - * This functions starts the acquisition chain. It must be called - * after ADC module configuration has been fully carried out. No ADC - * configuration change is allowed after module has been started. - * If you're not sure how to initialize ADC, just use the Hardware - * Configuration module API: hwConfig.configureAdcDefaultAllMeasurements() + * @brief This functions starts the acquisition chain. + * + * @note If your code uses an uninterruptible task, you do not need to + * start Data Acquisition manually, it will automatically be started + * at the same time as the task as their internal behavior are + * intrinsically linked. * - * NOTE 1: If your code uses an uninterruptible task, you do not need to start - * Data Acquisition manually, it will automatically be started at the same - * time as the task as their internal behavior are intrinsically linked. + * @note Data Acquisition must be started only after ADC module configuration + * has been fully carried out. No ADC configuration change is allowed + * after module has been started. If you're not sure how to initialize + * ADCs, just use the Hardware Configuration module API: + * hwConfig.configureAdcDefaultAllMeasurements() * - * NOTE 2: Data Acquisition must be started before accessing any - * dataAcquisition.get*() or dataAcquisition.peek*() function. - * Other Data Acquisition functions are safe to use before starting - * the module. + * @note Data Acquisition must be started before accessing any dataAcquisition.get*() + * or dataAcquisition.peek*() function. Other Data Acquisition functions + * are safe to use before starting the module. * * @param dispatch_method Indicates when the dispatch should be done. * Dispatch makes data from ADCs available to dataAcquisition.get*() @@ -86,7 +91,7 @@ public: * use an uninterrptible task in your application, default parameter * on_dma_interrupt is the correct value. * If for some reason you have an uninterruptible task in your code, - * but stoill want the dispatch to be done on DMA interrupt, + * but still want the dispatch to be done on DMA interrupt, * you need to call this function prior to starting the task. * Note that using DMA interrupts will consume a non-negligible * amount of processor time and it is not advised. @@ -94,20 +99,23 @@ public: * @return 0 if everything went well, -1 if there was an error. * Error is triggered when dispatch method is set to * uninterruptible task start, but the task has not been - * defined yet. + * defined yet. Another source of error is trying to start + * Data Acquisition after it has already been started. */ int8_t start(dispatch_method_t dispatch_method = on_dma_interrupt); /** - * Check if the module is already started. + * @brief Checks if the module is already started. * * For auto-spawning threads, this allows to make sure the module * has already been started before trying to access measures. * * If you don't use (or don't know what are) auto-spawning threads, - * just make sure you call dataAcquisition.start() before accessing - * any dataAcquisition.get*() or dataAcquisition.peek*() function, - * and ignore this one. + * just make sure calls to any dataAcquisition.get*() or dataAcquisition.peek*() + * function occur after the uninterruptible task is started, or + * Data Acquisition is manually started, and ignore this function. + * + * @return true is the module has been started, false otherwise. */ bool started(); @@ -115,33 +123,36 @@ public: ///// // Accessor API + ///@{ /** - * Functions to access the acquired data for each channel. - * Each function provides a buffer in which all data that - * have been acquired since last call are stored. The count - * of these values is returned as an output parameter: the - * user has to define a variable and pass a reference to this - * variable as the parameter of the function. The variable - * will be updated with the number of values that are available - * in the buffer. + * @brief Function to access the acquired data for specified channel. + * This function provides a buffer in which all data that + * have been acquired since last call are stored. The count + * of these values is returned as an output parameter: the + * user has to define a variable and pass it as the parameter + * of the function. The variable will be updated with the + * number of values that are available in the buffer. + * + * @note When calling this function, it invalidates the buffer + * returned by a previous call to the same function. + * However, different channels buffers are independent + * from each other. + * + * @note When using this functions, the user is responsible for data + * conversion. Use matching dataAcquisition.convert*() function + * for this purpose. * - * NOTE 1: When calling one of these functions, it invalidates - * the buffer returned by a previous call to the same function. - * NOTE 2: All function buffers are independent from each other. - * NOTE 3: When using these functions, the user is responsible for data - * conversion. Use dataAcquisition.convert*() functions for this - * purpose. - * NOTE 4: When using these functions for a channel, DO NOT use the - * functions to get the latest converted value for the same channel - * as these functions clear the buffer and disregard all values - * but the latest. + * @note When using this function, DO NOT use the function to get the + * latest converted value for the same channel as this function + * will clear the buffer and disregard all values but the latest. * * @param number_of_values_acquired Pass an uint32_t variable. * This variable will be updated with the number of values that - * have been acquired for this channel. + * are present in the returned buffer. + * * @return Pointer to a buffer in which the acquired values are stored. * If number_of_values_acquired is 0, do not try to access the - * buffer as it may be NULL. + * buffer as it may be nullptr. */ uint16_t* getV1LowRawValues(uint32_t& number_of_values_acquired); uint16_t* getV2LowRawValues(uint32_t& number_of_values_acquired); @@ -152,12 +163,15 @@ public: uint16_t* getTemperatureRawValues(uint32_t& number_of_values_acquired); uint16_t* getExtraRawValues(uint32_t& number_of_values_acquired); uint16_t* getAnalogCommRawValues(uint32_t& number_of_values_acquired); + ///@} + ///@{ /** - * Functions to access the latest value available from a channel expressed - * in the relevant unit for the data: Volts, Amperes, Degree Celcius. - * These functions will not touch anything in the buffer, and thus can - * be called safely at any time. + * @brief Function to access the latest value available from the channel, + * expressed in the relevant unit for the data: Volts, Amperes, or + * Degree Celcius. This function will not touch anything in the + * buffer, and thus can be called safely at any time after the + * module has been started. * * @return Latest available value available from the given channel. * If there was no value acquired in this channel yet, @@ -172,25 +186,31 @@ public: float32_t peekTemperature(); float32_t peekExtra(); float32_t peekAnalogComm(); + ///@} + ///@{ /** - * These functions return the latest acquired measure expressed - * in the relevant unit for the data: Volts, Amperes, Degree Celcius. + * @brief This function returns the latest acquired measure expressed + * in the relevant unit for the channel: Volts, Amperes, or + * Degree Celcius. * - * NOTE: When using these functions for a channel, you loose the - * ability to access raw values using dataAcquisition.get*RawValues() - * functions, as dataAcquisition.get*() functions clear the buffers - * on each call. + * @note When using this functions, you loose the ability to access raw + * values using dataAcquisition.get*RawValues() function for the + * matching channel, as dataAcquisition.get*() function clears the + * buffer on each call. * * @param dataValid Pointer to an uint8_t variable. This parameter is * facultative. If this parameter is provided, it will be updated * to indicate information about data. Possible values for this - * parameter will be: DATA_IS_OK if returned data is a newly acquired - * data, DATA_IS_OLD if returned data has already been provided before + * parameter will be: + * - DATA_IS_OK if returned data is a newly acquired data, + * - DATA_IS_OLD if returned data has already been provided before * (no new data available since latest time this function was called), - * DATA_IS_MISSING if returned data is NO_VALUE. + * - DATA_IS_MISSING if returned data is NO_VALUE. + * * @return Latest acquired measure for the channel. * If no value was acquired in this channel yet, return value is NO_VALUE. + * */ float32_t getV1Low(uint8_t* dataValid = nullptr); float32_t getV2Low(uint8_t* dataValid = nullptr); @@ -201,11 +221,17 @@ public: float32_t getTemperature(uint8_t* dataValid = nullptr); float32_t getExtra(uint8_t* dataValid = nullptr); float32_t getAnalogComm(uint8_t* dataValid = nullptr); + ///@} + ///@{ /** - * Use these functions to convert values obtained using - * dataAcquisition.get*RawValues() functions to relevant - * unit for the data: Volts, Amperes, Degree Celcius. + * @brief Use this function to convert values obtained using matching + * dataAcquisition.get*RawValues() function to relevant + * unit for the data: Volts, Amperes, or Degree Celcius. + * + * @param raw_value Raw value obtained from the channel buffer. + * + * @return Converted value in the relevant unit. */ float32_t convertV1Low(uint16_t raw_value); float32_t convertV2Low(uint16_t raw_value); @@ -216,10 +242,17 @@ public: float32_t convertTemperature(uint16_t raw_value); float32_t convertExtra(uint16_t raw_value); float32_t convertAnalogComm(uint16_t raw_value); + ///@} + ///@{ /** - * Use these functions to tweak the conversion values for - * a specific sensor if default values are not accurate enough. + * @brief Use this function to tweak the conversion values for the + * channel if default values are not accurate enough. + * + * @param gain Gain to be applied (multiplied) to the channel raw value. + * + * @param offset Offset to be applied (added) to the channel value + * after gain has been applied. */ void setV1LowParameters(float32_t gain, float32_t offset); void setI1LowParameters(float32_t gain, float32_t offset); @@ -230,41 +263,46 @@ public: void setTemperatureParameters(float32_t gain, float32_t offset); void setExtraParameters(float32_t gain, float32_t offset); void setAnalogCommParameters(float32_t gain, float32_t offset); + ///@} private: + /** + * Internal types definitions. + */ + typedef float32_t(*conversion_function_t)(uint16_t); + typedef void(*set_convert_params_function_t)(float32_t, float32_t); + typedef struct { uint8_t adc_number; uint8_t channel_rank; + conversion_function_t convert; + set_convert_params_function_t set_parameters; } channel_assignment_t; private: /** - * This function is used to indicate to the DataAcquisition module - * what the underlying ADC channel configuration is. - * - * @param adc_number ADC number - * @param channel_name Channel name - * @param channel_rannk Channel rank + * Helper functions to share code. */ - void setChannnelAssignment(uint8_t adc_number, const char* channel_name, uint8_t channel_rank); - - float32_t _getChannel(channel_assignment_t assignment, float32_t(*convert)(uint16_t), uint8_t* dataValid); + void _setAssignment(channel_assignment_t& assignment, uint8_t adc_number, uint8_t channel_rank); + float32_t _getLatest(channel_assignment_t assignment, uint8_t* dataValid); uint16_t* _getRawValues(channel_assignment_t assignment, uint32_t& number_of_values_acquired); - float32_t _peek(channel_assignment_t assignment, float32_t(*convert)(uint16_t)); + float32_t _peek(channel_assignment_t assignment); + float32_t _convert(channel_assignment_t assignment, uint16_t raw_value); + void _setParameters(channel_assignment_t assignment, float32_t gain, float32_t offset); private: bool is_started = false; - channel_assignment_t v1_low_assignement = {0}; - channel_assignment_t v2_low_assignement = {0}; - channel_assignment_t v_high_assignement = {0}; - channel_assignment_t i1_low_assignement = {0}; - channel_assignment_t i2_low_assignement = {0}; - channel_assignment_t i_high_assignement = {0}; - channel_assignment_t temp_sensor_assignement = {0}; - channel_assignment_t extra_sensor_assignement = {0}; - channel_assignment_t analog_comm_assignement = {0}; + channel_assignment_t v1_low_assignement = {0, 0, data_conversion_convert_v1_low, data_conversion_set_v1_low_parameters }; + channel_assignment_t v2_low_assignement = {0, 0, data_conversion_convert_v2_low, data_conversion_set_v2_low_parameters }; + channel_assignment_t v_high_assignement = {0, 0, data_conversion_convert_v_high, data_conversion_set_v_high_parameters }; + channel_assignment_t i1_low_assignement = {0, 0, data_conversion_convert_i1_low, data_conversion_set_i1_low_parameters }; + channel_assignment_t i2_low_assignement = {0, 0, data_conversion_convert_i2_low, data_conversion_set_i2_low_parameters }; + channel_assignment_t i_high_assignement = {0, 0, data_conversion_convert_i_high, data_conversion_set_i_high_parameters }; + channel_assignment_t temp_sensor_assignement = {0, 0, data_conversion_convert_temp, data_conversion_set_temp_parameters }; + channel_assignment_t extra_sensor_assignement = {0, 0, data_conversion_convert_extra, data_conversion_set_extra_parameters }; + channel_assignment_t analog_comm_assignement = {0, 0, data_conversion_convert_analog_comm, data_conversion_set_analog_comm_parameters}; };