mirror of https://github.com/arendst/Tasmota.git
Change ADC range result from int to float
Change ADC range result from int to float using command ``FreqRes`` for decimal resolution selection (#11545)
This commit is contained in:
parent
a756c7437e
commit
75bbe5d3fa
|
@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file.
|
|||
- IRremoteESP8266 library from v2.7.15 to v2.7.16
|
||||
- ESP32 core library from v1.0.5 to v1.0.6
|
||||
- Limit number of relay/button columns in GUI to 8 (#11546)
|
||||
- ADC range result from int to float using command ``FreqRes`` for decimal resolution selection (#11545)
|
||||
|
||||
### Fixed
|
||||
- HC-SR04 on ESP32 release serial interface if not used (#11507)
|
||||
|
|
|
@ -112,6 +112,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
|
|||
- Rename epaper 42 commands [#11222](https://github.com/arendst/Tasmota/issues/11222)
|
||||
- DeepSleep announcement topic [#11223](https://github.com/arendst/Tasmota/issues/11223)
|
||||
- Limit number of relay/button columns in GUI to 8 [#11546](https://github.com/arendst/Tasmota/issues/11546)
|
||||
- ADC range result from int to float using command ``FreqRes`` for decimal resolution selection [#11545](https://github.com/arendst/Tasmota/issues/11545)
|
||||
|
||||
### Fixed
|
||||
- PN532 on ESP32 Serial flush both Tx and Rx buffers [#10910](https://github.com/arendst/Tasmota/issues/10910)
|
||||
|
|
|
@ -826,6 +826,7 @@ const char HTTP_SNS_CO2EAVG[] PROGMEM = "{s}%s " D_ECO2 "{
|
|||
const char HTTP_SNS_GALLONS[] PROGMEM = "{s}%s " D_TOTAL_USAGE "{m}%s " D_UNIT_GALLONS "{e}";
|
||||
const char HTTP_SNS_GPM[] PROGMEM = "{s}%s " D_FLOW_RATE "{m}%s " D_UNIT_GALLONS_PER_MIN "{e}";
|
||||
const char HTTP_SNS_MOISTURE[] PROGMEM = "{s}%s " D_MOISTURE "{m}%d " D_UNIT_PERCENT "{e}";
|
||||
const char HTTP_SNS_RANGE_CHR[] PROGMEM = "{s}%s " D_RANGE "{m}%s" "{e}";
|
||||
const char HTTP_SNS_RANGE[] PROGMEM = "{s}%s " D_RANGE "{m}%d" "{e}";
|
||||
const char HTTP_SNS_DISTANCE[] PROGMEM = "{s}%s " D_DISTANCE "{m}%d " D_UNIT_MILLIMETER "{e}";
|
||||
const char HTTP_SNS_DISTANCE_CM[] PROGMEM = "{s}%s " D_DISTANCE "{m}%s " D_UNIT_CENTIMETER "{e}";
|
||||
|
|
|
@ -356,13 +356,13 @@ float AdcGetPh(uint32_t idx) {
|
|||
return ph;
|
||||
}
|
||||
|
||||
uint16_t AdcGetRange(uint32_t idx) {
|
||||
float AdcGetRange(uint32_t idx) {
|
||||
// formula for calibration: value, fromLow, fromHigh, toLow, toHigh
|
||||
// Example: 514, 632, 236, 0, 100
|
||||
// int( ((<param2> - <analog-value>) / (<param2> - <param1>) ) * (<param3> - <param4>) ) + <param4> )
|
||||
int adc = AdcRead(Adc[idx].pin, 2);
|
||||
double adcrange = ( ((double)Adc[idx].param2 - (double)adc) / ( ((double)Adc[idx].param2 - (double)Adc[idx].param1)) * ((double)Adc[idx].param3 - (double)Adc[idx].param4) + (double)Adc[idx].param4 );
|
||||
return (uint16_t)adcrange;
|
||||
return (float)adcrange;
|
||||
}
|
||||
|
||||
void AdcGetCurrentPower(uint8_t idx, uint8_t factor) {
|
||||
|
@ -498,14 +498,16 @@ void AdcShow(bool json) {
|
|||
break;
|
||||
}
|
||||
case ADC_RANGE: {
|
||||
uint16_t adc_range = AdcGetRange(idx);
|
||||
float adc_range = AdcGetRange(idx);
|
||||
char range_chr[FLOATSZ];
|
||||
dtostrfd(adc_range, Settings.flag2.frequency_resolution, range_chr);
|
||||
|
||||
if (json) {
|
||||
AdcShowContinuation(&jsonflg);
|
||||
ResponseAppend_P(PSTR("\"" D_JSON_RANGE "%s\":%d"), adc_idx, adc_range);
|
||||
ResponseAppend_P(PSTR("\"" D_JSON_RANGE "%s\":%s"), adc_idx, range_chr);
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
WSContentSend_PD(HTTP_SNS_RANGE, adc_name, adc_range);
|
||||
WSContentSend_PD(HTTP_SNS_RANGE_CHR, adc_name, range_chr);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue