Guppy
Registrato: Feb 2010
Città: Bologna
Acquariofilo: Marino
N° Acquari: 1
Età : 50
Messaggi: 126
Post "Grazie" / "Mi Piace"
Mentioned: 0 Post(s)
Annunci Mercatino: 0
|
..... continua
pagine.h
codice:
uint16_t http200ok(void) {return(es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nPragma: no-cache\r\n\r\n")));}
// prepare the webpage by writing the data to the tcp send buffer
uint16_t homepage(uint8_t *buf)
{
uint16_t plen;
plen = http200ok();
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>AquaControl</title></head><body>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<b>ACQUARIO</b><hr>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<a href=\"../?sez=4\">ILLUMINAZIONE<a></br>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<a href=\"../?sez=8\">SETUP OROLOGIO<a></br>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<a href=\"../?sez=9\">SD/LOGGER<a></br>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<hr>by Carlo COLOMBARI</body></html>"));
return(plen);
}
uint16_t page_logger(uint8_t *buf)
{
uint16_t plen;
plen = http200ok();
if (sdLogInCorso == 0) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>AquaControl</title></head><body>"));}
else {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>AquaControl</title></head><meta http-equiv=\"refresh\" content=\"3\"><body>"));}
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<b>SD/LOGGER</b><hr>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Stato SD card: "));
if (sdError == 0) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Ok</br>"));}
if (sdError == 1) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Non presente (trovato all'accensione)</br>"));}
if (sdError == 2) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("File logger.txt corrotto (trovato all'accensione)</br>"));}
if (sdError == 3) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("File logger.txt vuoto (trovato all'accensione)</br>"));}
if (sdError == 4) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("File logger.txt non esistente (trovato all'accensione)</br>"));}
if (sdError == 5) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("File logger.txt corrotto (trovato durante un log)</br>"));}
if (sdError == 6) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("File logger.txt vuoto (trovato durante un log)</br>"));}
if (sdError == 7) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("File logger.txt non esistente (trovato durante un log)</br>"));}
if (sdLogInCorso == 0)
{
if (sdError)
{
if ((sdError != 1) && (sdError != 2) && (sdError != 3) && (sdError != 6)) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Log: Fermo <a href=\"../?sez=9&act=3\">(TENTATIVO DI RIPRISTINO)<a></br>"));}
if ((sdError == 2) || (sdError == 3) || (sdError == 6)) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Formattazione SD <a href=\"../?sez=9&act=4\">(FORMATTA)<a></br>"));}
}
else
{
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Log: Fermo <a href=\"../?sez=9&act=1\">(ATTIVA)<a></br>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Formattazione SD <a href=\"../?sez=9&act=4\">(FORMATTA)<a></br>"));
}
}
else {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Log: In corso <a href=\"../?sez=9&act=2\">(DISATTIVA)<a></br>"));}
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<hr><a href=\"..\"><<< INDIETRO<a></body></html>"));
return(plen);
}
uint16_t page_orologio(uint8_t *buf)
{
char* stringa = "";
uint16_t plen;
plen = http200ok();
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>AquaControl</title></head><body>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<b>SETUP OROLOGIO</b><hr>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Ora: <a href=\"../?sez=8&act=1\">(+)<a> <a href=\"../?sez=8&act=2\">(-)<a> "));
if (rtcHour < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",rtcHour);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(":"));
if (rtcMinute < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",rtcMinute);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=8&act=3\">(+)<a> <a href=\"../?sez=8&act=4\">(-)<a></br>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Giorno: "));
if (rtcMonthDay < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",rtcMonthDay);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
sprintf(stringa,"%d",rtcMonthDay);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=8&act=5\">(+)<a> <a href=\"../?sez=8&act=6\">(-)<a> "));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Mese: "));
if (rtcMonth == 1) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Gennaio"));}
if (rtcMonth == 2) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Febbraio"));}
if (rtcMonth == 3) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Marzo"));}
if (rtcMonth == 4) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Aprile"));}
if (rtcMonth == 5) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Maggio"));}
if (rtcMonth == 6) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Giugno"));}
if (rtcMonth == 7) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Luglio"));}
if (rtcMonth == 8) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Agosto"));}
if (rtcMonth == 9) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Settembre"));}
if (rtcMonth == 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Ottobre"));}
if (rtcMonth == 11) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Novembre"));}
if (rtcMonth == 12) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Dicembre"));}
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=8&act=7\">(Cambia)<a> "));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Anno: 20"));
sprintf(stringa,"%d",rtcYear);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=8&act=8\">(+)<a> <a href=\"../?sez=8&act=9\">(-)<a></br>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Giorno della settimana: "));
if (rtcWeekDay == 1) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Domenica"));}
if (rtcWeekDay == 2) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Lunedì"));}
if (rtcWeekDay == 3) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Martedì"));}
if (rtcWeekDay == 4) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Mercoledì"));}
if (rtcWeekDay == 5) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Giovedì"));}
if (rtcWeekDay == 6) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Venerdì"));}
if (rtcWeekDay == 7) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Sabato"));}
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=8&act=0\">(Cambia)<a>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<hr><a href=\"..\"><<< INDIETRO<a></body></html>"));
return(plen);
}
uint16_t page_illuminazione(uint8_t *buf)
{
uint16_t plen;
plen = http200ok();
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>AquaControl</title></head><body>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<b>ILLUMINAZIONE</b><hr>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<a href=\"../?sez=4&cmd=1\">SETUP FOTOPERIODO<a></br>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<a href=\"../?sez=4&cmd=3\">SETUP POTENZA/TEMPERATURA<a></br>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<a href=\"../?sez=4&cmd=5\">SETUP EFFETTI LUCE<a></br>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<hr><a href=\"..\"><<< INDIETRO<a></body></html>"));
return(plen);
}
uint16_t page_fotoperiodo(uint8_t *buf)
{
char* stringa = "";
uint16_t plen;
plen = http200ok();
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>AquaControl</title></head><body>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<b>SETUP FOTOPERIODO</b><hr>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Ora accensione: <a href=\"../?sez=4&cmd=1&act=1\">(+)<a> <a href=\"../?sez=4&cmd=1&act=2\">(-)<a> "));
if (luciOraAccensione < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciOraAccensione);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(":"));
if (luciMinutoAccensione < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciMinutoAccensione);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=4&cmd=1&act=3\">(+)<a> <a href=\"../?sez=4&cmd=1&act=4\">(-)<a></br>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Durata alba: "));
if (luciMinutiDurataAlba < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciMinutiDurataAlba);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" minuti <a href=\"../?sez=4&cmd=1&act=5\">(+)<a> <a href=\"../?sez=4&cmd=1&act=6\">(-)<a></br>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Durata accensione completa: <a href=\"../?sez=4&cmd=2&act=1\">(+)<a> <a href=\"../?sez=4&cmd=2&act=2\">(-)<a> "));
if (luciOreAccensioneCompleta < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciOreAccensioneCompleta);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(":"));
if (luciMinutiAccensioneCompleta < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciMinutiAccensioneCompleta);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=4&cmd=2&act=3\">(+)<a> <a href=\"../?sez=4&cmd=2&act=4\">(-)<a></br>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Durata tramonto: "));
if (luciMinutiDurataTramonto < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciMinutiDurataTramonto);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" minuti <a href=\"../?sez=4&cmd=2&act=5\">(+)<a> <a href=\"../?sez=4&cmd=2&act=6\">(-)<a></br>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<hr><a href=\"../?sez=4\"><<< INDIETRO<a></body></html>"));
return(plen);
}
uint16_t page_illuminazione_potenza(uint8_t *buf)
{
char* stringa = "";
uint16_t plen;
plen = http200ok();
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>AquaControl</title></head><body>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<b>SETUP POTENZA/TEMPERATURA</b><hr>"));
// plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0><TR><TD WIDTH=120 ALIGN=CENTER>SX</TD><TD WIDTH=120 ALIGN=CENTER>RGB</TD><TD WIDTH=120 ALIGN=CENTER>DX</TD></TR><TR><TD>BLU: "));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<TABLE><TR><TD>SX</TD><TD>RGB</TD><TD>DX</TD></TR><TR><TD>BLU: "));
if (luciTargetBluSx < 100) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
if (luciTargetBluSx < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciTargetBluSx);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=4&cmd=3&act=1\">(+)<a> <a href=\"../?sez=4&cmd=3&act=2\">(-)<a></TD><TD>R: "));
if (luciTargetRRGB < 100) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
if (luciTargetRRGB < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciTargetRRGB);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=4&cmd=3&act=3\">(+)<a> <a href=\"../?sez=4&cmd=3&act=4\">(-)<a></TD><TD>BLU: "));
if (luciTargetBluDx < 100) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
if (luciTargetBluDx < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciTargetBluDx);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=4&cmd=3&act=5\">(+)<a> <a href=\"../?sez=4&cmd=3&act=6\">(-)<a></TD></TR><TR><TD>10K: "));
if (luciTarget10kSx < 100) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
if (luciTarget10kSx < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciTarget10kSx);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=4&cmd=3&act=7\">(+)<a> <a href=\"../?sez=4&cmd=3&act=8\">(-)<a></TD><TD>G: "));
if (luciTargetGRGB < 100) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
if (luciTargetGRGB < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciTargetGRGB);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=4&cmd=3&act=9\">(+)<a> <a href=\"../?sez=4&cmd=4&act=1\">(-)<a></TD><TD>10K: "));
if (luciTarget10kDx < 100) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
if (luciTarget10kDx < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciTarget10kDx);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=4&cmd=4&act=2\">(+)<a> <a href=\"../?sez=4&cmd=4&act=3\">(-)<a></TD></TR><TR><TD>20K: "));
if (luciTarget20kSx < 100) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
if (luciTarget20kSx < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciTarget20kSx);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=4&cmd=4&act=4\">(+)<a> <a href=\"../?sez=4&cmd=4&act=5\">(-)<a></TD><TD>B: "));
if (luciTargetBRGB < 100) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
if (luciTargetBRGB < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciTargetBRGB);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=4&cmd=4&act=6\">(+)<a> <a href=\"../?sez=4&cmd=4&act=7\">(-)<a></TD><TD>20K: "));
if (luciTarget20kDx < 100) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
if (luciTarget20kDx < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciTarget20kDx);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=4&cmd=4&act=8\">(+)<a> <a href=\"../?sez=4&cmd=4&act=9\">(-)<a></TD></TR></TABLE>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<hr><a href=\"../?sez=4\"><<< INDIETRO<a></body></html>"));
return(plen);
}
uint16_t page_illuminazione_effetti(uint8_t *buf)
{
char* stringa = "";
uint16_t plen;
plen = http200ok();
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>AquaControl</title></head><body>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<b>SETUP EFFETTI LUCE</b><hr>"));
if ((luciTipoAlbaTramonto == 1) || (luciTipoAlbaTramonto == 3)) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Effetto alba/tramonto: Prima blu e poi bianchi <a href=\"../?sez=4&cmd=5&act=1\">(Blu e bianchi assieme)</BR><a>"));}
else {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Effetto alba/tramonto: Blu e bianchi assieme <a href=\"../?sez=4&cmd=5&act=1\">(Prima blu e poi bianchi)</BR><a>"));}
if ((luciTipoAlbaTramonto == 2) || (luciTipoAlbaTramonto == 3)) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Effetto est/ovest: Sole sorge a est e tramonta a ovest <a href=\"../?sez=4&cmd=5&act=2\">(Sinistra e destra assieme)<a>"));}
else {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("Effetto est/ovest: Sinistra e destra assieme <a href=\"../?sez=4&cmd=5&act=2\">(Sole sorge a est e tramonta a ovest)<a>"));}
sprintf(stringa,"%d",luciTipoAlbaTramonto);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0><TR><TD WIDTH=160 ALIGN=CENTER>LUCE LUNARE</TD></TR><TR><TD>RED: "));
if (luciTargetRRGBLunare < 100) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
if (luciTargetRRGBLunare < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciTargetRRGBLunare);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=4&cmd=5&act=3\">(+)<a> <a href=\"../?sez=4&cmd=5&act=4\">(-)<a></TD></TR><TR><TD>GREEN: "));
if (luciTargetGRGBLunare < 100) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
if (luciTargetGRGBLunare < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciTargetGRGBLunare);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=4&cmd=5&act=5\">(+)<a> <a href=\"../?sez=4&cmd=5&act=6\">(-)<a></TD</TR><TR><TD>BLUE: "));
if (luciTargetBRGBLunare < 100) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
if (luciTargetBRGBLunare < 10) {plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("0"));}
sprintf(stringa,"%d",luciTargetBRGBLunare);
plen = es.ES_fill_tcp_data(buf,plen,stringa);
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR(" <a href=\"../?sez=4&cmd=5&act=7\">(+)<a> <a href=\"../?sez=4&cmd=5&act=8\">(-)<a></TD</TR></TABLE>"));
plen = es.ES_fill_tcp_data_p(buf,plen,PSTR("<hr><a href=\"../?sez=4\"><<< INDIETRO<a></body></html>"));
return(plen);
}
rtc.h
codice:
#define DS1307_ADDRESS 0x68
void inizializza_rtc()
{
Wire.begin();
msLastUpdateRTC = 0;
}
byte decToBcd(byte val) {return ((val/10*16) + (val%10));}
byte bcdToDec(byte val) {return ((val/16*10) + (val%16));}
void rtc_getDateTime()
{
if ((msCurrent - msLastUpdateRTC) > 500)
{
msLastUpdateRTC = msCurrent;
Wire.beginTransmission(DS1307_ADDRESS);
Wire.send(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_ADDRESS, 7);
rtcSecond = bcdToDec(Wire.receive());
rtcMinute = bcdToDec(Wire.receive());
rtcHour = bcdToDec(Wire.receive() & 0b111111); //24 hour time
rtcWeekDay = bcdToDec(Wire.receive()); //0-6 -> sunday - Saturday
rtcMonthDay = bcdToDec(Wire.receive());
rtcMonth = bcdToDec(Wire.receive());
rtcYear = bcdToDec(Wire.receive());
}
}
void rtc_setDateTime()
{
Wire.beginTransmission(DS1307_ADDRESS);
Wire.send(0); //stop Oscillator
Wire.send(decToBcd(rtcSecond));
Wire.send(decToBcd(rtcMinute));
Wire.send(decToBcd(rtcHour));
Wire.send(decToBcd(rtcWeekDay));
Wire.send(decToBcd(rtcMonthDay));
Wire.send(decToBcd(rtcMonth));
Wire.send(decToBcd(rtcYear));
Wire.send(0); //start
Wire.endTransmission();
}
sd.h
codice:
void inizializza_sd()
{
sdError = 0;
msLogger = 0;
sdLogInCorso = 0;
if (!SD.begin(SD_CS)) {sdError = 1;} // memory non inerita all'accensione
else
{
sdDataFile = SD.open("logger.txt", FILE_READ);
if (sdDataFile)
{
if (sdDataFile.available())
{
if (sdDataFile.read() == 70) {sdError = 0;} // Ok il file deve iniziare con una "F"
else {sdError = 2;} // file corrotto (non inizia con la lettera giusta all'accensione
}
else {sdError = 3;} // file vuoto all'accensione
}
else {sdError = 4;} // file non esistente all'accensione
sdDataFile.close();
}
}
void logger_sd()
{
// String sdDataString = "";
if (sdLogInCorso)
{
if((msCurrent - msLogger) > 5000) // LIMITE tenere se possibile 5 secondi con 1 alle volte si una un crash
{
msLogger = msCurrent;
if (sdError) {return;}
// test se la memory funziona o se è stata rimossa durante il log
sdDataFile = SD.open("logger.txt", FILE_READ);
if (sdDataFile)
{
if (sdDataFile.available())
{
if (sdDataFile.read() == 70) {sdError = 0;} // Ok il file deve iniziare con una "F"
else {sdError = 5;} // file corrotto (non inizia con la lettera giusta) durante la scrittura
}
else {sdError = 6;} // file vuoto durante la scrittura
}
else {sdError = 7;} // file non esistente durante la scrittura
sdDataFile.close();
if (sdError != 0)
{
sdLogInCorso = 0;
return;
}
// scrittura dei file di log
// sdDataString = String(millis());
sdDataString = "";
sdDataString += "4"; // LIMITE alle volte nel log al posto della prima colonna 4 mette 111. Non si capisce cosa è 111
sdDataString += ",";
// if (rtcMonth < 10) {sdDataString += "0";}
// sdDataString += String(rtcMonth);
// if (rtcMonthDay < 10) {sdDataString += "0";}
// sdDataString += String(rtcMonthDay);
// if (rtcHour < 10) {sdDataString += "0";}
// sdDataString += String(rtcHour);
// if (rtcMinute < 10) {sdDataString += "0";}
// sdDataString += String(rtcMinute);
// if (rtcSecond < 10) {sdDataString += "0";}
// sdDataString += String(rtcSecond);
// sdDataString += " 1234567890 1234567890 1234567890"; // LIMITE tenere massimo 40 caratteri per scrittura. con più caratteri alle volte si una un crash
// sdDataString += ","; // LIMITE tenere massimo 40 caratteri per scrittura. con più caratteri alle volte si una un crash
sdDataString += String(luciCurrentBluDx);
sdDataString += ",";
sdDataString += String(luciCurrentBluSx);
sdDataString += ",";
sdDataString += String(luciCurrent10kDx);
sdDataString += ",";
sdDataString += String(luciCurrent10kSx);
sdDataString += ",";
sdDataString += String(luciCurrent20kDx);
sdDataString += ",";
sdDataString += String(luciCurrent20kSx);
// sdDataString += ",";
// sdDataString += String(luciCurrentRRGB);
// sdDataString += ",";
// sdDataString += String(luciCurrentGRGB);
// sdDataString += ",";
// sdDataString += String(luciCurrentBRGB);
sdDataFile = SD.open("logger.txt", FILE_WRITE);
sdDataFile.println(sdDataString);
sdDataFile.close();
}
}
}
void formattazione_sd()
{
sdError = 0;
SD.remove("logger.txt");
sdDataFile = SD.open("logger.txt", FILE_WRITE);
sdDataFile.println("File di LOG del controller per acquari AquaControl");
sdDataFile.close();
}
web.h
codice:
// The ethernet shield
EtherShield es = EtherShield();
#include "pagine.h"
void inizializza_sd();
void formattazione_sd();
void rtc_setDateTime();
// The returned value is stored in the global var strbuf
uint8_t find_key_val(char *str,char *key)
{
uint8_t found = 0;
uint8_t i = 0;
char *kp;
kp = key;
while(*str && *str!=' ' && found == 0)
{
if (*str == *kp)
{
kp++;
if (*kp == '\0')
{
str++;
kp = key;
if (*str == '=') {found = 1;}
}
}
else {kp = key;}
str++;
}
if (found == 1)
{
// while(*str && *str != ' ' && *str != '&' && i < STR_BUFFER_SIZE)
while(*str && *str != ' ' && *str != '&' && i < STR_BUFFER_SIZE)
{
strbuf[i] = *str;
i++;
str++;
}
strbuf[i] = '\0'
}
return(found);
}
int8_t analyse_sez(char *str)
{
int8_t r = -1;
if (find_key_val(str,"sez")) {if (*strbuf < 0x3a && *strbuf > 0x2f) {r = (*strbuf - 0x30);}}
return r;
}
int8_t analyse_cmd(char *str)
{
int8_t r = -1;
if (find_key_val(str,"cmd")) {if (*strbuf < 0x3a && *strbuf > 0x2f) {r = (*strbuf - 0x30);}}
return r;
}
int8_t analyse_act(char *str)
{
int8_t r = -1;
if (find_key_val(str,"act")) {if (*strbuf < 0x3a && *strbuf > 0x2f) {r = (*strbuf - 0x30);}}
return r;
}
void webserver()
{
uint16_t plen, dat_p;
int8_t sez;
int8_t cmd;
int8_t act;
// LIMITE ogni 30 secondi è bene resettare il webserver che impiegherà 2 secondi a ripartire (serve in caso di crash)
if((msCurrent - msResetWeb) > 30000)
{
msResetWeb = msCurrent;
es.ES_enc28j60Init(mymac);
es.ES_init_ip_arp_udp_tcp(mymac,myip, MYWWWPORT);
}
while(1) {
// read packet, handle ping and wait for a tcp packet:
dat_p = es.ES_packetloop_icmp_tcp(buf,es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf));
/* dat_p will be unequal to zero if there is a valid
* http get */
if (dat_p == 0)
{
return;
}
// tcp port 80 begin
if (strncmp("GET ",(char *)&(buf[dat_p]),4) != 0)
{
// head, post and other methods:
dat_p = http200ok();
dat_p = es.ES_fill_tcp_data_p(buf,dat_p,PSTR("<h1>200 OK</h1>"));
goto SENDTCP;
}
// just one web page in the "root directory" of the web server
if (strncmp("/ ",(char *) & (buf[dat_p + 4]),2) == 0)
{
dat_p = homepage(buf);
goto SENDTCP;
}
sez = analyse_sez((char *) & (buf[dat_p+5]));
cmd = analyse_cmd((char *) & (buf[dat_p+5]));
act = analyse_act((char *) & (buf[dat_p+5]));
//***********************************************************************************************************************
//***********************************************************************************************************************
//***********************************************************************************************************************
//***********************************************************************************************************************
//***********************************************************************************************************************
if (sez == 4)
{
if ((cmd == 1) || (cmd == 2))
{
if (cmd == 1)
{
if (act == 1)
{
if (luciOraAccensione >= 23) {luciOraAccensione = 0u;}
else {luciOraAccensione++;}
EEPROM.write(INDIRIZZOLUCIORAACCENSIONE, luciOraAccensione);
}
else if (act == 2)
{
if (luciOraAccensione == 0) {luciOraAccensione = 23u;}
else {luciOraAccensione--;}
EEPROM.write(INDIRIZZOLUCIORAACCENSIONE, luciOraAccensione);
}
else if (act == 3)
{
if (luciMinutoAccensione >= 59) {luciMinutoAccensione = 0u;}
else {luciMinutoAccensione++;}
EEPROM.write(INDIRIZZOLUCIMINUTOACCENSIONE, luciMinutoAccensione);
}
else if (act == 4)
{
if (luciMinutoAccensione == 0) {luciMinutoAccensione = 59u;}
else {luciMinutoAccensione--;}
EEPROM.write(INDIRIZZOLUCIMINUTOACCENSIONE, luciMinutoAccensione);
}
else if (act == 5)
{
if (luciMinutiDurataAlba >= 54) {luciMinutiDurataAlba = 5u;}
else {luciMinutiDurataAlba++;}
EEPROM.write(INDIRIZZOLUCIMINUTIDURATAALBA, luciMinutiDurataAlba);
}
else if (act == 6)
{
if (luciMinutiDurataAlba <= 5) {luciMinutiDurataAlba = 54u;}
else {luciMinutiDurataAlba--;}
EEPROM.write(INDIRIZZOLUCIMINUTIDURATAALBA, luciMinutiDurataAlba);
}
}
else
{
if (act == 1)
{
if (luciOreAccensioneCompleta >= 16) {luciOreAccensioneCompleta = 0u;}
else {luciOreAccensioneCompleta++;}
EEPROM.write(INDIRIZZOLUCIOREACCENSIONECOMPLETA, luciOreAccensioneCompleta);
}
else if (act == 2)
{
if (luciOreAccensioneCompleta == 0) {luciOreAccensioneCompleta = 16u;}
else {luciOreAccensioneCompleta--;}
EEPROM.write(INDIRIZZOLUCIOREACCENSIONECOMPLETA, luciOreAccensioneCompleta);
}
else if (act == 3)
{
if (luciMinutiAccensioneCompleta >= 59) {luciMinutiAccensioneCompleta = 0u;}
else {luciMinutiAccensioneCompleta++;}
EEPROM.write(INDIRIZZOLUCIMINUTIACCENSIONECOMPLETA, luciMinutiAccensioneCompleta);
}
else if (act == 4)
{
if (luciMinutiAccensioneCompleta == 0) {luciMinutiAccensioneCompleta = 59u;}
else {luciMinutiAccensioneCompleta--;}
EEPROM.write(INDIRIZZOLUCIMINUTIACCENSIONECOMPLETA, luciMinutiAccensioneCompleta);
}
else if (act == 5)
{
if (luciMinutiDurataTramonto >= 54) {luciMinutiDurataTramonto = 5u;}
else {luciMinutiDurataTramonto++;}
EEPROM.write(INDIRIZZOLUCIMINUTIDURATATRAMANTO, luciMinutiDurataTramonto);
}
else if (act == 6)
{
if (luciMinutiDurataTramonto <= 5) {luciMinutiDurataTramonto = 54u;}
else {luciMinutiDurataTramonto--;}
EEPROM.write(INDIRIZZOLUCIMINUTIDURATATRAMANTO, luciMinutiDurataTramonto);
}
}
dat_p = page_fotoperiodo(buf);
}
else if ((cmd == 3) || (cmd == 4))
{
if (cmd == 3)
{
if (act == 1)
{
if (luciTargetBluSx >= 255) {luciTargetBluSx = 0u;}
else {luciTargetBluSx++;}
EEPROM.write(INDIRIZZOLUCITARGETBLUSX, luciTargetBluSx);
}
else if (act == 2)
{
if (luciTargetBluSx == 0) {luciTargetBluSx = 255u;}
else {luciTargetBluSx--;}
EEPROM.write(INDIRIZZOLUCITARGETBLUSX, luciTargetBluSx);
}
else if (act == 3)
{
if (luciTargetRRGB >= 255) {luciTargetRRGB = 0u;}
else {luciTargetRRGB++;}
EEPROM.write(INDIRIZZOLUCITARGETRRGB, luciTargetRRGB);
}
else if (act == 4)
{
if (luciTargetRRGB == 0) {luciTargetRRGB = 255u;}
else {luciTargetRRGB--;}
EEPROM.write(INDIRIZZOLUCITARGETRRGB, luciTargetRRGB);
}
else if (act == 5)
{
if (luciTargetBluDx >= 255) {luciTargetBluDx = 0u;}
else {luciTargetBluDx++;}
EEPROM.write(INDIRIZZOLUCITARGETBLUDX, luciTargetBluDx);
}
else if (act == 6)
{
if (luciTargetBluDx == 0) {luciTargetBluDx = 255u;}
else {luciTargetBluDx--;}
EEPROM.write(INDIRIZZOLUCITARGETBLUDX, luciTargetBluDx);
}
else if (act == 7)
{
if (luciTarget10kSx >= 255) {luciTarget10kSx = 0u;}
else {luciTarget10kSx++;}
EEPROM.write(INDIRIZZOLUCITARGET10KSX, luciTarget10kSx);
}
else if (act == 8)
{
if (luciTarget10kSx == 0) {luciTarget10kSx = 255u;}
else {luciTarget10kSx--;}
EEPROM.write(INDIRIZZOLUCITARGET10KSX, luciTarget10kSx);
}
else if (act == 9)
{
if (luciTargetGRGB >= 255) {luciTargetGRGB = 0u;}
else {luciTargetGRGB++;}
EEPROM.write(INDIRIZZOLUCITARGETGRGB, luciTargetGRGB);
}
}
else if (cmd == 4)
{
if (act == 1)
{
if (luciTargetGRGB == 0) {luciTargetGRGB = 255u;}
else {luciTargetGRGB--;}
EEPROM.write(INDIRIZZOLUCITARGETGRGB, luciTargetGRGB);
}
else if (act == 2)
{
if (luciTarget10kDx >= 255) {luciTarget10kDx = 0u;}
else {luciTarget10kDx++;}
EEPROM.write(INDIRIZZOLUCITARGET10KDX, luciTarget10kDx);
}
else if (act == 3)
{
if (luciTarget10kDx == 0) {luciTarget10kDx = 255u;}
else {luciTarget10kDx--;}
EEPROM.write(INDIRIZZOLUCITARGET10KDX, luciTarget10kDx);
}
else if (act == 4)
{
if (luciTarget20kSx >= 255) {luciTarget20kSx = 0u;}
else {luciTarget20kSx++;}
EEPROM.write(INDIRIZZOLUCITARGET20KSX, luciTarget20kSx);
}
else if (act == 5)
{
if (luciTarget20kSx == 0) {luciTarget20kSx = 255u;}
else {luciTarget20kSx--;}
EEPROM.write(INDIRIZZOLUCITARGET20KSX, luciTarget20kSx);
}
else if (act == 6)
{
if (luciTargetBRGB >= 255) {luciTargetBRGB = 0u;}
else {luciTargetBRGB++;}
EEPROM.write(INDIRIZZOLUCITARGETBRGB, luciTargetBRGB);
}
else if (act == 7)
{
if (luciTargetBRGB == 0) {luciTargetBRGB = 255u;}
else {luciTargetBRGB--;}
EEPROM.write(INDIRIZZOLUCITARGETBRGB, luciTargetBRGB);
}
else if (act == 8)
{
if (luciTarget20kDx >= 255) {luciTarget20kDx = 0u;}
else {luciTarget20kDx++;}
EEPROM.write(INDIRIZZOLUCITARGET20KDX, luciTarget20kDx);
}
else if (act == 9)
{
if (luciTarget20kDx == 0) {luciTarget20kDx = 255u;}
else {luciTarget20kDx--;}
EEPROM.write(INDIRIZZOLUCITARGET20KDX, luciTarget20kDx);
}
}
dat_p = page_illuminazione_potenza(buf);
}
else if (cmd == 5)
{
if (luciTipoAlbaTramonto >= 4u) {luciTipoAlbaTramonto = 0u;}
if (act == 1)
{
if (luciTipoAlbaTramonto == 0u) {luciTipoAlbaTramonto = 1u;}
else if (luciTipoAlbaTramonto == 1u) {luciTipoAlbaTramonto = 0u;}
else if (luciTipoAlbaTramonto == 2u) {luciTipoAlbaTramonto = 3u;}
else if (luciTipoAlbaTramonto == 3u) {luciTipoAlbaTramonto = 2u;}
EEPROM.write(INDIRIZZOLUCITIPOALBATRAMONTO, luciTipoAlbaTramonto);
}
else if (act == 2)
{
if (luciTipoAlbaTramonto == 0u) {luciTipoAlbaTramonto = 2u;}
else if (luciTipoAlbaTramonto == 1u) {luciTipoAlbaTramonto = 3u;}
else if (luciTipoAlbaTramonto == 2u) {luciTipoAlbaTramonto = 0u;}
else if (luciTipoAlbaTramonto == 3u) {luciTipoAlbaTramonto = 1u;}
EEPROM.write(INDIRIZZOLUCITIPOALBATRAMONTO, luciTipoAlbaTramonto);
}
else if (act == 3)
{
if (luciTargetRRGBLunare >= 255) {luciTargetRRGBLunare = 0u;}
else {luciTargetRRGBLunare++;}
EEPROM.write(INDIRIZZOLUCITARGETRRGBLUNARE, luciTargetRRGBLunare);
}
else if (act == 4)
{
if (luciTargetRRGBLunare == 0) {luciTargetRRGBLunare = 255u;}
else {luciTargetRRGBLunare--;}
EEPROM.write(INDIRIZZOLUCITARGETRRGBLUNARE, luciTargetRRGBLunare);
}
else if (act == 5)
{
if (luciTargetGRGBLunare >= 255) {luciTargetGRGBLunare = 0u;}
else {luciTargetGRGBLunare++;}
EEPROM.write(INDIRIZZOLUCITARGETGRGBLUNARE, luciTargetGRGBLunare);
}
else if (act == 6)
{
if (luciTargetGRGBLunare == 0) {luciTargetGRGBLunare = 255u;}
else {luciTargetGRGBLunare--;}
EEPROM.write(INDIRIZZOLUCITARGETGRGBLUNARE, luciTargetGRGBLunare);
}
else if (act == 7)
{
if (luciTargetBRGBLunare >= 255) {luciTargetBRGBLunare = 0u;}
else {luciTargetBRGBLunare++;}
EEPROM.write(INDIRIZZOLUCITARGETBRGBLUNARE, luciTargetBRGBLunare);
}
else if (act == 8)
{
if (luciTargetBRGBLunare == 0) {luciTargetBRGBLunare = 255u;}
else {luciTargetBRGBLunare--;}
EEPROM.write(INDIRIZZOLUCITARGETBRGBLUNARE, luciTargetBRGBLunare);
}
dat_p = page_illuminazione_effetti(buf);
}
else
{
dat_p = page_illuminazione(buf);
}
goto SENDTCP;
}
//***********************************************************************************************************************
//***********************************************************************************************************************
//***********************************************************************************************************************
//***********************************************************************************************************************
//***********************************************************************************************************************
if (sez == 8)
{
if (act == 1) {rtcHour++;}
if (rtcHour >= 24) {rtcHour = 0u;}
if (act == 2)
{
if (rtcHour == 0) {rtcHour = 23u;}
else {rtcHour--;}
}
if (act == 3) {rtcMinute++;}
if (rtcMinute >= 60) {rtcMinute = 0u;}
if (act == 4)
{
if (rtcMinute == 0) {rtcMinute = 59u;}
else {rtcMinute--;}
}
if (act == 5) {rtcMonthDay++;}
if (rtcMonthDay >= 32) {rtcMonthDay = 1u;}
if (act == 6)
{
if (rtcMonthDay <= 1) {rtcMonthDay = 31u;}
else {rtcMonthDay--;}
}
if (act == 7) {rtcMonth++;}
if (rtcMonth >= 13) {rtcMonth = 1u;}
if (act == 8) {rtcYear++;}
if (rtcYear >= 100) {rtcYear = 11u;}
if (act == 9) {rtcYear--;}
if (rtcYear <= 10) {rtcYear = 99u;}
if (act == 0) {rtcWeekDay++;}
if (rtcWeekDay >= 8) {rtcWeekDay = 1u;}
rtc_setDateTime();
dat_p = page_orologio(buf);
goto SENDTCP;
}
//***********************************************************************************************************************
//***********************************************************************************************************************
//***********************************************************************************************************************
//***********************************************************************************************************************
//***********************************************************************************************************************
if (sez == 9)
{
if ((act == 1) && (sdError == 0)) {sdLogInCorso = 1;}
if (act == 2) {sdLogInCorso = 0;}
if (act == 3)
{
inizializza_sd();
sdError = 0;
}
if (act == 4) {formattazione_sd();}
dat_p = page_logger(buf);
goto SENDTCP;
}
//***********************************************************************************************************************
//***********************************************************************************************************************
//***********************************************************************************************************************
//***********************************************************************************************************************
//***********************************************************************************************************************
SENDTCP:
es.ES_www_server_reply(buf,dat_p); // send web page data
// tcp port 80 end
}
}
void inizializza_enc28j60()
{
// Configuro l'uscita per il CS del chip
pinMode(ENC28J60_CONTROL_CS, OUTPUT);
// initialize enc28j60
es.ES_enc28j60Init(mymac);
// init the ethernet/ip layer:
es.ES_init_ip_arp_udp_tcp(mymac,myip, MYWWWPORT);
msResetWeb = 0;
}
Tramite internet si regola l'orologio, l'ora di accensione della lampada, la durata dell'alba, la durata del tramonto, il tipo di dimmerazione (blu e bianchi assieme oppure prima blu poi bianchi e sinistra e destra assieme o prima sinistra poi destra), la potenza massima di ogni uscita, il colore del led rgb di notte o di giorno ed altro.
|