Added: radio button

pull/193/head
Karai Csaba 9 years ago committed by Thorsten von Eicken
parent 9958c332f2
commit 680edf931b
  1. 36
      examples/arduino/EspLinkSample/EspLinkSample.ino
  2. 5
      examples/arduino/EspLinkSample/WebServer.cpp
  3. 1
      examples/arduino/EspLinkSample/WebServer.h

@ -5,7 +5,9 @@
int8_t blinking = 0;
int8_t frequency = 10;
uint8_t pattern = 2;
uint16_t elapse = 100;
uint16_t elapse_delta = 200;
uint32_t next_ts = 0;
void ledHtmlCallback(WebServerCommand command, char * data, int dataLen);
@ -38,6 +40,7 @@ void loop()
{
digitalWrite(LED_PIN, !digitalRead(LED_PIN));
next_ts += elapse;
elapse = elapse_delta - elapse;
}
}
}
@ -66,12 +69,41 @@ void ledHtmlCallback(WebServerCommand command, char * data, int dataLen)
if( strcmp_P(data, PSTR("frequency") ) == 0 )
{
frequency = webServer.getArgInt();
elapse = 1000 / frequency;
digitalWrite(LED_PIN, false);
elapse_delta = 2000 / frequency;
elapse = pattern * elapse_delta / 4;
}
else if( strcmp_P(data, PSTR("pattern") ) == 0 )
{
char * arg = webServer.getArgString();
if( strcmp_P(arg, PSTR("25_75")) == 0 )
pattern = 1;
else if( strcmp_P(arg, PSTR("50_50")) == 0 )
pattern = 2;
else if( strcmp_P(arg, PSTR("75_25")) == 0 )
pattern = 3;
digitalWrite(LED_PIN, false);
elapse = pattern * elapse_delta / 4;
}
break;
case LOAD:
webServer.setArgNum(2);
webServer.setArgNum(3);
webServer.setArgInt("frequency", frequency);
switch(pattern)
{
case 1:
webServer.setArgStringP("pattern", PSTR("25_75"));
break;
case 2:
webServer.setArgStringP("pattern", PSTR("50_50"));
break;
case 3:
webServer.setArgStringP("pattern", PSTR("75_25"));
break;
}
case REFRESH:
if( command == REFRESH )
webServer.setArgNum(1);

@ -182,3 +182,8 @@ int32_t WebServer::getArgInt()
return (int32_t)atol(value_ptr);
}
char * WebServer::getArgString()
{
return value_ptr;
}

@ -77,6 +77,7 @@ class WebServer
void setArgStringP(const char * name, const char * value);
int32_t getArgInt();
char * getArgString();
};
#endif /* WEB_SERVER_H */

Loading…
Cancel
Save