-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
I would argue that this is less than ideal in a number of ways.
// 10k NTC with 10k pullup converted to degrees Celsius
let temp_metric = probe_plotter::make_metric!(
TEMP: u16 = 0,
"(1.0 / ((ln((10000 * (TEMP * 3.3 / 4095.0)) / (3.3 - (TEMP * 3.3 / 4095.0)) / 10000) / 4100) + 1.0 / (273.15 + 25))) - 273.15"
);
let other_temp_metric = probe_plotter::make_metric!(
OTHER_TEMP: u16 = 0,
"(1.0 / ((ln((10000 * (OTHER_TEMP * 3.3 / 4095.0)) / (3.3 - (OTHER_TEMP * 3.3 / 4095.0)) / 10000) / 4100) + 1.0 / (273.15 + 25))) - 273.15"
);- Hardcoded constants
- Duplication of code
- Lots of code
Is there any way to have const evaluated things end up in an elf, preferably without taking any real space in flash?
If not then plan B would be some sort of make_const.
make_const!(R_PULL_UP = "10000");
make_const!(VCC = "3.3");
make_const!(ADC_MAX = "2^12 - 1");
make_const!(NTC_BETA = "4100");
make_const!(NTC_R0 = "ZERO_CELCIUS_AS_KELVIN + 25");
make_const!(ZERO_CELCIUS_AS_KELVIN = "273.15");
let other_temp_metric = probe_plotter::make_metric!(
TEMP: u16 = 0,
"(1.0 / ((ln((R_PULL_UP * (TEMP * VCC / ADC_MAX)) / (VCC - (TEMP * VCC / ADC_MAX)) / NTC_R0) / NTC_BETA) + 1.0 / NTC_R0)) - ZERO_CELCIUS_AS_KELVIN"
);Metadata
Metadata
Assignees
Labels
No labels