Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <Ethernet.h>
- #include <UTFT.h>
- extern uint8_t SmallFont[];
- byte mac[] = {
- 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
- };
- IPAddress ip(10, 80, 45, 254);
- EthernetServer server(80);
- UTFT myGLCD(ITDB28,A5,A4,A3,A2);
- void setup()
- {
- randomSeed(analogRead(0));
- myGLCD.InitLCD();
- myGLCD.setFont(SmallFont);
- //Added bit of code for ethernet support
- Ethernet.begin(mac, ip);
- server.begin();
- myGLCD.clrScr();
- myGLCD.setColor(255, 0, 0);
- myGLCD.fillRect(0, 0, 319, 13);
- myGLCD.setColor(64, 64, 64);
- myGLCD.fillRect(0, 226, 319, 239);
- myGLCD.setColor(255, 255, 255);
- myGLCD.setBackColor(255, 0, 0);
- myGLCD.print("* UTFT TEST WORKING *", CENTER, 1);
- }
- void loop()
- {
- int buf[318];
- int x, x2;
- int y, y2;
- int r;
- EthernetClient client = server.available();
- if (client) {
- myGLCD.setBackColor(0, 0, 0);
- myGLCD.setColor(255, 255, 255);
- myGLCD.print("new client", CENTER, 16);
- delay(10);
- boolean currentLineIsBlank = true;
- while (client.connected()) {
- if (client.available()) {
- char c = client.read();
- if (c == '\n' && currentLineIsBlank) {
- // send a standard http response header
- client.println("HTTP/1.1 200 OK");
- client.println("Content-Type: text/html");
- client.println("Connection: close"); // the connection will be closed after completion of the response
- client.println("Refresh: 5"); // refresh the page automatically every 5 sec
- client.println();
- client.println("<!DOCTYPE HTML>");
- client.println("<html>");
- for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
- int sensorReading = analogRead(analogChannel);
- client.print("analog input ");
- client.print(analogChannel);
- client.print(" is ");
- client.print(sensorReading);
- client.println("<br />");
- }
- client.println("</html>");
- break;
- }
- if (c == '\n') {
- currentLineIsBlank = true;
- } else if (c != '\r') {
- currentLineIsBlank = false;
- }
- }
- }
- delay(1);
- client.stop();
- myGLCD.print("client disconnected", CENTER, 16);
- delay(10);
- myGLCD.setColor(0, 0, 0);
- myGLCD.fillRect(0, 16, 319, 32);
- Ethernet.maintain();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement