View difference between Paste ID: n519FcQw and yqUs2ZGZ
SHOW: | | - or go back to the newest paste.
1-
1+
2
#include <Ethernet.h>
3
#include <UTFT.h>
4
extern uint8_t SmallFont[];
5
byte mac[] = {
6
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
7
};
8
IPAddress ip(10, 80, 45, 254);
9
EthernetServer server(80);
10
UTFT myGLCD(ITDB28,A5,A4,A3,A2);
11
void setup()
12
{
13
   randomSeed(analogRead(0));
14
  myGLCD.InitLCD();
15
  myGLCD.setFont(SmallFont);
16
  //Added bit of code for ethernet support
17
  Ethernet.begin(mac, ip);
18
  server.begin();
19
  myGLCD.clrScr();
20
  myGLCD.setColor(255, 0, 0);
21
  myGLCD.fillRect(0, 0, 319, 13);
22
  myGLCD.setColor(64, 64, 64);
23
  myGLCD.fillRect(0, 226, 319, 239);
24
  myGLCD.setColor(255, 255, 255);
25
  myGLCD.setBackColor(255, 0, 0);
26
  myGLCD.print("* UTFT TEST WORKING *", CENTER, 1);
27
  
28
}
29
void loop()
30
{
31
  int buf[318];
32
  int x, x2;
33
  int y, y2;
34
  int r;
35
  
36
  
37
  
38
  EthernetClient client = server.available();
39
  if (client) {
40
    
41
    myGLCD.setBackColor(0, 0, 0);
42
    myGLCD.setColor(255, 255, 255);
43
    myGLCD.print("new client", CENTER, 16);
44
    delay(10);
45
    boolean currentLineIsBlank = true;
46
    while (client.connected()) {
47
      if (client.available()) {
48
        char c = client.read();
49
        if (c == '\n' && currentLineIsBlank) {
50
          // send a standard http response header
51
          client.println("HTTP/1.1 200 OK");
52
          client.println("Content-Type: text/html");
53
          client.println("Connection: close");  // the connection will be closed after completion of the response
54
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
55
          client.println();
56
          client.println("<!DOCTYPE HTML>");
57
          client.println("<html>");
58
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
59
            int sensorReading = analogRead(analogChannel);
60
            client.print("analog input ");
61
            client.print(analogChannel);
62
            client.print(" is ");
63
            client.print(sensorReading);
64
            client.println("<br />");
65
          }
66
          client.println("</html>");
67
          break;
68
        }
69
        if (c == '\n') {
70
          currentLineIsBlank = true;
71
        } else if (c != '\r') {
72
          currentLineIsBlank = false;
73
        }
74
      }
75
    }
76
    delay(1);
77
    client.stop();
78
    myGLCD.print("client disconnected", CENTER, 16);
79
    delay(10);
80
    myGLCD.setColor(0, 0, 0);
81
    myGLCD.fillRect(0, 16, 319, 32);
82
    Ethernet.maintain();
83
    
84
  }
85
}