ETH_SD_JPG

Dependencies:   DS1820 SDFileSystem SLCD WIZnet_Library mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.h Source File

main.h

00001 #include "mbed.h"
00002 #include "WIZnetInterface.h"
00003 #define ECHO_SERVER_PORT   80
00004 
00005 
00006 //******************
00007 #define MULTIPLE_PROBES
00008 #define DATA_PIN        PTC10 //1wire
00009 
00010 
00011 
00012 #include "SerialBase.h"
00013 #include "mbed.h"
00014 #include "DS1820.h"
00015 #include "SLCD.h"
00016 #include "Serial.h"
00017 #define MAX_PROBES     64
00018 #define BAUD (115200)
00019 #include "SDFileSystem.h"
00020 
00021 char zp;
00022 char zpp[1001];
00023 int tt;
00024 //int ustaw;
00025 char data[8];
00026 char data_all[600];  //="komarowski";
00027 int data_rozmiar=599;
00028 int data_rozmiar2=599;
00029 int lenght;
00030 char zzpp[1001];
00031 
00032 
00033 DigitalOut myled(LED1);//PTD5
00034 DigitalOut myled2(LED2); //PTE29
00035 DigitalOut SD_SEL(PTA12);
00036 
00037 DigitalIn  sw1(PTC3);  //if(sw1) Release else Press
00038 DigitalIn  sw3(PTC12); //while(sw3); wait for Press
00039 //DigitalIn  sw4(PTD5);//dioda czerwona
00040 //DigitalIn  sw5(PTE29);//dioda czerwona
00041 
00042 SLCD slcd;
00043 DS1820* probe[MAX_PROBES];
00044 
00045 
00046 SPI spi(PTD6, PTD7, PTD5); // mosi, miso, sclk
00047 WIZnetInterface eth(&spi, PTD4, PTA20); // spi, cs, reset
00048 SDFileSystem sd(PTD6, PTD7, PTD5, PTA4, "sd"); // MOSI, MISO, SCLK, SSEL
00049 
00050 Serial pc(PTA2,PTA1);
00051 DigitalOut led(PTB0);
00052 
00053 char a[]={"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nPragma: no-cache\r\n\r\n"};
00054 char aa[]={"HTTP/1.0 200 OK\r\nContent-Type: image/jpeg\r\nPragma: no-cache\r\n"};
00055 //char aa[]={"HTTP/1.0 200 OK\r\nContent-Type: image/jpg\r\nPragma: no-cache\r\n\r\n"};
00056 char b[]={"<html>\r\n<body>\r\n"};
00057 char bb[]={"<html>\r\n<body>\r\n"};
00058 //char ab[]={"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nPragma: no-cache\r\n\r\n"};
00059 //char b[]={"<meta http-equiv=refresh content=1>"};
00060 //char b[]={"<html>\r\n<body>\r\n"};
00061 char c[]={"<body bgcolor=\"green\">"};
00062 char c1[]={"<body bgcolor=\"000ff0\"></body>\r\n"};
00063 char d[]={"<H2>Test W5100 i DS18b20</H2>"};
00064 char e[]={"<form action=\"http://10.192.144.204/d\"><input type=\"submit\" value=\"Wylacz LED2\" /></form>"};
00065 char f[]={""};
00066 char g[]={"<form action=\"http://10.192.144.204/c\"><input type=\"submit\" value=\"Wlacz LED 2\" /></form>"};
00067 char h[]={"<H1>__________</H1>"};
00068 char i[]={"<form action=\"http://10.192.144.204/bb\"><input type=\"submit\" value=\"Wylacz LED1\" /></form>"};
00069 char j[]={"_"};
00070 char k[]={"<form action=\"http://10.192.144.204/aa\"><input type=\"submit\" value=\"Wlacz LED1\" /></form>"};
00071 char l[]={"<form action=http://10.192.144.204 method=post onsubmit><input type=text name=tekst /><input type=submit value=OK /></form>"};
00072 char m[]={"Temp"};
00073 //if (this.tekst2.value == '') { alert('Zanim wyślesz formularz, musisz wypełnić pole tekstem!'); return false }><input type=text name=tekst /><input type=submit value=OK /></form>"};
00074 //char g[]={"<FONT FACE=\"Arial\" SIZE=\"8\" COLOR=\"FF0000\">"};
00075 //char w[]={"<meta http-equiv=\"refresh\" content=\"10; url=/\">\r\n"};
00076 //char g[]={"<center><h2>Tutaj jestes -01 :)</h2>\r\n"};
00077 //char h[]={"<center><div STYLE=\"position:absolute;bgcolor:black; top:100px; left:200px;width:54px\">"};
00078 //char i[]={"<center><h2>Tutaj jestes :)</h2>\r\n"};
00079 //char s[]={"Content-Type: text/html\r\n"};
00080 char t[]={"Connection: close\r\n\r\n"};
00081 //char u[]={"Refresh content=5\r\n\r\n"};
00082 //char u[]={"<meta http-equiv=refresh content=1>"};
00083 //char v[]={"<!DOCTYOE HTML>\r\n"};
00084 //char y[]={"<html>\r\n"};
00085 
00086 
00087 char paq_en[128];
00088 
00089 
00090 void temperatura_f()
00091 {
00092     
00093     int num_devices = 0;    
00094     while(DS1820::unassignedProbe(DATA_PIN))
00095      {
00096         probe[num_devices] = new DS1820(DATA_PIN);
00097         num_devices++;
00098         if (num_devices == MAX_PROBES)
00099             break;
00100       }
00101 }
00102 
00103 
00104 
00105 void odczyt_z_SD(TCPSocketConnection client, int ustaw)
00106 {                 
00107         FILE *zw;  
00108         if(strstr(data_all, "zmiana")!=0)
00109             zw = fopen("/sd/index_old.htm","r"); 
00110         else
00111             zw = fopen("/sd/index.htm","r");    
00112         
00113             if(zw==NULL)
00114             {
00115                 printf("plik jest pusty, lub nie istnieje");
00116             }
00117                 zp=0;
00118                 tt=0;
00119                 
00120                 while(1) // aż napotka pusty znak 
00121                 {                   
00122                     zp=fgetc(zw); // czytanie z pliku
00123                     if(feof(zw))//wychodzi z pętli gdy napotka nie zapisaną komórkę
00124                     break;
00125                     
00126                     zpp[tt]=zp;
00127                     tt++;
00128                     if (tt==1000)
00129                     {
00130                         if (ustaw==1)
00131                             {
00132                             client.send(zpp,1001);
00133                             //zpp[1000]=0;
00134                            // printf("\r\n Wyslal \r\n %s",zpp); 
00135                             }
00136                         else if (ustaw==2)
00137                             {
00138                             printf("\r\n Wyslal \r\n %s",zpp);                 
00139                             }                        
00140                                         
00141                     zpp[0]=0;//zerowanie tablicy
00142                     tt=0;
00143                     }             
00144                 }
00145                 
00146               // tt=0;
00147               zpp[tt]=0;
00148                if (ustaw==1)
00149                {
00150                     client.send(zpp,tt);
00151                    // printf("\n Doslal \r\n %s",zpp);   
00152                 }
00153                 else if (ustaw==2)
00154                 {
00155                     
00156                     
00157                     printf("\n Doslal \r\n %s",zpp); 
00158                 }
00159               
00160                zpp[0]=0;//zerowanie tablicy                
00161                
00162                fclose(zw);
00163                      
00164 }
00165 
00166 void diody()
00167 {
00168     
00169     //zmiena dla funkcji POST
00170             printf("%s ",a);
00171             if (strstr(data_all,"komarowski") !=0) 
00172             {
00173                 myled2=0;
00174             }
00175             else if (strstr(data_all,"wotlinski") !=0) 
00176              {
00177                 myled2=1;
00178             }                
00179             else if (strstr(data_all,"obojski") !=0) 
00180              {
00181                 myled2=!myled2;
00182             }
00183                 
00184      //zmienne dla funkcji GET       
00185             
00186             if (data_all[6]=='a')
00187             {
00188                 myled=0;
00189                 pc.printf("\r\n Myled=0");
00190             }
00191             else if (data_all[6]=='b')
00192             {
00193                 myled=1;
00194                 pc.printf("\r\n Myled=1");
00195             }
00196             
00197             if (data_all[5]=='c')
00198             {
00199                 myled2=0;
00200                 pc.printf("\r\n Myled2=0");
00201             }
00202             else if (data_all[5]=='d')
00203             {
00204                 myled2=1;
00205                 pc.printf("\r\n Myled2=1");
00206             }
00207            
00208             
00209 }
00210 
00211 
00212 
00213 //*******załącza i wyłącza diody