mirror of https://github.com/arendst/Tasmota.git
make adc_ph formula more flexible
This commit is contained in:
parent
3916709d5f
commit
27a08b456e
|
@ -338,13 +338,13 @@ float AdcGetPh(uint32_t idx) {
|
||||||
int adc = AdcRead(Adc[idx].pin, 2);
|
int adc = AdcRead(Adc[idx].pin, 2);
|
||||||
|
|
||||||
|
|
||||||
float y1 = Adc[idx].param1 / ANALOG_PH_DECIMAL_MULTIPLIER;
|
float y1 = (float)Adc[idx].param1 / ANALOG_PH_DECIMAL_MULTIPLIER;
|
||||||
uint32_t x1 = Adc[idx].param2;
|
int32_t x1 = Adc[idx].param2;
|
||||||
float y2 = Adc[idx].param3 / ANALOG_PH_DECIMAL_MULTIPLIER;
|
float y2 = (float)Adc[idx].param3 / ANALOG_PH_DECIMAL_MULTIPLIER;
|
||||||
uint32_t x2 = Adc[idx].param4;
|
int32_t x2 = Adc[idx].param4;
|
||||||
|
|
||||||
float m = (y2 - y1) / (x2 - x1);
|
float m = (y2 - y1) / (float)(x2 - x1);
|
||||||
float ph = m * (adc - x1) + y1;
|
float ph = m * (float)(adc - x1) + y1;
|
||||||
|
|
||||||
|
|
||||||
char phLow_chr[6];
|
char phLow_chr[6];
|
||||||
|
|
Loading…
Reference in New Issue