mirror of https://github.com/arendst/Tasmota.git
Merge pull request #7589 from effelle/development
ADC Range (replaces adc Moisture)
This commit is contained in:
commit
a55b6fd81b
|
@ -114,6 +114,7 @@
|
|||
#define D_JSON_ACTIVE_POWERUSAGE "ActivePower"
|
||||
#define D_JSON_APPARENT_POWERUSAGE "ApparentPower"
|
||||
#define D_JSON_REACTIVE_POWERUSAGE "ReactivePower"
|
||||
#define D_JSON_RANGE "Range"
|
||||
#define D_JSON_PRESSURE "Pressure"
|
||||
#define D_JSON_PRESSUREATSEALEVEL "SeaPressure"
|
||||
#define D_JSON_PRESSURE_UNIT "PressureUnit"
|
||||
|
@ -605,6 +606,7 @@ const char JSON_SNS_TEMPHUM[] PROGMEM = ",\"%s\":{\"" D_JSON_TEMPERATURE "\":%s,
|
|||
|
||||
const char JSON_SNS_ILLUMINANCE[] PROGMEM = ",\"%s\":{\"" D_JSON_ILLUMINANCE "\":%d}";
|
||||
const char JSON_SNS_MOISTURE[] PROGMEM = ",\"%s\":{\"" D_JSON_MOISTURE "\":%d}";
|
||||
const char JSON_SNS_RANGE[] PROGMEM = ",\"%s\":{\"" D_JSON_RANGE "\":%d}";
|
||||
|
||||
const char JSON_SNS_GNGPM[] PROGMEM = ",\"%s\":{\"" D_JSON_TOTAL_USAGE "\":%s,\"" D_JSON_FLOWRATE "\":%s}";
|
||||
|
||||
|
@ -636,6 +638,8 @@ const char HTTP_SNS_CO2EAVG[] PROGMEM = "{s}%s " D_ECO2 "{m}%d " D_UNIT_PARTS_PE
|
|||
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 %%{e}";
|
||||
const char HTTP_SNS_RANGE[] PROGMEM = "{s}%s " D_RANGE "{m}%d %%{e}";
|
||||
|
||||
|
||||
const char HTTP_SNS_VOLTAGE[] PROGMEM = "{s}" D_VOLTAGE "{m}%s " D_UNIT_VOLT "{e}";
|
||||
const char HTTP_SNS_CURRENT[] PROGMEM = "{s}" D_CURRENT "{m}%s " D_UNIT_AMPERE "{e}";
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Размер на програмата"
|
||||
#define D_PROJECT "Проект"
|
||||
#define D_RAIN "Дъжд"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Получено"
|
||||
#define D_RESTART "Рестарт"
|
||||
#define D_RESTARTING "Рестартиране"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Velikost programu"
|
||||
#define D_PROJECT "Projekt"
|
||||
#define D_RAIN "Rain"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Přijatý"
|
||||
#define D_RESTART "Restart"
|
||||
#define D_RESTARTING "Restartování"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Ben. Flash Speicher"
|
||||
#define D_PROJECT "Projekt"
|
||||
#define D_RAIN "Regen"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "erhalten"
|
||||
#define D_RESTART "Neustart"
|
||||
#define D_RESTARTING "starte neu"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Μέγεθος προγράμματος"
|
||||
#define D_PROJECT "Έργο"
|
||||
#define D_RAIN "Rain"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Ελήφθη"
|
||||
#define D_RESTART "Επανεκκίνηση"
|
||||
#define D_RESTARTING "Επανεκκινεί"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Program Size"
|
||||
#define D_PROJECT "Project"
|
||||
#define D_RAIN "Rain"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Received"
|
||||
#define D_RESTART "Restart"
|
||||
#define D_RESTARTING "Restarting"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Tamaño Programa"
|
||||
#define D_PROJECT "Proyecto"
|
||||
#define D_RAIN "Lluvia"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Recibido"
|
||||
#define D_RESTART "Reiniciar"
|
||||
#define D_RESTARTING "Reiniciando"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Taille programme"
|
||||
#define D_PROJECT "Projet"
|
||||
#define D_RAIN "Pluie"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Reçu"
|
||||
#define D_RESTART "Redémarrage"
|
||||
#define D_RESTARTING "Redémarre"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "גודל תוכנית"
|
||||
#define D_PROJECT "פרויקט"
|
||||
#define D_RAIN "גשם"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "התקבל"
|
||||
#define D_RESTART "איתחול"
|
||||
#define D_RESTARTING "הפעלה מחדש"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Program méret"
|
||||
#define D_PROJECT "Projekt"
|
||||
#define D_RAIN "Eső"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Érkezett"
|
||||
#define D_RESTART "Újraindítás"
|
||||
#define D_RESTARTING "Újraindítás"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Dimensione Programma"
|
||||
#define D_PROJECT "Progetto"
|
||||
#define D_RAIN "Rain"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Ricevuto"
|
||||
#define D_RESTART "Riavvio"
|
||||
#define D_RESTARTING "Riavviando"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "프로그램 용량"
|
||||
#define D_PROJECT "프로젝트"
|
||||
#define D_RAIN "비"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "받음"
|
||||
#define D_RESTART "재시작"
|
||||
#define D_RESTARTING "재시작 중.."
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Programma Grootte"
|
||||
#define D_PROJECT "Project"
|
||||
#define D_RAIN "Regen"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Ontvangen"
|
||||
#define D_RESTART "Herstart"
|
||||
#define D_RESTARTING "Herstarten"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Rozmiar programu"
|
||||
#define D_PROJECT "Projekt"
|
||||
#define D_RAIN "Deszcz"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Otrzymany"
|
||||
#define D_RESTART "Restart"
|
||||
#define D_RESTARTING "Restartowanie"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Tamanho do programa"
|
||||
#define D_PROJECT "Projeto"
|
||||
#define D_RAIN "Rain"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Recebido"
|
||||
#define D_RESTART "Reiniciar"
|
||||
#define D_RESTARTING "Reiniciando"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Tamanho do Programa"
|
||||
#define D_PROJECT "Projeto"
|
||||
#define D_RAIN "Chuva"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Recebido"
|
||||
#define D_RESTART "Reiniciar"
|
||||
#define D_RESTARTING "A reiniciar"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Размер программы "
|
||||
#define D_PROJECT "Проект"
|
||||
#define D_RAIN "Rain"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Получено"
|
||||
#define D_RESTART "Перезапуск"
|
||||
#define D_RESTARTING "Перезапуск"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Veľkosť programu"
|
||||
#define D_PROJECT "Projekt"
|
||||
#define D_RAIN "Dážď"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Prijatý"
|
||||
#define D_RESTART "Reštart"
|
||||
#define D_RESTARTING "Reštartuje sa"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Programstorlek"
|
||||
#define D_PROJECT "Projekt"
|
||||
#define D_RAIN "Regn"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Mottagen"
|
||||
#define D_RESTART "Omstart"
|
||||
#define D_RESTARTING "Startar om"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Yazılım Boyutu"
|
||||
#define D_PROJECT "Proje"
|
||||
#define D_RAIN "Rain"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Alınan"
|
||||
#define D_RESTART "Yeniden Başlat"
|
||||
#define D_RESTARTING "Yeniden Başlatılıyor"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "Розмір програми"
|
||||
#define D_PROJECT "Проект"
|
||||
#define D_RAIN "Дощ"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "Отримано"
|
||||
#define D_RESTART "Перезавантаження"
|
||||
#define D_RESTARTING "Перезавантаження"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "固件大小"
|
||||
#define D_PROJECT "项目:"
|
||||
#define D_RAIN "降水量"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "已接收"
|
||||
#define D_RESTART "重启"
|
||||
#define D_RESTARTING "正在重启"
|
||||
|
|
|
@ -137,6 +137,7 @@
|
|||
#define D_PROGRAM_SIZE "韌體大小"
|
||||
#define D_PROJECT "項目:"
|
||||
#define D_RAIN "Rain"
|
||||
#define D_RANGE "Range"
|
||||
#define D_RECEIVED "已接收"
|
||||
#define D_RESTART "重啟"
|
||||
#define D_RESTARTING "正在重啟"
|
||||
|
|
|
@ -311,7 +311,7 @@ enum UserSelectableAdc0 {
|
|||
ADC0_LIGHT, // Light sensor
|
||||
ADC0_BUTTON, // Button
|
||||
ADC0_BUTTON_INV,
|
||||
ADC0_MOIST, // Moisture
|
||||
ADC0_RANGE, // Range
|
||||
ADC0_CT_POWER, // Current
|
||||
// ADC0_SWITCH, // Switch
|
||||
// ADC0_SWITCH_INV,
|
||||
|
@ -328,7 +328,7 @@ const char kAdc0Names[] PROGMEM =
|
|||
D_SENSOR_NONE "|" D_ANALOG_INPUT "|"
|
||||
D_TEMPERATURE "|" D_LIGHT "|"
|
||||
D_SENSOR_BUTTON "|" D_SENSOR_BUTTON "i|"
|
||||
D_MOISTURE "|"
|
||||
D_RANGE "|"
|
||||
D_CT_POWER "|"
|
||||
// D_SENSOR_SWITCH "|" D_SENSOR_SWITCH "i|"
|
||||
;
|
||||
|
|
|
@ -85,8 +85,8 @@ void AdcInit(void)
|
|||
Settings.adc_param2 = ANALOG_LDR_LUX_CALC_SCALAR;
|
||||
Settings.adc_param3 = ANALOG_LDR_LUX_CALC_EXPONENT * 10000;
|
||||
}
|
||||
else if (ADC0_MOIST == my_adc0) {
|
||||
Settings.adc_param_type = ADC0_MOIST;
|
||||
else if (ADC0_RANGE == my_adc0) {
|
||||
Settings.adc_param_type = ADC0_RANGE;
|
||||
Settings.adc_param1 = 0;
|
||||
Settings.adc_param2 = 1023;
|
||||
Settings.adc_param3 = 0;
|
||||
|
@ -145,14 +145,14 @@ uint16_t AdcGetLux(void)
|
|||
return (uint16_t)ldrLux;
|
||||
}
|
||||
|
||||
uint16_t AdcGetMoist(void)
|
||||
uint16_t AdcGetRange(void)
|
||||
{
|
||||
// formula for calibration: value, fromLow, fromHigh, toHigh, toLow
|
||||
// Example: 632, 0, 1023, 0, 100
|
||||
// int( ( ( (<param2> - <analogue-value>) / ( <param2> - <param1> ) ) * ( <param3> - <param4> ) ) + <param4> )
|
||||
// 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(2);
|
||||
double amoist = ( ((double)Settings.adc_param2 - (double)adc) / ( ((double)Settings.adc_param2 - (double)Settings.adc_param1)) * ((double)Settings.adc_param3 - (double)Settings.adc_param4) + (double)Settings.adc_param4 );
|
||||
return (uint16_t)amoist;
|
||||
double adcrange = ( ((double)Settings.adc_param2 - (double)adc) / ( ((double)Settings.adc_param2 - (double)Settings.adc_param1)) * ((double)Settings.adc_param3 - (double)Settings.adc_param4) + (double)Settings.adc_param4 );
|
||||
return (uint16_t)adcrange;
|
||||
}
|
||||
|
||||
void AdcGetCurrentPower(uint8_t factor)
|
||||
|
@ -253,14 +253,14 @@ void AdcShow(bool json)
|
|||
}
|
||||
}
|
||||
|
||||
else if (ADC0_MOIST == my_adc0) {
|
||||
uint16_t adc_moist = AdcGetMoist();
|
||||
else if (ADC0_RANGE == my_adc0) {
|
||||
uint16_t adc_range = AdcGetRange();
|
||||
|
||||
if (json) {
|
||||
ResponseAppend_P(JSON_SNS_MOISTURE, "ANALOG", adc_moist);
|
||||
ResponseAppend_P(JSON_SNS_RANGE, "ANALOG", adc_range);
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
WSContentSend_PD(HTTP_SNS_MOISTURE, "", adc_moist);
|
||||
WSContentSend_PD(HTTP_SNS_RANGE, "", adc_range);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ void CmndAdcParam(void)
|
|||
if (XdrvMailbox.data_len) {
|
||||
if ((ADC0_TEMP == XdrvMailbox.payload) ||
|
||||
(ADC0_LIGHT == XdrvMailbox.payload) ||
|
||||
(ADC0_MOIST == XdrvMailbox.payload) ||
|
||||
(ADC0_RANGE == XdrvMailbox.payload) ||
|
||||
(ADC0_CT_POWER == XdrvMailbox.payload)) {
|
||||
if (strstr(XdrvMailbox.data, ",") != nullptr) { // Process parameter entry
|
||||
char sub_string[XdrvMailbox.data_len +1];
|
||||
|
@ -350,7 +350,7 @@ void CmndAdcParam(void)
|
|||
Settings.adc_param_type = XdrvMailbox.payload;
|
||||
Settings.adc_param1 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
|
||||
Settings.adc_param2 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 3), nullptr, 10);
|
||||
if (ADC0_MOIST == XdrvMailbox.payload) {
|
||||
if (ADC0_RANGE == XdrvMailbox.payload) {
|
||||
Settings.adc_param3 = abs(strtol(subStr(sub_string, XdrvMailbox.data, ",", 4), nullptr, 10));
|
||||
Settings.adc_param4 = abs(strtol(subStr(sub_string, XdrvMailbox.data, ",", 5), nullptr, 10));
|
||||
} else {
|
||||
|
@ -375,7 +375,7 @@ void CmndAdcParam(void)
|
|||
|
||||
// AdcParam
|
||||
Response_P(PSTR("{\"" D_CMND_ADCPARAM "\":[%d,%d,%d"), Settings.adc_param_type, Settings.adc_param1, Settings.adc_param2);
|
||||
if (ADC0_MOIST == my_adc0) {
|
||||
if (ADC0_RANGE == my_adc0) {
|
||||
ResponseAppend_P(PSTR(",%d,%d"), Settings.adc_param3, Settings.adc_param4);
|
||||
} else {
|
||||
int value = Settings.adc_param3;
|
||||
|
@ -407,7 +407,7 @@ bool Xsns02(uint8_t function)
|
|||
if ((ADC0_INPUT == my_adc0) ||
|
||||
(ADC0_TEMP == my_adc0) ||
|
||||
(ADC0_LIGHT == my_adc0) ||
|
||||
(ADC0_MOIST == my_adc0) ||
|
||||
(ADC0_RANGE == my_adc0) ||
|
||||
(ADC0_CT_POWER == my_adc0)) {
|
||||
switch (function) {
|
||||
#ifdef USE_RULES
|
||||
|
|
Loading…
Reference in New Issue