Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DATA_API, SENSOR_API, data_conversion] Support sensor type dynamically #86

Open
luizvilla opened this issue Aug 29, 2024 · 0 comments
Open
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@luizvilla
Copy link
Member

Is your feature request related to a problem? Please describe.
Right now our technology supports two types of sensors, LINEAR and THERMISTANCE. These should be integrated into the function calls related to sensor parameters get and set dynamically. This will help redeability.

Describe the enhancement you'd like
We currently have two setConversionParameters functions as shown below:

	/**
	 * @brief Use this function to tweak the conversion values for the
	 *        channel if default values are not accurate enough.
	 *
	 * @note  This function can't be called before the pin is enabled.
	 *        The DataAPI module must not have been started, neither
	 *        explicitly nor by starting the Uninterruptible task.
	 *
	 * @param[in] pin_number Number of the pin from which to obtain values.
	 * @param[in] gain Gain to be applied (multiplied) to the channel raw value.
	 * @param[in] offset Offset to be applied (added) to the channel value
	 *        after gain has been applied.
	 */
	void setConversionParametersLinear(uint8_t pin_number, float32_t gain, float32_t offset);

	/**
	 * @brief Use this function to set the conversion values for any NTC 
	 * 		  thermistor sensor if default values are not accurate enough.
	 *
	 * @note  This function can't be called before the sensor is enabled.
	 *        The DataAPI must not have been started, neither explicitly
	 *        nor by starting the Uninterruptible task.
	 *
	 * @param[in] pin_number Number of the pin from which to obtain values.
	 * @param[in] r0 The NTC resistance at a reference temperature.
	 * @param[in] b The sensibility coefficient of the resistance to temperature.
	 * @param[in] rdiv The bridge dividor resistance used to condition the NTC.
	 * @param[in] t0 The reference temperature of the thermistor.
	 */
	void setConversionParametersNtcThermistor(uint8_t pin_num, float32_t r0, float32_t b, float32_t rdiv, float32_t t0);

We should be able to test for the conversion_type_t and set the parameters accordingly.

For now parameters are a typedef enum:

typedef enum : uint8_t
{
	gain = 1,
	offset = 2,
	r0 = 1,
	b = 2,
	rdiv =3,
	t0=4

} parameter_t;

And parameters are individualized, making it impossible to set them without two distinct funcitons.

Describe alternatives you've considered
For now what we have works with these two functions. But we should do better.

@luizvilla luizvilla added the enhancement New feature or request label Aug 29, 2024
@luizvilla luizvilla added this to the V2.0 milestone Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants