<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[RemoteXY community — Пример выключателя - где ошибся?]]></title>
		<link>https://forum.remotexy.com/viewtopic.php?id=421</link>
		<atom:link href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=421&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Пример выключателя - где ошибся?.]]></description>
		<lastBuildDate>Sun, 17 Jun 2018 22:09:44 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Пример выключателя - где ошибся?]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=1652#p1652</link>
			<description><![CDATA[<p>Ну да, навертел малехо). Сервер поднят для прошивки по воздуху. Кнопки на 14 и пятом пинах ESP. При первом нажатии переключатель включается (работает). При втором должен выключаться (не работает). Защита от дребезга, как ни странно действует,&nbsp; но позже я&nbsp; переделал на millis.</p>]]></description>
			<author><![CDATA[null@example.com (Dark2005)]]></author>
			<pubDate>Sun, 17 Jun 2018 22:09:44 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=1652#p1652</guid>
		</item>
		<item>
			<title><![CDATA[Re: Пример выключателя - где ошибся?]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=1546#p1546</link>
			<description><![CDATA[<div class="quotebox"><cite>zsm wrote:</cite><blockquote><p>Что то вы уважаемый нахуевертили здесь, зачем сервер поднимаете ?<br />Пишете про кнопку , а в коде переключатели используются..<br />Попробуйте от простого к сложному.</p></blockquote></div><p>Поддерживаю! <br />ТС с дребезгом делеями не борятся...</p>]]></description>
			<author><![CDATA[null@example.com (alchi26)]]></author>
			<pubDate>Sat, 05 May 2018 04:03:57 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=1546#p1546</guid>
		</item>
		<item>
			<title><![CDATA[Re: Пример выключателя - где ошибся?]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=1478#p1478</link>
			<description><![CDATA[<p>Что то вы уважаемый нахуевертили здесь, зачем сервер поднимаете ?<br />Пишете про кнопку , а в коде переключатели используются..<br />Попробуйте от простого к сложному.</p>]]></description>
			<author><![CDATA[null@example.com (zsm)]]></author>
			<pubDate>Sun, 08 Apr 2018 14:37:42 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=1478#p1478</guid>
		</item>
		<item>
			<title><![CDATA[Re: Пример выключателя - где ошибся?]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=1428#p1428</link>
			<description><![CDATA[<p>Понятно. Недоработанно приложение. Жаль.</p>]]></description>
			<author><![CDATA[null@example.com (Dark2005)]]></author>
			<pubDate>Mon, 19 Mar 2018 17:43:32 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=1428#p1428</guid>
		</item>
		<item>
			<title><![CDATA[Пример выключателя - где ошибся?]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=1424#p1424</link>
			<description><![CDATA[<p>Здравствуйте. Сделал все по примеру с сайта,&nbsp; кнопка реле включает, но не выключает. Не подскажете где ошибка?<br />ESP8266 12F</p><p>/*<br />&nbsp; &nbsp;-- New project --<br />&nbsp; &nbsp;<br />&nbsp; &nbsp;This source code of graphical user interface <br />&nbsp; &nbsp;has been generated automatically by RemoteXY editor.<br />&nbsp; &nbsp;To compile this code using RemoteXY library 2.3.1 or later version <br />&nbsp; &nbsp;download by link <a target="_blank" href="http://remotexy.com/en/library/">http://remotexy.com/en/library/</a><br />&nbsp; &nbsp;To connect using RemoteXY mobile app by link <a target="_blank" href="http://remotexy.com/en/download/">http://remotexy.com/en/download/</a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp;- for ANDROID 4.0.1 or later version;<br />&nbsp; &nbsp; &nbsp;- for iOS 1.1.0 or later version;<br />&nbsp; &nbsp; <br />&nbsp; &nbsp;This source code is free software; you can redistribute it and/or<br />&nbsp; &nbsp;modify it under the terms of the GNU Lesser General Public<br />&nbsp; &nbsp;License as published by the Free Software Foundation; either<br />&nbsp; &nbsp;version 2.1 of the License, or (at your option) any later version.&nbsp; &nbsp; <br />*/</p><p>//////////////////////////////////////////////<br />//&nbsp; &nbsp; &nbsp; &nbsp; RemoteXY include library&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br />//////////////////////////////////////////////</p><p>// определение режима соединения и подключение библиотеки RemoteXY <br />#define REMOTEXY_MODE__ESP8266WIFI_LIB<br />#include &lt;ESP8266WiFi.h&gt;<br />#include &lt;WiFiClient.h&gt;<br />#include &lt;ESP8266WebServer.h&gt;<br />#include &lt;ESP8266mDNS.h&gt;<br />#include &lt;RemoteXY.h&gt;<br />// NETWORK: Static IP details...<br />IPAddress ip(192, 168, 0, 100);<br />IPAddress gateway(192, 168, 0, 1);<br />IPAddress subnet(255, 255, 255, 0);</p><br /><p>// настройки соединения <br />#define REMOTEXY_WIFI_SSID &quot;NETGEAR&quot;<br />#define REMOTEXY_WIFI_PASSWORD &quot;zorg1498prost12ant498&quot;<br />#define REMOTEXY_SERVER_PORT 6377</p><br /><br /><p>// конфигурация интерфейса&nbsp; <br />#pragma pack(push, 1)<br />uint8_t RemoteXY_CONF[] =<br />&nbsp; { 255,4,0,0,0,87,0,6,4,1,<br />&nbsp; 2,0,4,7,55,14,1,208,146,208,<br />&nbsp; 186,208,187,46,32,49,0,79,70,70,<br />&nbsp; 0,2,0,4,30,55,14,1,208,146,<br />&nbsp; 208,186,208,187,46,32,50,0,79,70,<br />&nbsp; 70,0,2,0,4,53,55,15,1,208,<br />&nbsp; 146,208,186,208,187,46,32,51,0,79,<br />&nbsp; 70,70,0,2,0,5,77,54,15,1,<br />&nbsp; 208,146,208,186,208,187,46,32,52,0,<br />&nbsp; 79,70,70,0 };<br />&nbsp; <br />// структура определяет все переменные вашего интерфейса управления <br />struct {</p><p>&nbsp; &nbsp; // input variable<br />&nbsp; &nbsp;uint8_t switch_3; // =1 если переключатель включен и =0 если отключен <br />&nbsp; uint8_t switch_4; // =1 если переключатель включен и =0 если отключен </p><p>&nbsp; &nbsp; // other variable<br />&nbsp; uint8_t connect_flag;&nbsp; // =1 if wire connected, else =0 </p><p>} RemoteXY;<br />#pragma pack(pop)</p><p>/////////////////////////////////////////////<br />//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END RemoteXY include&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br />/////////////////////////////////////////////</p><p>// Подключаем реле к ногам:</p><p>#define BUTTON_1 14 //Pin for knopka 1<br />#define BUTTON_2 5 //Pin for knopkay2<br />#define&nbsp; rele3 12 //Pin for reley3<br />#define&nbsp; rele4 13 //Pin for reley4<br />int currentValue1, prevValue1;<br />int currentValue2, prevValue2;</p><br /><br /><p>const char* host = &quot;Doom1-webupdate&quot;;<br />const char* ssid = &quot;NETGEAR&quot;;<br />const char* password = &quot;zorg1498prost12ant498&quot;;</p><p>ESP8266WebServer server(80);<br />const char* serverIndex = &quot;&lt;form method=&#039;POST&#039; action=&#039;/update&#039; enctype=&#039;multipart/form-data&#039;&gt;&lt;input type=&#039;file&#039; name=&#039;update&#039;&gt;&lt;input type=&#039;submit&#039; value=&#039;Update&#039;&gt;&lt;/form&gt;&quot;;</p><p>void setup() <br />{<br />&nbsp; // Начало серверной части<br />&nbsp; Serial.begin(115200);<br />&nbsp; &nbsp; Serial.println();<br />&nbsp; Serial.println(&quot;Booting Sketch...&quot;);<br />&nbsp; WiFi.mode(WIFI_AP_STA);<br />&nbsp; // Static IP Setup Info Here...<br />WiFi.config(ip, gateway, subnet);<br />&nbsp; WiFi.begin(ssid, password);<br />&nbsp; if(WiFi.waitForConnectResult() == WL_CONNECTED){<br />&nbsp; &nbsp; MDNS.begin(host);<br />&nbsp; &nbsp; server.on(&quot;/&quot;, HTTP_GET, [](){<br />&nbsp; &nbsp; &nbsp; server.sendHeader(&quot;Connection&quot;, &quot;close&quot;);<br />&nbsp; &nbsp; &nbsp; server.sendHeader(&quot;Access-Control-Allow-Origin&quot;, &quot;*&quot;);<br />&nbsp; &nbsp; &nbsp; server.send(200, &quot;text/html&quot;, serverIndex);<br />&nbsp; &nbsp; });<br />&nbsp; &nbsp; server.on(&quot;/update&quot;, HTTP_POST, [](){<br />&nbsp; &nbsp; &nbsp; server.sendHeader(&quot;Connection&quot;, &quot;close&quot;);<br />&nbsp; &nbsp; &nbsp; server.sendHeader(&quot;Access-Control-Allow-Origin&quot;, &quot;*&quot;);<br />&nbsp; &nbsp; &nbsp; server.send(200, &quot;text/plain&quot;, (Update.hasError())?&quot;FAIL&quot;:&quot;OK&quot;);<br />&nbsp; &nbsp; &nbsp; ESP.restart();<br />&nbsp; &nbsp; },[](){<br />&nbsp; &nbsp; &nbsp; HTTPUpload&amp; upload = server.upload();<br />&nbsp; &nbsp; &nbsp; if(upload.status == UPLOAD_FILE_START){<br />&nbsp; &nbsp; &nbsp; &nbsp; Serial.setDebugOutput(true);<br />&nbsp; &nbsp; &nbsp; &nbsp; WiFiUDP::stopAll();<br />&nbsp; &nbsp; &nbsp; &nbsp; Serial.printf(&quot;Update: %s\n&quot;, upload.filename.c_str());<br />&nbsp; &nbsp; &nbsp; &nbsp; uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) &amp; 0xFFFFF000;<br />&nbsp; &nbsp; &nbsp; &nbsp; if(!Update.begin(maxSketchSpace)){//start with max available size<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Update.printError(Serial);<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; } else if(upload.status == UPLOAD_FILE_WRITE){<br />&nbsp; &nbsp; &nbsp; &nbsp; if(Update.write(upload.buf, upload.currentSize) != upload.currentSize){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Update.printError(Serial);<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; } else if(upload.status == UPLOAD_FILE_END){<br />&nbsp; &nbsp; &nbsp; &nbsp; if(Update.end(true)){ //true to set the size to the current progress<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Serial.printf(&quot;Update Success: %u\nRebooting...\n&quot;, upload.totalSize);<br />&nbsp; &nbsp; &nbsp; &nbsp; } else {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Update.printError(Serial);<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; Serial.setDebugOutput(false);<br />&nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; yield();<br />&nbsp; &nbsp; });<br />&nbsp; &nbsp; server.begin();<br />&nbsp; &nbsp; MDNS.addService(&quot;http&quot;, &quot;tcp&quot;, 80);<br />&nbsp; <br />&nbsp; &nbsp; Serial.printf(&quot;Прошивка завершена.Наш IP&quot;, host);<br />&nbsp; &nbsp; Serial.println(WiFi.localIP());<br />&nbsp; } else {<br />&nbsp; &nbsp; Serial.println(&quot;WiFi Failed&quot;);<br />&nbsp; }<br />&nbsp; // Конец серверной части<br />&nbsp; RemoteXY_Init (); // Мои данные<br />&nbsp; <br />&nbsp; pinMode(rele3, OUTPUT);<br />&nbsp; pinMode(rele4, OUTPUT);<br />&nbsp; pinMode(BUTTON_1, INPUT);<br />&nbsp; pinMode(BUTTON_2, INPUT);<br />&nbsp; RemoteXY.switch_3=0;<br />&nbsp; RemoteXY.switch_4=0;<br />&nbsp; // TODO you setup code<br />&nbsp; <br />}</p><p>void loop() <br />&nbsp; {<br />&nbsp; RemoteXY_Handler ();<br />&nbsp; /*Защита от дребезга кнопок*/<br />&nbsp; currentValue1 = digitalRead(BUTTON_1);<br />&nbsp; if (currentValue1 != prevValue1) {<br />&nbsp; &nbsp; // Что-то изменилось, здесь возможна зона неопределенности<br />&nbsp; &nbsp; // Делаем задержку<br />&nbsp; &nbsp; delay(10);<br />&nbsp; &nbsp; // А вот теперь спокойно считываем значение, считая, что нестабильность исчезла<br />&nbsp; &nbsp; currentValue1 = digitalRead(BUTTON_1);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp;prevValue1 = currentValue1;<br />&nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp;currentValue2 = digitalRead(BUTTON_2);<br />&nbsp; if (currentValue2 != prevValue2) {<br />&nbsp; &nbsp; // Что-то изменилось, здесь возможна зона неопределенности<br />&nbsp; &nbsp; // Делаем задержку<br />&nbsp; &nbsp; delay(10);<br />&nbsp; &nbsp; // А вот теперь спокойно считываем значение, считая, что нестабильность исчезла<br />&nbsp; &nbsp; currentValue2 = digitalRead(BUTTON_2);<br />&nbsp; }<br />&nbsp; &nbsp;prevValue2 = currentValue2;<br />&nbsp; /*Управление реле через функцию RemoteXY*/<br />&nbsp; if (currentValue1==HIGH&amp;&amp;(RemoteXY.switch_3==1)) { //если нажата кнопка и поле структуры RemoteXY.switch_3 равно 1, <br />&nbsp; //то выключаем освещение присвоив полю структуры RemoteXY.switch_3 значение 0<br />&nbsp; &nbsp; RemoteXY.switch_3=0;<br />&nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; if (currentValue1==HIGH&amp;&amp;(RemoteXY.switch_3==0)) { //тут наоборот, если нажата кнопка, а реле выключено, <br />&nbsp; //то включаем реле посредством присваивания полю структуры RemoteXY.switch_3 значения 1<br />&nbsp; &nbsp; RemoteXY.switch_3=1;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; digitalWrite(rele3, (RemoteXY.switch_3==0)?LOW:HIGH); //если поле структуры RemoteXY.switch_1 равно нулю, то свет выключен, если 1, то включен </p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; if (currentValue2==HIGH&amp;&amp;(RemoteXY.switch_4==1)) { //если нажата кнопка и поле структуры RemoteXY.switch_1 равно 1, <br />&nbsp; //то выключаем освещение присвоив полю структуры RemoteXY.switch_4 значение 0<br />&nbsp; &nbsp; RemoteXY.switch_4=0;<br />&nbsp; &nbsp; &nbsp;}<br />&nbsp; if (currentValue2==HIGH&amp;&amp;(RemoteXY.switch_4==0)) { //тут наоборот, если нажата кнопка, а реле выключено, <br />&nbsp; //то включаем реле посредством присваивания полю структуры RemoteXY.switch_4 значения 1<br />&nbsp; &nbsp; RemoteXY.switch_4=1;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp;digitalWrite(rele4, (RemoteXY.switch_4==0)?LOW:HIGH);//если поле структуры RemoteXY.switch_1 равно нулю, то свет выключен, если 1, то включен<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp;<br />}</p>]]></description>
			<author><![CDATA[null@example.com (Dark2005)]]></author>
			<pubDate>Sun, 18 Mar 2018 06:56:28 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=1424#p1424</guid>
		</item>
	</channel>
</rss>
