make adc_ph formula more flexible

This commit is contained in:
barbudor 2022-01-04 16:33:35 +01:00
parent 3916709d5f
commit 27a08b456e
1 changed files with 7 additions and 7 deletions

View File

@ -338,13 +338,13 @@ float AdcGetPh(uint32_t idx) {
int adc = AdcRead(Adc[idx].pin, 2);
float y1 = Adc[idx].param1 / ANALOG_PH_DECIMAL_MULTIPLIER;
uint32_t x1 = Adc[idx].param2;
float y2 = Adc[idx].param3 / ANALOG_PH_DECIMAL_MULTIPLIER;
uint32_t x2 = Adc[idx].param4;
float y1 = (float)Adc[idx].param1 / ANALOG_PH_DECIMAL_MULTIPLIER;
int32_t x1 = Adc[idx].param2;
float y2 = (float)Adc[idx].param3 / ANALOG_PH_DECIMAL_MULTIPLIER;
int32_t x2 = Adc[idx].param4;
float m = (y2 - y1) / (x2 - x1);
float ph = m * (adc - x1) + y1;
float m = (y2 - y1) / (float)(x2 - x1);
float ph = m * (float)(adc - x1) + y1;
char phLow_chr[6];