|
|
@ -3,9 +3,11 @@ |
|
|
|
|
|
|
|
|
|
|
|
#define LED_PIN 13 |
|
|
|
#define LED_PIN 13 |
|
|
|
|
|
|
|
|
|
|
|
int8_t blinking = 0; |
|
|
|
int8_t blinking = 0; |
|
|
|
int8_t frequency = 10; |
|
|
|
int8_t frequency = 10; |
|
|
|
|
|
|
|
uint8_t pattern = 2; |
|
|
|
uint16_t elapse = 100; |
|
|
|
uint16_t elapse = 100; |
|
|
|
|
|
|
|
uint16_t elapse_delta = 200; |
|
|
|
uint32_t next_ts = 0; |
|
|
|
uint32_t next_ts = 0; |
|
|
|
|
|
|
|
|
|
|
|
void ledHtmlCallback(WebServerCommand command, char * data, int dataLen); |
|
|
|
void ledHtmlCallback(WebServerCommand command, char * data, int dataLen); |
|
|
@ -38,6 +40,7 @@ void loop() |
|
|
|
{ |
|
|
|
{ |
|
|
|
digitalWrite(LED_PIN, !digitalRead(LED_PIN)); |
|
|
|
digitalWrite(LED_PIN, !digitalRead(LED_PIN)); |
|
|
|
next_ts += elapse; |
|
|
|
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 ) |
|
|
|
if( strcmp_P(data, PSTR("frequency") ) == 0 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
frequency = webServer.getArgInt(); |
|
|
|
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; |
|
|
|
break; |
|
|
|
case LOAD: |
|
|
|
case LOAD: |
|
|
|
webServer.setArgNum(2); |
|
|
|
webServer.setArgNum(3); |
|
|
|
webServer.setArgInt("frequency", frequency); |
|
|
|
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: |
|
|
|
case REFRESH: |
|
|
|
if( command == REFRESH ) |
|
|
|
if( command == REFRESH ) |
|
|
|
webServer.setArgNum(1); |
|
|
|
webServer.setArgNum(1); |
|
|
|