mirror of https://github.com/arendst/Tasmota.git
Add support for HC-SR04
5.12.0m * Add support for sensor HC-SR04 ultrasonic (#113, #1964, #2444)
This commit is contained in:
parent
24b82c78e8
commit
2743c35462
|
@ -3,7 +3,8 @@
|
|||
* Add random window to timers (#2447)
|
||||
* Add optional KNX IP Protocol Support (#2402)
|
||||
* Add Greek language file (#2491)
|
||||
* Fix compile error when using ESP/Arduino library v2.3.0 by reverting KNX async UDP library to default UDP library (#2488,#2492,#2493)
|
||||
* Add support for sensor HC-SR04 ultrasonic (#113, #1964, #2444)
|
||||
* Fix compile error when using ESP/Arduino library v2.3.0 by reverting KNX async UDP library to default UDP library (#2488, #2492, #2493)
|
||||
* Fix configuration filename truncation when it contains spaces (#2484, #2490)
|
||||
*
|
||||
* 5.12.0l
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#define D_JSON_COUNTER "Counter"
|
||||
#define D_JSON_CURRENT "Current" // As in Voltage and Current
|
||||
#define D_JSON_DATA "Data"
|
||||
#define D_JSON_DISTANCE "Distance"
|
||||
#define D_JSON_DNSSERVER "DNSServer"
|
||||
#define D_JSON_DONE "Done"
|
||||
#define D_JSON_ECO2 "eCO2"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#define D_DARKLIGHT "Tmavý"
|
||||
#define D_DEBUG "Debug"
|
||||
#define D_DISABLED "Zablokováno"
|
||||
#define D_DISTANCE "Distance"
|
||||
#define D_DNS_SERVER "Server DNS"
|
||||
#define D_DONE "Provedeno"
|
||||
#define D_DST_TIME "DST"
|
||||
|
@ -450,9 +451,12 @@
|
|||
#define D_SENSOR_SDS0X1 "SDS0X1"
|
||||
#define D_SENSOR_SBR_RX "SerBr Rx"
|
||||
#define D_SENSOR_SBR_TX "SerBr Tx"
|
||||
#define D_SENSOR_SR04_TRIG "SR04 Tri"
|
||||
#define D_SENSOR_SR04_ECHO "SR04 Ech"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
#define D_UNIT_CENTIMETER "cm"
|
||||
#define D_UNIT_HOUR "hod"
|
||||
#define D_UNIT_KILOOHM "kOhm"
|
||||
#define D_UNIT_KILOWATTHOUR "kWh"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#define D_DARKLIGHT "dunkel"
|
||||
#define D_DEBUG "debug"
|
||||
#define D_DISABLED "deaktiviert"
|
||||
#define D_DISTANCE "Abstand"
|
||||
#define D_DNS_SERVER "DNS-Server"
|
||||
#define D_DONE "erledigt"
|
||||
#define D_DST_TIME "DST"
|
||||
|
@ -450,9 +451,12 @@
|
|||
#define D_SENSOR_SDS0X1 "SDS0X1"
|
||||
#define D_SENSOR_SBR_RX "SerBr Rx"
|
||||
#define D_SENSOR_SBR_TX "SerBr Tx"
|
||||
#define D_SENSOR_SR04_TRIG "SR04 Tri"
|
||||
#define D_SENSOR_SR04_ECHO "SR04 Ech"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
#define D_UNIT_CENTIMETER "cm"
|
||||
#define D_UNIT_HOUR "h"
|
||||
#define D_UNIT_KILOOHM "kOhm"
|
||||
#define D_UNIT_KILOWATTHOUR "kWh"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#define D_DARKLIGHT "Σκούρο"
|
||||
#define D_DEBUG "Debug"
|
||||
#define D_DISABLED "Απενεργοποιημένο"
|
||||
#define D_DISTANCE "Distance"
|
||||
#define D_DNS_SERVER "Διακομιστής DNS"
|
||||
#define D_DONE "Εγινε"
|
||||
#define D_DST_TIME "DST"
|
||||
|
@ -450,9 +451,12 @@
|
|||
#define D_SENSOR_SDS0X1 "SDS0X1"
|
||||
#define D_SENSOR_SBR_RX "SerBr Rx"
|
||||
#define D_SENSOR_SBR_TX "SerBr Tx"
|
||||
#define D_SENSOR_SR04_TRIG "SR04 Tri"
|
||||
#define D_SENSOR_SR04_ECHO "SR04 Ech"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
#define D_UNIT_CENTIMETER "cm"
|
||||
#define D_UNIT_HOUR "Hr"
|
||||
#define D_UNIT_KILOOHM "kOhm"
|
||||
#define D_UNIT_KILOWATTHOUR "kWh"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#define D_DARKLIGHT "Dark"
|
||||
#define D_DEBUG "Debug"
|
||||
#define D_DISABLED "Disabled"
|
||||
#define D_DISTANCE "Distance"
|
||||
#define D_DNS_SERVER "DNS Server"
|
||||
#define D_DONE "Done"
|
||||
#define D_DST_TIME "DST"
|
||||
|
@ -450,9 +451,12 @@
|
|||
#define D_SENSOR_SDS0X1 "SDS0X1"
|
||||
#define D_SENSOR_SBR_RX "SerBr Rx"
|
||||
#define D_SENSOR_SBR_TX "SerBr Tx"
|
||||
#define D_SENSOR_SR04_TRIG "SR04 Tri"
|
||||
#define D_SENSOR_SR04_ECHO "SR04 Ech"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
#define D_UNIT_CENTIMETER "cm"
|
||||
#define D_UNIT_HOUR "Hr"
|
||||
#define D_UNIT_KILOOHM "kOhm"
|
||||
#define D_UNIT_KILOWATTHOUR "kWh"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#define D_DARKLIGHT "Oscura"
|
||||
#define D_DEBUG "Debug"
|
||||
#define D_DISABLED "Deshabilitado"
|
||||
#define D_DISTANCE "Distance"
|
||||
#define D_DNS_SERVER "DNS Server"
|
||||
#define D_DONE "Listo"
|
||||
#define D_DST_TIME "DST"
|
||||
|
@ -450,9 +451,12 @@
|
|||
#define D_SENSOR_SDS0X1 "SDS0X1"
|
||||
#define D_SENSOR_SBR_RX "SerBr Rx"
|
||||
#define D_SENSOR_SBR_TX "SerBr Tx"
|
||||
#define D_SENSOR_SR04_TRIG "SR04 Tri"
|
||||
#define D_SENSOR_SR04_ECHO "SR04 Ech"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
#define D_UNIT_CENTIMETER "cm"
|
||||
#define D_UNIT_HOUR "Hr"
|
||||
#define D_UNIT_KILOOHM "kOhm"
|
||||
#define D_UNIT_KILOWATTHOUR "kWh"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#define D_DARKLIGHT "Sombre"
|
||||
#define D_DEBUG "Debug"
|
||||
#define D_DISABLED "Désactivé"
|
||||
#define D_DISTANCE "Distance"
|
||||
#define D_DNS_SERVER "Serveur DNS"
|
||||
#define D_DONE "Fait"
|
||||
#define D_DST_TIME "DST"
|
||||
|
@ -450,9 +451,12 @@
|
|||
#define D_SENSOR_SDS0X1 "SDS0X1"
|
||||
#define D_SENSOR_SBR_RX "SerBr Rx"
|
||||
#define D_SENSOR_SBR_TX "SerBr Tx"
|
||||
#define D_SENSOR_SR04_TRIG "SR04 Tri"
|
||||
#define D_SENSOR_SR04_ECHO "SR04 Ech"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
#define D_UNIT_CENTIMETER "cm"
|
||||
#define D_UNIT_HOUR "h"
|
||||
#define D_UNIT_KILOOHM "kΩ"
|
||||
#define D_UNIT_KILOWATTHOUR "kWh"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#define D_DARKLIGHT "Min. fényerő"
|
||||
#define D_DEBUG "Debug"
|
||||
#define D_DISABLED "Letiltva"
|
||||
#define D_DISTANCE "Distance"
|
||||
#define D_DNS_SERVER "DNS Szerver"
|
||||
#define D_DONE "Kész"
|
||||
#define D_DST_TIME "DST"
|
||||
|
@ -450,9 +451,12 @@
|
|||
#define D_SENSOR_SDS0X1 "SDS0X1"
|
||||
#define D_SENSOR_SBR_RX "SerBr Rx"
|
||||
#define D_SENSOR_SBR_TX "SerBr Tx"
|
||||
#define D_SENSOR_SR04_TRIG "SR04 Tri"
|
||||
#define D_SENSOR_SR04_ECHO "SR04 Ech"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
#define D_UNIT_CENTIMETER "cm"
|
||||
#define D_UNIT_HOUR "ó"
|
||||
#define D_UNIT_KILOOHM "kOhm"
|
||||
#define D_UNIT_KILOWATTHOUR "kWh"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#define D_DARKLIGHT "Scuro"
|
||||
#define D_DEBUG "Debug"
|
||||
#define D_DISABLED "Disabilitato"
|
||||
#define D_DISTANCE "Distance"
|
||||
#define D_DNS_SERVER "DNS Server"
|
||||
#define D_DONE "Fatto"
|
||||
#define D_DST_TIME "DST"
|
||||
|
@ -450,9 +451,12 @@
|
|||
#define D_SENSOR_SDS0X1 "SDS0X1"
|
||||
#define D_SENSOR_SBR_RX "SerBr Rx"
|
||||
#define D_SENSOR_SBR_TX "SerBr Tx"
|
||||
#define D_SENSOR_SR04_TRIG "SR04 Tri"
|
||||
#define D_SENSOR_SR04_ECHO "SR04 Ech"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
#define D_UNIT_CENTIMETER "cm"
|
||||
#define D_UNIT_HOUR "Hr"
|
||||
#define D_UNIT_KILOOHM "kOhm"
|
||||
#define D_UNIT_KILOWATTHOUR "kWh"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#define D_DARKLIGHT "Donker"
|
||||
#define D_DEBUG "Debug"
|
||||
#define D_DISABLED "Uitgeschakeld"
|
||||
#define D_DISTANCE "Afstand"
|
||||
#define D_DNS_SERVER "DNS Server"
|
||||
#define D_DONE "Klaar"
|
||||
#define D_DST_TIME "ZT"
|
||||
|
@ -450,9 +451,12 @@
|
|||
#define D_SENSOR_SDS0X1 "SDS0X1"
|
||||
#define D_SENSOR_SBR_RX "SerBr Rx"
|
||||
#define D_SENSOR_SBR_TX "SerBr Tx"
|
||||
#define D_SENSOR_SR04_TRIG "SR04 Tri"
|
||||
#define D_SENSOR_SR04_ECHO "SR04 Ech"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
#define D_UNIT_CENTIMETER "cm"
|
||||
#define D_UNIT_HOUR "h"
|
||||
#define D_UNIT_KILOOHM "kOhm"
|
||||
#define D_UNIT_KILOWATTHOUR "kWh"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#define D_DARKLIGHT "Ciemny"
|
||||
#define D_DEBUG "Debug"
|
||||
#define D_DISABLED "Zablokowany"
|
||||
#define D_DISTANCE "Distance"
|
||||
#define D_DNS_SERVER "Server DNS"
|
||||
#define D_DONE "Wykonane"
|
||||
#define D_DST_TIME "DST"
|
||||
|
@ -450,9 +451,12 @@
|
|||
#define D_SENSOR_SDS0X1 "SDS0X1"
|
||||
#define D_SENSOR_SBR_RX "SerBr Rx"
|
||||
#define D_SENSOR_SBR_TX "SerBr Tx"
|
||||
#define D_SENSOR_SR04_TRIG "SR04 Tri"
|
||||
#define D_SENSOR_SR04_ECHO "SR04 Ech"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
#define D_UNIT_CENTIMETER "cm"
|
||||
#define D_UNIT_HOUR "Godz"
|
||||
#define D_UNIT_KILOOHM "kOhm"
|
||||
#define D_UNIT_KILOWATTHOUR "kWh"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#define D_DARKLIGHT "Luz Escura"
|
||||
#define D_DEBUG "Depurar"
|
||||
#define D_DISABLED "Disabilitado"
|
||||
#define D_DISTANCE "Distance"
|
||||
#define D_DNS_SERVER "Servidor DNS"
|
||||
#define D_DONE "Concluído"
|
||||
#define D_DST_TIME "DST"
|
||||
|
@ -450,9 +451,12 @@
|
|||
#define D_SENSOR_SDS0X1 "SDS0X1"
|
||||
#define D_SENSOR_SBR_RX "SerBr Rx"
|
||||
#define D_SENSOR_SBR_TX "SerBr Tx"
|
||||
#define D_SENSOR_SR04_TRIG "SR04 Tri"
|
||||
#define D_SENSOR_SR04_ECHO "SR04 Ech"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
#define D_UNIT_CENTIMETER "cm"
|
||||
#define D_UNIT_HOUR "Hr"
|
||||
#define D_UNIT_KILOOHM "kOhm"
|
||||
#define D_UNIT_KILOWATTHOUR "kWh"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#define D_DARKLIGHT "Темный"
|
||||
#define D_DEBUG "Отладка"
|
||||
#define D_DISABLED "Блокирован"
|
||||
#define D_DISTANCE "Distance"
|
||||
#define D_DNS_SERVER "DNS Сервер"
|
||||
#define D_DONE "Выполнено"
|
||||
#define D_DST_TIME "DST"
|
||||
|
@ -450,9 +451,12 @@
|
|||
#define D_SENSOR_SDS0X1 "SDS0X1"
|
||||
#define D_SENSOR_SBR_RX "SerBr Rx"
|
||||
#define D_SENSOR_SBR_TX "SerBr Tx"
|
||||
#define D_SENSOR_SR04_TRIG "SR04 Tri"
|
||||
#define D_SENSOR_SR04_ECHO "SR04 Ech"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "А"
|
||||
#define D_UNIT_CENTIMETER "cm"
|
||||
#define D_UNIT_HOUR "Ч"
|
||||
#define D_UNIT_KILOOHM "кОм"
|
||||
#define D_UNIT_KILOWATTHOUR "кВт"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#define D_DARKLIGHT "Dark"
|
||||
#define D_DEBUG "调试"
|
||||
#define D_DISABLED "禁用"
|
||||
#define D_DISTANCE "Distance"
|
||||
#define D_DNS_SERVER "DNS服务器"
|
||||
#define D_DONE "完成"
|
||||
#define D_DST_TIME "DST"
|
||||
|
@ -450,9 +451,12 @@
|
|||
#define D_SENSOR_SDS0X1 "SDS0X1"
|
||||
#define D_SENSOR_SBR_RX "SerBr Rx"
|
||||
#define D_SENSOR_SBR_TX "SerBr Tx"
|
||||
#define D_SENSOR_SR04_TRIG "SR04 Tri"
|
||||
#define D_SENSOR_SR04_ECHO "SR04 Ech"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "安"
|
||||
#define D_UNIT_CENTIMETER "cm"
|
||||
#define D_UNIT_HOUR "时"
|
||||
#define D_UNIT_KILOOHM "千欧"
|
||||
#define D_UNIT_KILOWATTHOUR "千瓦时"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#define D_DARKLIGHT "Dark"
|
||||
#define D_DEBUG "除錯"
|
||||
#define D_DISABLED "停用"
|
||||
#define D_DISTANCE "Distance"
|
||||
#define D_DNS_SERVER "DNS伺服器"
|
||||
#define D_DONE "完成"
|
||||
#define D_DST_TIME "DST"
|
||||
|
@ -450,9 +451,12 @@
|
|||
#define D_SENSOR_SDS0X1 "SDS0X1"
|
||||
#define D_SENSOR_SBR_RX "SerBr Rx"
|
||||
#define D_SENSOR_SBR_TX "SerBr Tx"
|
||||
#define D_SENSOR_SR04_TRIG "SR04 Tri"
|
||||
#define D_SENSOR_SR04_ECHO "SR04 Ech"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "安"
|
||||
#define D_UNIT_CENTIMETER "cm"
|
||||
#define D_UNIT_HOUR "時"
|
||||
#define D_UNIT_KILOOHM "千歐"
|
||||
#define D_UNIT_KILOWATTHOUR "千瓦時"
|
||||
|
|
|
@ -91,6 +91,8 @@ enum UserSelectablePins {
|
|||
GPIO_SDS0X1, // Nova Fitness SDS011 Serial interface
|
||||
GPIO_SBR_TX, // Serial Bridge Serial interface
|
||||
GPIO_SBR_RX, // Serial Bridge Serial interface
|
||||
GPIO_SR04_TRIG, // SR04 Trigger pin
|
||||
GPIO_SR04_ECHO, // SR04 Echo pin
|
||||
GPIO_SENSOR_END };
|
||||
|
||||
// Programmer selectable GPIO functionality offset by user selectable GPIOs
|
||||
|
@ -133,7 +135,8 @@ const char kSensorNames[] PROGMEM =
|
|||
D_SENSOR_SAIR_TX "|" D_SENSOR_SAIR_RX "|"
|
||||
D_SENSOR_SPI_CS "|" D_SENSOR_SPI_DC "|" D_SENSOR_BACKLIGHT "|"
|
||||
D_SENSOR_PMS5003 "|" D_SENSOR_SDS0X1 "|"
|
||||
D_SENSOR_SBR_TX "|" D_SENSOR_SBR_RX;
|
||||
D_SENSOR_SBR_TX "|" D_SENSOR_SBR_RX "|"
|
||||
D_SENSOR_SR04_TRIG "|" D_SENSOR_SR04_ECHO;
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
|
|
|
@ -285,6 +285,8 @@
|
|||
|
||||
#define USE_ARILUX_RF // Add support for Arilux RF remote controller (+0k8 code, 252 iram (non 2.3.0))
|
||||
|
||||
#define USE_SR04 // Add support for HC-SR04 ultrasonic devices (+1k code)
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Select all sensors - overrides above undefines!!
|
||||
\*********************************************************************************************/
|
||||
|
|
|
@ -396,9 +396,7 @@ void StartWebserver(int type, IPAddress ipweb)
|
|||
my_hostname, (mdns_begun) ? ".local" : "", ipweb.toString().c_str());
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
}
|
||||
if (type) {
|
||||
webserver_state = type;
|
||||
}
|
||||
if (type) { webserver_state = type; }
|
||||
}
|
||||
|
||||
void StopWebserver()
|
||||
|
@ -435,12 +433,8 @@ void WifiManagerBegin()
|
|||
|
||||
void PollDnsWebserver()
|
||||
{
|
||||
if (DnsServer) {
|
||||
DnsServer->processNextRequest();
|
||||
}
|
||||
if (WebServer) {
|
||||
WebServer->handleClient();
|
||||
}
|
||||
if (DnsServer) { DnsServer->processNextRequest(); }
|
||||
if (WebServer) { WebServer->handleClient(); }
|
||||
}
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
@ -495,9 +489,7 @@ void HandleRoot()
|
|||
{
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_MAIN_MENU);
|
||||
|
||||
if (CaptivePortal()) { // If captive portal redirect instead of displaying the page.
|
||||
return;
|
||||
}
|
||||
if (CaptivePortal()) { return; } // If captive portal redirect instead of displaying the page.
|
||||
|
||||
if (HTTP_MANAGER == webserver_state) {
|
||||
if ((Settings.web_password[0] != 0) && !(WebServer->hasArg("USER1")) && !(WebServer->hasArg("PASS1"))) {
|
||||
|
@ -549,9 +541,7 @@ void HandleRoot()
|
|||
page += F("<tr>");
|
||||
byte idx = 0;
|
||||
for (byte i = 0; i < 4; i++) {
|
||||
if (idx > 0) {
|
||||
page += F("</tr><tr>");
|
||||
}
|
||||
if (idx > 0) { page += F("</tr><tr>"); }
|
||||
for (byte j = 0; j < 4; j++) {
|
||||
idx++;
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("<td style='width:25%'><button onclick='la(\"?k=%d\");'>%d</button></td>"), idx, idx);
|
||||
|
@ -620,17 +610,13 @@ void HandleAjaxStatusRefresh()
|
|||
boolean HttpUser()
|
||||
{
|
||||
boolean status = (HTTP_USER == webserver_state);
|
||||
if (status) {
|
||||
HandleRoot();
|
||||
}
|
||||
if (status) { HandleRoot(); }
|
||||
return status;
|
||||
}
|
||||
|
||||
void HandleConfiguration()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURATION);
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
|
@ -638,10 +624,10 @@ void HandleConfiguration()
|
|||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
page += FPSTR(HTTP_BTN_MENU_MODULE);
|
||||
#if defined(USE_TIMERS) && defined(USE_TIMERS_WEB)
|
||||
if (devices_present) page += FPSTR(HTTP_BTN_MENU_TIMER);
|
||||
if (devices_present) { page += FPSTR(HTTP_BTN_MENU_TIMER); }
|
||||
#endif // USE_TIMERS and USE_TIMERS_WEB
|
||||
page += FPSTR(HTTP_BTN_MENU_WIFI);
|
||||
if (Settings.flag.mqtt_enabled) page += FPSTR(HTTP_BTN_MENU_MQTT);
|
||||
if (Settings.flag.mqtt_enabled) { page += FPSTR(HTTP_BTN_MENU_MQTT); }
|
||||
page += FPSTR(HTTP_BTN_MENU4);
|
||||
page += FPSTR(HTTP_BTN_MAIN);
|
||||
ShowPage(page);
|
||||
|
@ -651,26 +637,20 @@ boolean GetUsedInModule(byte val, uint8_t *arr)
|
|||
{
|
||||
int offset = 0;
|
||||
|
||||
if (!val) {
|
||||
return false; // None
|
||||
}
|
||||
if (!val) { return false; } // None
|
||||
#ifndef USE_I2C
|
||||
if (GPIO_I2C_SCL == val) {
|
||||
return true;
|
||||
}
|
||||
if (GPIO_I2C_SDA == val) {
|
||||
return true;
|
||||
}
|
||||
if (GPIO_I2C_SCL == val) { return true; }
|
||||
if (GPIO_I2C_SDA == val) { return true; }
|
||||
#endif
|
||||
#ifndef USE_SR04
|
||||
if (GPIO_SR04_TRIG == val) { return true; }
|
||||
if (GPIO_SR04_ECHO == val) { return true; }
|
||||
#endif
|
||||
#ifndef USE_WS2812
|
||||
if (GPIO_WS2812 == val) {
|
||||
return true;
|
||||
}
|
||||
if (GPIO_WS2812 == val) { return true; }
|
||||
#endif
|
||||
#ifndef USE_IR_REMOTE
|
||||
if (GPIO_IRSEND == val) {
|
||||
return true;
|
||||
}
|
||||
if (GPIO_IRSEND == val) { return true; }
|
||||
#endif
|
||||
if ((val >= GPIO_REL1) && (val < GPIO_REL1 + MAX_RELAYS)) {
|
||||
offset = (GPIO_REL1_INV - GPIO_REL1);
|
||||
|
@ -693,21 +673,15 @@ boolean GetUsedInModule(byte val, uint8_t *arr)
|
|||
offset = -(GPIO_PWM1_INV - GPIO_PWM1);
|
||||
}
|
||||
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
|
||||
if (arr[i] == val) {
|
||||
return true;
|
||||
}
|
||||
if (arr[i] == val + offset) {
|
||||
return true;
|
||||
}
|
||||
if (arr[i] == val) { return true; }
|
||||
if (arr[i] == val + offset) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void HandleModuleConfiguration()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
char stemp[20];
|
||||
uint8_t midx;
|
||||
|
||||
|
@ -777,9 +751,7 @@ void HandleWifiConfiguration()
|
|||
|
||||
void HandleWifi(boolean scan)
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_WIFI);
|
||||
|
||||
|
@ -818,15 +790,13 @@ void HandleWifi(boolean scan)
|
|||
if (remove_duplicate_access_points) {
|
||||
String cssid;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (-1 == indices[i]) {
|
||||
continue;
|
||||
}
|
||||
if (-1 == indices[i]) { continue; }
|
||||
cssid = WiFi.SSID(indices[i]);
|
||||
for (int j = i + 1; j < n; j++) {
|
||||
if (cssid == WiFi.SSID(indices[j])) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_DUPLICATE_ACCESSPOINT " %s"), WiFi.SSID(indices[j]).c_str());
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
indices[j] = -1; // set dup aps to index -1
|
||||
indices[j] = -1; // set dup aps to index -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -834,9 +804,7 @@ void HandleWifi(boolean scan)
|
|||
|
||||
//display networks in page
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (-1 == indices[i]) {
|
||||
continue; // skip dups
|
||||
}
|
||||
if (-1 == indices[i]) { continue; } // skip dups
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_SSID " %s, " D_RSSI " %d"), WiFi.SSID(indices[i]).c_str(), WiFi.RSSI(indices[i]));
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
int quality = WifiGetRssiAsQuality(WiFi.RSSI(indices[i]));
|
||||
|
@ -878,9 +846,7 @@ void HandleWifi(boolean scan)
|
|||
|
||||
void HandleMqttConfiguration()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_MQTT);
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
|
@ -903,9 +869,7 @@ void HandleMqttConfiguration()
|
|||
|
||||
void HandleLoggingConfiguration()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_LOGGING);
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
|
@ -952,9 +916,7 @@ void HandleLoggingConfiguration()
|
|||
|
||||
void HandleOtherConfiguration()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_OTHER);
|
||||
char stemp[40];
|
||||
|
||||
|
@ -990,9 +952,7 @@ void HandleOtherConfiguration()
|
|||
|
||||
void HandleBackupConfiguration()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_BACKUP_CONFIGURATION));
|
||||
|
||||
uint8_t buffer[sizeof(Settings)];
|
||||
|
@ -1018,9 +978,7 @@ void HandleBackupConfiguration()
|
|||
|
||||
void HandleSaveSettings()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
|
||||
char stemp[TOPSZ];
|
||||
char stemp2[TOPSZ];
|
||||
|
@ -1186,9 +1144,7 @@ void HandleSaveSettings()
|
|||
|
||||
void HandleResetConfiguration()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
|
||||
char svalue[33];
|
||||
|
||||
|
@ -1208,9 +1164,7 @@ void HandleResetConfiguration()
|
|||
|
||||
void HandleRestoreConfiguration()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESTORE_CONFIGURATION);
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
|
@ -1228,9 +1182,7 @@ void HandleRestoreConfiguration()
|
|||
|
||||
void HandleUpgradeFirmware()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_FIRMWARE_UPGRADE);
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
|
@ -1249,9 +1201,7 @@ void HandleUpgradeFirmware()
|
|||
|
||||
void HandleUpgradeFirmwareStart()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
char svalue[100];
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPGRADE_STARTED));
|
||||
|
@ -1278,9 +1228,7 @@ void HandleUpgradeFirmwareStart()
|
|||
|
||||
void HandleUploadDone()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPLOAD_DONE));
|
||||
|
||||
char error[100];
|
||||
|
@ -1327,13 +1275,9 @@ void HandleUploadLoop()
|
|||
// Based on ESP8266HTTPUpdateServer.cpp uses ESP8266WebServer Parsing.cpp and Cores Updater.cpp (Update)
|
||||
boolean _serialoutput = (LOG_LEVEL_DEBUG <= seriallog_level);
|
||||
|
||||
if (HTTP_USER == webserver_state) {
|
||||
return;
|
||||
}
|
||||
if (HTTP_USER == webserver_state) { return; }
|
||||
if (upload_error) {
|
||||
if (!upload_file_type) {
|
||||
Update.end();
|
||||
}
|
||||
if (!upload_file_type) { Update.end(); }
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1408,9 +1352,7 @@ void HandleUploadLoop()
|
|||
if (_serialoutput) {
|
||||
Serial.printf(".");
|
||||
upload_progress_dot_count++;
|
||||
if (!(upload_progress_dot_count % 80)) {
|
||||
Serial.println();
|
||||
}
|
||||
if (!(upload_progress_dot_count % 80)) { Serial.println(); }
|
||||
}
|
||||
}
|
||||
} else if(!upload_error && (UPLOAD_FILE_END == upload.status)) {
|
||||
|
@ -1419,9 +1361,7 @@ void HandleUploadLoop()
|
|||
}
|
||||
if (!upload_file_type) {
|
||||
if (!Update.end(true)) { // true to set the size to the current progress
|
||||
if (_serialoutput) {
|
||||
Update.printError(Serial);
|
||||
}
|
||||
if (_serialoutput) { Update.printError(Serial); }
|
||||
upload_error = 6;
|
||||
return;
|
||||
}
|
||||
|
@ -1434,9 +1374,7 @@ void HandleUploadLoop()
|
|||
restart_flag = 0;
|
||||
MqttRetryCounter(0);
|
||||
upload_error = 7;
|
||||
if (!upload_file_type) {
|
||||
Update.end();
|
||||
}
|
||||
if (!upload_file_type) { Update.end(); }
|
||||
}
|
||||
delay(0);
|
||||
}
|
||||
|
@ -1451,9 +1389,7 @@ void HandlePreflightRequest()
|
|||
|
||||
void HandleHttpCommand()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
char svalue[INPUT_BUFFER_SIZE]; // big to serve Backlog
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_COMMAND));
|
||||
|
@ -1473,12 +1409,7 @@ void HandleHttpCommand()
|
|||
if (valid) {
|
||||
byte curridx = web_log_index;
|
||||
WebGetArg("cmnd", svalue, sizeof(svalue));
|
||||
if (strlen(svalue)) {
|
||||
// byte syslog_now = syslog_level;
|
||||
// syslog_level = 0; // Disable UDP syslog to not trigger hardware WDT - Seems to work fine since 5.7.1d (global logging)
|
||||
ExecuteCommand(svalue);
|
||||
// syslog_level = syslog_now;
|
||||
}
|
||||
if (strlen(svalue)) { ExecuteCommand(svalue); }
|
||||
|
||||
if (web_log_index != curridx) {
|
||||
byte counter = curridx;
|
||||
|
@ -1491,9 +1422,7 @@ void HandleHttpCommand()
|
|||
// [14:49:36 MQTT: stat/wemos5/RESULT = {"POWER":"OFF"}] > [{"POWER":"OFF"}]
|
||||
char* JSON = (char*)memchr(tmp, '{', len);
|
||||
if (JSON) { // Is it a JSON message (and not only [15:26:08 MQT: stat/wemos5/POWER = O])
|
||||
if (message.length() > 1) {
|
||||
message += F(",");
|
||||
}
|
||||
if (message.length() > 1) { message += F(","); }
|
||||
size_t JSONlen = len - (JSON - tmp);
|
||||
strlcpy(mqtt_data, JSON +1, JSONlen -2);
|
||||
message += mqtt_data;
|
||||
|
@ -1515,10 +1444,7 @@ void HandleHttpCommand()
|
|||
|
||||
void HandleConsole()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (HttpUser()) { return; }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONSOLE);
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
|
@ -1533,9 +1459,7 @@ void HandleConsole()
|
|||
|
||||
void HandleAjaxConsoleRefresh()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
char svalue[INPUT_BUFFER_SIZE]; // big to serve Backlog
|
||||
byte cflg = 1;
|
||||
byte counter = 0; // Initial start, should never be 0 again
|
||||
|
@ -1544,16 +1468,11 @@ void HandleAjaxConsoleRefresh()
|
|||
if (strlen(svalue)) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_COMMAND "%s"), svalue);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
// byte syslog_now = syslog_level;
|
||||
// syslog_level = 0; // Disable UDP syslog to not trigger hardware WDT - Seems to work fine since 5.7.1d (global logging)
|
||||
ExecuteCommand(svalue);
|
||||
// syslog_level = syslog_now;
|
||||
}
|
||||
|
||||
WebGetArg("c2", svalue, sizeof(svalue));
|
||||
if (strlen(svalue)) {
|
||||
counter = atoi(svalue);
|
||||
}
|
||||
if (strlen(svalue)) { counter = atoi(svalue); }
|
||||
|
||||
byte last_reset_web_log_flag = reset_web_log_flag;
|
||||
String message = F("}9"); // Cannot load mqtt_data here as <> will be encoded by replacements below
|
||||
|
@ -1580,7 +1499,7 @@ void HandleAjaxConsoleRefresh()
|
|||
message += mqtt_data;
|
||||
}
|
||||
counter++;
|
||||
if (!counter) counter++; // Skip 0 as it is not allowed
|
||||
if (!counter) { counter++; } // Skip 0 as it is not allowed
|
||||
} while (counter != web_log_index);
|
||||
// XML encoding to fix blank console log in concert with javascript decodeURIComponent
|
||||
message.replace(F("%"), F("%25")); // Needs to be done first as otherwise the % in %26 will also be converted
|
||||
|
@ -1596,9 +1515,7 @@ void HandleAjaxConsoleRefresh()
|
|||
|
||||
void HandleInformation()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_INFORMATION);
|
||||
|
||||
char stopic[TOPSZ];
|
||||
|
@ -1712,9 +1629,7 @@ void HandleInformation()
|
|||
|
||||
void HandleRestart()
|
||||
{
|
||||
if (HttpUser()) {
|
||||
return;
|
||||
}
|
||||
if (HttpUser()) { return; }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESTART);
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
|
@ -1738,9 +1653,7 @@ void HandleNotFound()
|
|||
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP "Not fount (%s)"), WebServer->uri().c_str());
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
|
||||
if (CaptivePortal()) { // If captive portal redirect instead of displaying the error page.
|
||||
return;
|
||||
}
|
||||
if (CaptivePortal()) { return; } // If captive portal redirect instead of displaying the error page.
|
||||
|
||||
#ifdef USE_EMULATION
|
||||
String path = WebServer->uri();
|
||||
|
@ -1778,9 +1691,7 @@ boolean ValidIpAddress(String str)
|
|||
{
|
||||
for (uint16_t i = 0; i < str.length(); i++) {
|
||||
int c = str.charAt(i);
|
||||
if (c != '.' && (c < '0' || c > '9')) {
|
||||
return false;
|
||||
}
|
||||
if (c != '.' && (c < '0' || c > '9')) { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,173 @@
|
|||
/*
|
||||
xsns_22_sr04.ino - SR04 ultrasonic sensor support for Sonoff-Tasmota
|
||||
|
||||
Copyright (C) 2018 Nuno Ferreira and Theo Arends
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef USE_SR04
|
||||
/*********************************************************************************************\
|
||||
* HC-SR04, HC-SR04+, JSN-SR04T - Ultrasonic distance sensor
|
||||
*
|
||||
* Code for SR04 family of ultrasonic distance sensors
|
||||
* References:
|
||||
* - https://www.dfrobot.com/wiki/index.php/Weather-proof_Ultrasonic_Sensor_SKU_:_SEN0207
|
||||
\*********************************************************************************************/
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
|
||||
uint8_t sr04_echo_pin = 0;
|
||||
uint8_t sr04_trig_pin = 0;
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Embedded stripped and tuned NewPing library from Tim Eckel - teckel@leethost.com
|
||||
* https://bitbucket.org/teckel12/arduino-new-ping
|
||||
\*********************************************************************************************/
|
||||
#define US_ROUNDTRIP_CM 58 // Microseconds (uS) it takes sound to travel round-trip 1cm (2cm total), uses integer to save compiled code space. Default: 58
|
||||
#define US_ROUNDTRIP_IN 148 // Microseconds (uS) it takes sound to travel round-trip 1 inch (2 inches total), uses integer to save compiled code space. Default: 148
|
||||
#define PING_MEDIAN_DELAY 29000
|
||||
#define MAX_SENSOR_DISTANCE 500
|
||||
#define PING_OVERHEAD 5
|
||||
|
||||
// Conversion from uS to distance (round result to nearest cm or inch).
|
||||
#define EchoConvert(echoTime, conversionFactor) (max(((unsigned int)echoTime + conversionFactor / 2) / conversionFactor, (echoTime ? 1 : 0)))
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
void Sr04Init()
|
||||
{
|
||||
sr04_echo_pin = pin[GPIO_SR04_ECHO];
|
||||
sr04_trig_pin = pin[GPIO_SR04_TRIG];
|
||||
pinMode(sr04_trig_pin, OUTPUT);
|
||||
pinMode(sr04_echo_pin, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
boolean Sr04Read(uint16_t *distance)
|
||||
{
|
||||
uint16_t duration = 0;
|
||||
|
||||
*distance = 0;
|
||||
|
||||
/* Send ping and get delay */
|
||||
duration = Sr04GetSamples(9, 250);
|
||||
|
||||
/* Calculate the distance (in cm) based on the speed of sound. */
|
||||
*distance = EchoConvert(duration, US_ROUNDTRIP_CM);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint16_t Sr04Ping(uint16_t max_cm_distance)
|
||||
{
|
||||
uint16_t duration = 0;
|
||||
uint16_t maxEchoTime, maxTime;
|
||||
|
||||
maxEchoTime = min(max_cm_distance + 1, (uint16_t) MAX_SENSOR_DISTANCE + 1) * US_ROUNDTRIP_CM;
|
||||
|
||||
/* The following trigPin/echoPin cycle is used to determine the
|
||||
distance of the nearest object by bouncing soundwaves off of it. */
|
||||
digitalWrite(sr04_trig_pin, LOW);
|
||||
delayMicroseconds(2);
|
||||
digitalWrite(sr04_trig_pin, HIGH);
|
||||
delayMicroseconds(10);
|
||||
digitalWrite(sr04_trig_pin, LOW);
|
||||
|
||||
/* Wait for the echo */
|
||||
duration = pulseIn(sr04_echo_pin, HIGH, 26000) - PING_OVERHEAD;
|
||||
|
||||
return (duration > maxEchoTime) ? 0 : duration;
|
||||
}
|
||||
|
||||
uint16_t Sr04GetSamples(uint8_t it, uint16_t max_cm_distance) {
|
||||
uint16_t uS[it];
|
||||
uint16_t last;
|
||||
uint8_t j;
|
||||
uint8_t i = 0;
|
||||
uint16_t t;
|
||||
uS[0] = 0;
|
||||
|
||||
while (i < it) {
|
||||
t = micros();
|
||||
last = Sr04Ping(max_cm_distance);
|
||||
|
||||
if (last != 0) {
|
||||
if (i > 0) {
|
||||
for (j = i; j > 0 && uS[j - 1] < last; j--) {
|
||||
uS[j] = uS[j - 1];
|
||||
}
|
||||
} else {
|
||||
j = 0;
|
||||
}
|
||||
uS[j] = last;
|
||||
i++;
|
||||
} else {
|
||||
it--;
|
||||
}
|
||||
if (i < it && micros() - t < PING_MEDIAN_DELAY) {
|
||||
delay((PING_MEDIAN_DELAY + t - micros()) / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
return (uS[1]); // Return the ping distance from the 2nd highest reading
|
||||
}
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
const char HTTP_SNS_DISTANCE[] PROGMEM =
|
||||
"%s{s}SR04 " D_DISTANCE "{m}%d" D_UNIT_CENTIMETER "{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
void Sr04Show(boolean json)
|
||||
{
|
||||
uint16_t distance;
|
||||
|
||||
if (Sr04Read(&distance)) { // Check if read failed
|
||||
if(json) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"SR04\":{\"" D_JSON_DISTANCE "\":%d}"), mqtt_data, distance);
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_DISTANCE, mqtt_data, distance);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
\*********************************************************************************************/
|
||||
|
||||
#define XSNS_22
|
||||
|
||||
boolean Xsns22(byte function)
|
||||
{
|
||||
boolean result = false;
|
||||
|
||||
if ((pin[GPIO_SR04_ECHO] < 99) && (pin[GPIO_SR04_TRIG] < 99)) {
|
||||
switch (function) {
|
||||
case FUNC_INIT:
|
||||
Sr04Init();
|
||||
break;
|
||||
case FUNC_JSON_APPEND:
|
||||
Sr04Show(1);
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_WEB_APPEND:
|
||||
Sr04Show(0);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // USE_SR04
|
Loading…
Reference in New Issue