Часы реального времени ds1307 и ENC28j60
- Войдите на сайт для отправки комментариев
Чт, 14/04/2016 - 01:03
Здравствуйте. Помогите пожалуйста вывести время и дату в раскрывающий список(когда значение фоторезистора больше 40), чтобы туда добавлялись 3 различные время и даты и потом перезаписывались?
#define MAXMILLIS 4294967295
#include <EtherCard.h>
#include "CyberLib.h"
#include <RTC.h>
RTC time;
static byte mymac[] = { 0xF0,0x7E,0x68,0x03,0x2A,0x7D };
static byte myip[] = { 192,168,0,191 };
byte Ethernet::buffer[650];
BufferFiller bfill;
String valT2;
const char http_OK[] PROGMEM =
"HTTP/1.0 200 OK\r\n"
"Content-Type: text/html\r\n"
"Pragma: no-cache\r\n\r\n";
const char http_Found[] PROGMEM =
"HTTP/1.0 302 Found\r\n"
"Location: /\r\n\r\n";
const char http_Unauthorized[] PROGMEM =
"HTTP/1.0 401 Unauthorized\r\n"
"Content-Type: text/html\r\n\r\n"
"<h1>401 Unauthorized</h1>";
void homePage()
{
bfill.emit_p(PSTR("$F" "<title>Home</title>" ), http_OK);
bfill.emit_p(PSTR("<meta http-equiv='refresh' content='5'/>" "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>"));
bfill.emit_p(PSTR("<form action=http://ab-w.net/info.php method=post name=drop_down_box>"));
bfill.emit_p(PSTR("<select name=menu size=1>"));
bfill.emit_p(PSTR("<option value=first>$D</option>"),time.gettime("d-m-Y, H:i:s, D"));
bfill.emit_p(PSTR("</select> <br />"));
}
void setup()
{
Serial.begin(9600);
if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 0);
if (!ether.dhcpSetup());
ether.staticSetup(myip);
ether.hisport = 8080;
time.begin(RTC_DS1307);
}
void loop()
{
int sensor0 = A0_Read;
if (sensor0 >= 40){ //фоторезистор
time.gettime("d-m-Y, H:i:s, D");
}
if(millis()%1000==0){ // если прошла 1 секунда
time.gettime("d-m-Y, H:i:s, D"); // выводим время
delay(1);
}
word len = ether.packetReceive(); // check for ethernet packet / проверить ethernet пакеты.
word pos = ether.packetLoop(len); // check for tcp packet / проверить TCP пакеты.
if (pos) {
bfill = ether.tcpOffset();
char *data = (char *) Ethernet::buffer + pos;
if (strncmp("GET /", data, 5) != 0) {
bfill.emit_p(http_Unauthorized);
}
else {
data += 5;
if (data[0] == ' ') {
homePage(); }
else {
}
}
ether.httpServerReply(bfill.position()); // send http response
}
}