lpc824lite 采集温湿度压强数据显示至oled12864,通w5500与用户进行TCP交互
Dependencies: mbed WIZnet_Library AM2320 BME280
Revision 0:ef802f772981, committed 2017-05-11
- Comitter:
- dadangjia
- Date:
- Thu May 11 16:51:19 2017 +0000
- Commit message:
- lpc824,w5500,am2320,bep280,ssd1306
Changed in this revision
diff -r 000000000000 -r ef802f772981 AM2320.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AM2320.lib Thu May 11 16:51:19 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/yasuyuki/code/AM2320/#766868b34d56
diff -r 000000000000 -r ef802f772981 BME280.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BME280.lib Thu May 11 16:51:19 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/MACRUM/code/BME280/#ddcaa259e65b
diff -r 000000000000 -r ef802f772981 OLED/CriusOLED.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OLED/CriusOLED.h Thu May 11 16:51:19 2017 +0000 @@ -0,0 +1,272 @@ +/* ============================================ +Modified Code from Crius +The CriusOLED Hardware MUST be modified for correct function of ACK +Copyright (c) 2014 Michael Ruck michael@ruck.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +=============================================== +*/ +#include "./data.h" +#define OLED_ADDR (0x78) + +I2C i2c(I2C_SDA, I2C_SCL); + +void displayOn(void); +void displayOff(void); +void SendByte(unsigned char data); +void sendcommand(unsigned char com); +void SendByte(unsigned char com); +void printBigNumber(unsigned char s, int X, int Y); +void SendByteXY(unsigned char data, int X, int Y); + + +//==========================================================// +// Turns display on. +void displayOn(void) +{ + sendcommand(0xaf); //display on +} + +//==========================================================// +// Turns display off. +void displayOff(void) +{ + sendcommand(0xae); //display off +} +//==========================================================// +// Actually this sends a byte, not a char to draw in the display. +// Display's chars uses 8 byte font the small ones and 96 bytes +// for the big number font. +void SendByte(unsigned char data) +{ + //Create a temporary buffer + char buff[2]; + + //Load the control byte and 8-bit data + buff[0] = (0x40); + buff[1] = data; + + //Write the data + i2c.write(OLED_ADDR, buff, 2); + +} + +//==========================================================// +// Used to send commands to the display. +void sendcommand(unsigned char com) +{ + //Create a temporary buffer + char buff[2]; + + //Load the control byte and 8-bit command + buff[0] = 0x00; + buff[1] = com; + + //Write the command + i2c.write(OLED_ADDR, buff, 2); +} +//==========================================================// +// Set the cursor position in a 16 COL * 8 ROW map. +void setXY(unsigned char row,unsigned char col) +{ + sendcommand(0xb0+row); //set page address + sendcommand(0x00+(8*col&0x0f)); //set low col address + sendcommand(0x10+((8*col>>4)&0x0f)); //set high col address +} +//==========================================================// +// Clears the display by sendind 0 to all the screen map. +void clear_display(void) +{ + unsigned char i,k; + for(k=0; k<8; k++) { + setXY(k,0); + { + for(i=0; i<128; i++) { //clear all COL + SendByte(0); //clear all COL + //delay(10); + } + } + } +} +//==========================================================// +// Resets display depending on the actual mode. +void reset_display(void) +{ + displayOff(); + clear_display(); + + + displayOn(); +} +//==========================================================// + +void sendImage() +{ + reset_display(); + for(int i=0; i<128*8; i++) // show 128* 64 Logo + SendByte(logo[i]); + +} +//==========================================================// +void printBigTime(char *s) +{ + + int Y=0; + int lon = strlen(s); + if(lon == 3) { + Y = 0; + } else if (lon == 2) { + Y = 3; + } else if (lon == 1) { + Y = 6; + } + + int X = 2; + while(*s) { + printBigNumber(*s, X, Y); + + Y+=3; + X=2; + setXY(X,Y); + *s++; + } +} + + +//==========================================================// +// Prints a display big number (96 bytes) in coordinates X Y, +// being multiples of 8. This means we have 16 COLS (0-15) +// and 8 ROWS (0-7). +void printBigNumber(unsigned char s, int X, int Y) +{ + setXY(X,Y); + int salto=0; + for(int i=0; i<96; i++) { + if(s == ' ') { + SendByte(0); + } else + SendByte(bigNumbers[s-0x30][i]); + + if(salto == 23) { + salto = 0; + X++; + setXY(X,Y); + } else { + salto++; + } + } +} +//==========================================================// +// Prints a display char (not just a byte) in coordinates X Y, +// being multiples of 8. This means we have 16 COLS (0-15) +// and 8 ROWS (0-7). +void SendByteXY(unsigned char data, int X, int Y) +{ + i2c.start(); + i2c.write(OLED_ADDR); + i2c.write(0x40); + + for(int i=0; i<8; i++) + i2c.write((int)(myFont[data-0x20]+i)); // <<------------------------------------- + + i2c.stop(); // stop transmitting +} +//==========================================================// +// Prints a string regardless the cursor position. +void sendStr(unsigned char *s) +{ + unsigned char i=0; + while(*s) { + for(i=0; i<8; i++) { + SendByte(myFont[*s-0x20][i]); + } + *s++; + } +} +//==========================================================// +// Prints a string in coordinates X Y, being multiples of 8. +// This means we have 16 COLS (0-15) and 8 ROWS (0-7). +void sendStrXY( char *s, int X, int Y) +{ + setXY(X,Y); + unsigned char i=0; + while(*s) { + for(i=0; i<8; i++) { + SendByte(myFont[*s-0x20][i]); + } + *s++; + } +} + + +//==========================================================// +// Inits oled and draws logo at startup +void init_OLED(void) +{ + sendcommand(0xae); //display off + sendcommand(0xa6); //Set Normal Display (default) + // Adafruit Init sequence for 128x64 OLED module + sendcommand(0xAE); //DISPLAYOFF + sendcommand(0xD5); //SETDISPLAYCLOCKDIV + sendcommand(0x80); // the suggested ratio 0x80 + sendcommand(0xA8); //SSD1306_SETMULTIPLEX + sendcommand(0x3F); + sendcommand(0xD3); //SETDISPLAYOFFSET + sendcommand(0x0); //no offset + sendcommand(0x40 | 0x0); //SETSTARTLINE + sendcommand(0x8D); //CHARGEPUMP + sendcommand(0x14); + sendcommand(0x20); //MEMORYMODE + sendcommand(0x00); //0x0 act like ks0108 + + sendcommand(0xA0 | 0x1); //SEGREMAP //Rotate screen 180 deg + //sendcommand(0xA0); + + sendcommand(0xC8); //COMSCANDEC Rotate screen 180 Deg + //sendcommand(0xC0); + + sendcommand(0xDA); //0xDA + sendcommand(0x12); //COMSCANDEC + sendcommand(0x81); //SETCONTRAS + sendcommand(0xCF); // + sendcommand(0xd9); //SETPRECHARGE + sendcommand(0xF1); + sendcommand(0xDB); //SETVCOMDETECT + sendcommand(0x40); + sendcommand(0xA4); //DISPLAYALLON_RESUME + sendcommand(0xA6); //NORMALDISPLAY + + clear_display(); + sendcommand(0x2e); // stop scroll + //----------------------------REVERSE comments----------------------------// + // sendcommand(0xa0); //seg re-map 0->127(default) + // sendcommand(0xa1); //seg re-map 127->0 + // sendcommand(0xc8); + // delay(1000); + //----------------------------REVERSE comments----------------------------// + // sendcommand(0xa7); //Set Inverse Display + // sendcommand(0xae); //display off + sendcommand(0x20); //Set Memory Addressing Mode + sendcommand(0x00); //Set Memory Addressing Mode ab Horizontal addressing mode + // sendcommand(0x02); // Set Memory Addressing Mode ab Page addressing mode(RESET) + + setXY(0,0); + + sendcommand(0xaf); //display on +}
diff -r 000000000000 -r ef802f772981 OLED/data.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OLED/data.h Thu May 11 16:51:19 2017 +0000 @@ -0,0 +1,283 @@ +/* + * This file contains all the static arrays to draw things in the display. + */ + + +// GPS Logo +char logo [] = { +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, +0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF8, 0x3C, 0x1C, 0x0E, 0x07, +0x07, 0x83, 0x83, 0x83, 0xC3, 0xC7, 0xEF, 0xFE, 0x7C, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x80, 0x80, 0x00, +0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0x78, 0x1C, 0x1E, 0x0E, 0x07, 0x07, 0x1F, 0xFB, 0xAB, 0x83, +0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x07, 0x0F, 0x3F, 0xFF, 0xFC, 0x8E, 0x0E, 0x06, 0x07, +0x07, 0x03, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x7E, 0xFF, 0xE7, 0xE1, 0xE1, 0xE0, 0xE0, 0x60, 0x60, 0x70, 0x71, 0x71, 0x71, 0x33, 0x37, +0x3F, 0x7E, 0xFF, 0xEF, 0x83, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xE0, 0xC0, 0x80, 0x03, 0x0E, +0x70, 0xC0, 0x00, 0x78, 0xFC, 0xCE, 0xC6, 0xC6, 0xFE, 0xFC, 0x31, 0x07, 0x3F, 0xFE, 0xF0, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x01, 0x0F, 0x7F, 0xFC, 0xE3, 0x8F, 0x1F, 0x18, 0x18, 0x1C, 0x0F, 0x0F, 0x00, 0x80, +0x80, 0x41, 0x6E, 0x38, 0x20, 0x11, 0x11, 0x11, 0x70, 0x10, 0x70, 0x10, 0xF0, 0xFF, 0xFF, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0xF0, 0xF0, 0x10, 0x10, 0x00, 0x00, 0xD8, 0xD8, 0x00, +0x00, 0xC0, 0xC0, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x80, 0xC0, 0x40, 0x40, 0xF8, 0xF8, 0x00, +0x00, 0xD8, 0xD8, 0x00, 0x00, 0x80, 0xC0, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x80, 0xC0, 0x40, 0x40, 0x80, 0x00, 0x80, 0xC0, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0xC0, +0xC0, 0x40, 0x40, 0xC0, 0x80, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xFE, 0xE7, 0xC7, 0xE7, 0x7E, 0x7C, 0x00, 0x00, +0x00, 0x00, 0x80, 0xE0, 0xF8, 0x7D, 0x1F, 0x87, 0xCF, 0xFE, 0xFC, 0xFC, 0xF4, 0xE2, 0xC1, 0x81, +0x00, 0x10, 0x18, 0x18, 0x1C, 0x1C, 0x9E, 0x8E, 0xC7, 0xC0, 0xE0, 0xF0, 0x7F, 0x3F, 0x1F, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x00, +0x00, 0x1F, 0x1F, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x1F, 0x1F, 0x00, +0x00, 0x1F, 0x1F, 0x00, 0x00, 0x0F, 0x1F, 0x12, 0x12, 0x13, 0x0B, 0x00, 0x00, 0x18, 0x18, 0x00, +0x00, 0x0F, 0x1F, 0x10, 0x10, 0x08, 0x00, 0x0F, 0x1F, 0x10, 0x10, 0x1F, 0x0F, 0x00, 0x00, 0x1F, +0x1F, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x06, 0x0E, 0x0E, 0xFE, 0xFF, 0x0F, 0x7F, 0xFF, 0xF7, 0x87, 0x06, 0x00, +0xE0, 0xFE, 0xFF, 0x0F, 0x01, 0x00, 0x0F, 0x3F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0x3F, 0x1E, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x01, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE7, 0x7F, 0x7E, 0x78, 0x31, 0x33, 0x3F, 0x3E, 0x7E, +0xFF, 0xEF, 0xC0, 0xE0, 0x60, 0x60, 0x70, 0x60, 0x60, 0xE0, 0xE0, 0xC0, 0x90, 0xE5, 0xFF, 0xC3, +0xE0, 0xE0, 0x60, 0x60, 0x70, 0x60, 0x60, 0xE0, 0xC0, 0xFF, 0xFF, 0x3F, 0x30, 0x30, 0x70, 0x70, +0xE0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x7E, 0x7F, 0x67, 0x61, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, +0x7F, 0x7F, 0x61, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x61, 0x7F, 0x7F, 0x7F, 0x61, +0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x61, 0x7F, 0x7F, 0x78, 0x60, 0x60, 0x60, 0x60, +0x60, 0x61, 0x67, 0x7F, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + + +// Big numbers font, from 0 to 9. 96 byte each. +char bigNumbers [][96] = { +{0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, +0xF0, 0xF0, 0xF0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x0F, 0x0F, 0x0F, +0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00}, + +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF0, +0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, +0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + +{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, +0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0xC1, 0xC0, 0xC0, 0xC0, +0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x87, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, +0x03, 0x03, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, +0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00}, + +{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, +0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0xC1, 0xC0, 0xC0, 0xC0, +0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE1, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x81, 0x83, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x87, +0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, +0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00}, + +{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, +0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, +0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, +0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00}, + +{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, +0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1, +0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC1, 0x81, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x81, 0x83, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x87, +0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, +0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00}, + +{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, +0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1, +0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC1, 0x81, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x87, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x87, +0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, +0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00}, + +{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, +0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00}, + +{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, +0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xE1, +0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE1, 0xFF, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x87, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x87, +0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, +0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00}, + +{0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, +0xF0, 0xF0, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1, +0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, +0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0F, 0x0F, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00}, + +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x3C, 0x7E, 0x7E, 0x7E, 0x7E, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} +}; + +// Big numbers minus simbol. +char minus [] = { +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x0C, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, +0x1E, 0x1E, 0x1E, 0x1E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +// Km/h in big font. This avoids to create an entirely new big font and saves flash space. +char kmh [] = { +0x00, 0x00, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x00, 0x80, +0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xF0, 0xF8, 0xFC, +0x9E, 0x0E, 0x06, 0xE0, 0xF0, 0xF0, 0xF0, 0x70, 0xF0, 0xE0, 0xF0, 0xF0, 0x70, 0xF0, 0xE0, 0xC0, +0x00, 0x00, 0xE0, 0xFE, 0x1F, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0x18, 0x18, 0xF8, 0xF0, 0xF0, 0x00, +0x00, 0x00, 0x07, 0x07, 0x07, 0x00, 0x01, 0x03, 0x07, 0x07, 0x06, 0x07, 0x07, 0x07, 0x00, 0x00, +0x07, 0x07, 0x07, 0x00, 0x00, 0x07, 0x07, 0x07, 0x00, 0x1E, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x07, +0x07, 0x07, 0x00, 0x00, 0x07, 0x07, 0x07, 0x00 +}; + +// degrees, outside the ascii table myFont +const char myDregree [8] = { +0x00,0x00,0x0C,0x12,0x12,0x0C,0x00,0x00 +}; + + +// Small 8x8 font +char myFont[][8] = { +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, +{0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00}, +{0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00}, +{0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00}, +{0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00}, +{0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00}, +{0x00,0x36,0x49,0x55,0x22,0x50,0x00,0x00}, +{0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00}, +{0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00}, +{0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00}, +{0x00,0x08,0x2A,0x1C,0x2A,0x08,0x00,0x00}, +{0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00}, +{0x00,0xA0,0x60,0x00,0x00,0x00,0x00,0x00}, +{0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00}, +{0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00}, +{0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00}, +{0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00}, +{0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00}, +{0x00,0x62,0x51,0x49,0x49,0x46,0x00,0x00}, +{0x00,0x22,0x41,0x49,0x49,0x36,0x00,0x00}, +{0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00}, +{0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00}, +{0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00}, +{0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00}, +{0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00}, +{0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00}, +{0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00}, +{0x00,0x00,0xAC,0x6C,0x00,0x00,0x00,0x00}, +{0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00}, +{0x00,0x14,0x14,0x14,0x14,0x14,0x00,0x00}, +{0x00,0x41,0x22,0x14,0x08,0x00,0x00,0x00}, +{0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00}, +{0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00}, +{0x00,0x7E,0x09,0x09,0x09,0x7E,0x00,0x00}, +{0x00,0x7F,0x49,0x49,0x49,0x36,0x00,0x00}, +{0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00}, +{0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00}, +{0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00}, +{0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00}, +{0x00,0x3E,0x41,0x41,0x51,0x72,0x00,0x00}, +{0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00}, +{0x00,0x41,0x7F,0x41,0x00,0x00,0x00,0x00}, +{0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00}, +{0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00}, +{0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00}, +{0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00}, +{0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00}, +{0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00}, +{0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00}, +{0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00}, +{0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00}, +{0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00}, +{0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00}, +{0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00}, +{0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00}, +{0x00,0x3F,0x40,0x38,0x40,0x3F,0x00,0x00}, +{0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00}, +{0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00}, +{0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00}, +{0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00}, +{0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00}, +{0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00}, +{0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00}, +{0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00}, +{0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00}, +{0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00}, +{0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00}, +{0x00,0x38,0x44,0x44,0x28,0x00,0x00,0x00}, +{0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00}, +{0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00}, +{0x00,0x08,0x7E,0x09,0x02,0x00,0x00,0x00}, +{0x00,0x18,0xA4,0xA4,0xA4,0x7C,0x00,0x00}, +{0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00}, +{0x00,0x00,0x7D,0x00,0x00,0x00,0x00,0x00}, +{0x00,0x80,0x84,0x7D,0x00,0x00,0x00,0x00}, +{0x00,0x7F,0x10,0x28,0x44,0x00,0x00,0x00}, +{0x00,0x41,0x7F,0x40,0x00,0x00,0x00,0x00}, +{0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00}, +{0x00,0x7C,0x08,0x04,0x7C,0x00,0x00,0x00}, +{0x00,0x38,0x44,0x44,0x38,0x00,0x00,0x00}, +{0x00,0xFC,0x24,0x24,0x18,0x00,0x00,0x00}, +{0x00,0x18,0x24,0x24,0xFC,0x00,0x00,0x00}, +{0x00,0x00,0x7C,0x08,0x04,0x00,0x00,0x00}, +{0x00,0x48,0x54,0x54,0x24,0x00,0x00,0x00}, +{0x00,0x04,0x7F,0x44,0x00,0x00,0x00,0x00}, +{0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00}, +{0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00}, +{0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00}, +{0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00}, +{0x00,0x1C,0xA0,0xA0,0x7C,0x00,0x00,0x00}, +{0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00}, +{0x00,0x08,0x36,0x41,0x00,0x00,0x00,0x00}, +{0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00}, +{0x00,0x41,0x36,0x08,0x00,0x00,0x00,0x00}, +{0x00,0x02,0x01,0x01,0x02,0x01,0x00,0x00}, +{0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00} +}; + +//************************************************************************************************* \ No newline at end of file
diff -r 000000000000 -r ef802f772981 WIZnet_Library.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WIZnet_Library.lib Thu May 11 16:51:19 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/WIZnet/code/WIZnet_Library/#cb8808b47e69
diff -r 000000000000 -r ef802f772981 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 11 16:51:19 2017 +0000 @@ -0,0 +1,186 @@ +#include "mbed.h" +DigitalIn button(P0_1, PullUp); //按键myled3改变状态 +//adc采集电压函数 +float meas; +long ADC_VALUE[3]; +AnalogIn ADC_MQ2(P0_6); //ADC1,MQ2空气质量检测 +AnalogIn ADC_MQ3(P0_14); //ADC2,MQ2空气质量检测 +AnalogIn analog_value(P0_23); // ADC3,可调电位器 + +void adc_data() +{ + meas = ADC_MQ2.read(); + ADC_VALUE[0] = (long)(meas * 3300); + meas = ADC_MQ3.read(); + ADC_VALUE[1] = (long)(meas * 3300); + meas = analog_value.read(); + ADC_VALUE[2] = (long)(meas * 3300); +} + +//oled显示函数 +#include "CriusOLED.h" +DigitalOut myled1(P0_27); +DigitalOut myled2(P0_13); +DigitalOut myled3(P0_17); //用户led +Ticker ticker; +float sampleTime = 1.0; +long times; +char buffer1[40]; +char buffer2[20]; +char buffer3[20]; +char Buffer[100]; +#define bufferclear " " +void am2320_dat(); +void bme280_dat(); +void Tlink_Tcp(); +void oled_ticker() +{ + //每隔一秒显示一次 + myled1=!myled1; + if(!button) + myled3=!myled3; + adc_data(); + sendStrXY(bufferclear,1,0); + snprintf(buffer1,sizeof(buffer1), "%ds %dmV %dmV %dmV",times++,ADC_VALUE[0],ADC_VALUE[1],ADC_VALUE[2]); + sendStrXY(buffer1,0,0); + am2320_dat(); + bme280_dat(); +} + +void oled_init() +{ + i2c.frequency(400000); + init_OLED(); + displayOn(); + reset_display(); + ticker.attach(&oled_ticker, sampleTime); +} + +//AM2320初始化 +#include "AM2320.h" +AM2320 am2320(i2c); +int h; +int t; +void am2320_dat() +{ + h = am2320.humidity(); + t = am2320.temperature(); + snprintf(buffer2,sizeof(buffer2), "%2d.%dc %2d.%d%%",t/10,t%10,h/10,h%10); + sendStrXY(buffer2,4,0); +} + +#include "BME280.h" +BME280 sensor(I2C_SDA, I2C_SCL); +void bme280_dat() +{ + snprintf(buffer3,sizeof(buffer3), "%2.2fC %6.0fPa",sensor.getTemperature(), sensor.getPressure()*100); + sendStrXY(buffer3,5,0); +} + +Serial pc(P0_4,P0_0,921600); +//w5500初始化函数 +#include "WIZnetInterface.h" +#define USE_DHCP 1 + +#define LOOPBACKPORT 80 +char * IP_Addr = "192.168.0.194"; +char * IP_Subnet = "255.255.255.0"; +char * IP_Gateway = "192.168.0.1"; +unsigned char MAC_Addr[6] = {0x00,0x08,0xDC,0x12,0x34,0x56}; + + +SPI spi(P0_26,P0_25,P0_24); +WIZnetInterface ethernet(&spi,P0_16,P0_5); + +void W5500_init() +{ + #if USE_DHCP + int ret = ethernet.init(MAC_Addr); + #else + int ret = ethernet.init(MAC_Addr,IP_Addr,IP_Subnet,IP_Gateway); + #endif + myled2=1; + if (!ret) { + pc.printf("Initialized, MAC: %s\r\n", ethernet.getMACAddress()); + ret = ethernet.connect(); + if (!ret) { + pc.printf("IP: %s, MASK: %s, GW: %s\r\n", + ethernet.getIPAddress(), ethernet.getNetworkMask(), ethernet.getGateway()); + sendStrXY("IP:",2,0); + sendStrXY(ethernet.getIPAddress(),2,3); + } else { + pc.printf("Error ethernet.connect() - ret = %d\r\n", ret); + exit(0); + } + } else { + pc.printf("Error ethernet.init() - ret = %d\r\n", ret); + exit(0); + } +} + +void w5500_httpserver() +{ + char buffer[128]; + W5500_init(); + TCPSocketServer server; + server.bind(LOOPBACKPORT); + server.listen(); + while (1) { + pc.printf("\nWait for new connection...\r\n"); + TCPSocketConnection client; + server.accept(client); + client.set_blocking(false, 0); + pc.printf("Connection from: %s\r\n", client.get_address()); + sendStrXY("C:",3,0); + sendStrXY(client.get_address(),3,3); + while (client.is_connected() == true) { + myled2=0; + int n = client.receive(buffer, sizeof(buffer)); + if(n > 0) + { + //client.send_all(buffer, n); //将接受的数据发送回去 + if(strstr(buffer,"AD")) + client.send(buffer1, sizeof(buffer1)); + + if(strstr(buffer,"AM")) + client.send_all(buffer2, sizeof(buffer2)); + + if(strstr(buffer,"BE")) + client.send(buffer3, sizeof(buffer3)); + + if(strstr(buffer,"LED")) + myled3=!myled3; + + if(strstr(buffer,"ALL")) + { + snprintf(Buffer,sizeof(Buffer), " %s\r\n %s\r\n %s\r\n ledstatus:%d\r\n",buffer1,buffer2,buffer3,!myled3); + client.send(Buffer, sizeof(Buffer)); + } + + if(strstr(buffer,"IP")) + { + snprintf(Buffer,sizeof(Buffer), " MAC_Addr: %s\r\n LocalIp: %s\r\n ClientIp: %s\r\n",ethernet.getMACAddress(),ethernet.getIPAddress(),client.get_address()); + client.send(Buffer, sizeof(Buffer)); + } + } + if(client.is_fin_received()) + client.close(); + } + pc.printf("Disconnected.\r\n"); + sendStrXY(bufferclear,3,0); + //sendStrXY(bufferclear,7,0); + myled2=1; + } +} + + + +int main() { + pc.printf("Start\r\n"); + oled_init(); + wait(5); + while(1) + { + w5500_httpserver(); + } +}
diff -r 000000000000 -r ef802f772981 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 11 16:51:19 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/99b5ccf27215 \ No newline at end of file