hadif azli
/
TEST123
BLYNK TEST
oled.h@0:d8f4c441e032, 2016-06-10 (annotated)
- Committer:
- lixianyu
- Date:
- Fri Jun 10 15:20:20 2016 +0000
- Revision:
- 0:d8f4c441e032
- Child:
- 1:0e75de2a5d21
u8glib???????????i2c???
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lixianyu | 0:d8f4c441e032 | 1 | //#include <Wire.h> |
lixianyu | 0:d8f4c441e032 | 2 | #include <U8glib.h> |
lixianyu | 0:d8f4c441e032 | 3 | |
lixianyu | 0:d8f4c441e032 | 4 | U8GLIB_SSD1306_MICRODUINO_128X64 u8g; //设置OLED型号 |
lixianyu | 0:d8f4c441e032 | 5 | //-------字体设置,大、中、小 |
lixianyu | 0:d8f4c441e032 | 6 | #define setFont_L u8g.setFont(u8g_font_7x13) |
lixianyu | 0:d8f4c441e032 | 7 | #define setFont_M u8g.setFont(u8g_font_fixed_v0r) |
lixianyu | 0:d8f4c441e032 | 8 | #define setFont_S u8g.setFont(u8g_font_chikitar) |
lixianyu | 0:d8f4c441e032 | 9 | |
lixianyu | 0:d8f4c441e032 | 10 | //温度计图案 |
lixianyu | 0:d8f4c441e032 | 11 | const unsigned char bmp_tem[] U8G_PROGMEM = { |
lixianyu | 0:d8f4c441e032 | 12 | 0xE0,0x81,0x30,0x83,0x10,0x82,0x10,0x82,0x10,0xFA,0x10,0x82, |
lixianyu | 0:d8f4c441e032 | 13 | 0x10,0x82,0x10,0xFA,0x10,0x82,0xD0,0x82,0xD0,0xFA,0xD0,0x82, |
lixianyu | 0:d8f4c441e032 | 14 | 0xD0,0x82,0xD0,0xFA,0xD0,0x82,0xD0,0x82,0xD0,0xFA,0xD0,0x82, |
lixianyu | 0:d8f4c441e032 | 15 | 0xD0,0x82,0xD8,0x86,0xC4,0x88,0xF2,0x93,0xFB,0xB7,0xF9,0xA7, |
lixianyu | 0:d8f4c441e032 | 16 | 0xFD,0xAF,0xFD,0xAF,0xF9,0xA7,0xFA,0x97,0xF2,0x93,0xC4,0x88, |
lixianyu | 0:d8f4c441e032 | 17 | 0x18,0x86,0xF0,0x83 |
lixianyu | 0:d8f4c441e032 | 18 | }; |
lixianyu | 0:d8f4c441e032 | 19 | |
lixianyu | 0:d8f4c441e032 | 20 | //水滴图案 |
lixianyu | 0:d8f4c441e032 | 21 | const unsigned char bmp_hum[] U8G_PROGMEM = { |
lixianyu | 0:d8f4c441e032 | 22 | 0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x80,0x03,0x08,0x80,0x03,0x18,0x80,0x07,0x1C, |
lixianyu | 0:d8f4c441e032 | 23 | 0xC0,0x07,0x3C,0xC0,0x07,0x3E,0xE0,0x0F,0x3E,0xE0,0x0F,0x7A,0xF0,0x1F,0x7B,0xF8, |
lixianyu | 0:d8f4c441e032 | 24 | 0x1F,0x72,0xF8,0x1F,0x3E,0xF8,0x3F,0x1C,0xFC,0x3F,0x00,0xFC,0x7F,0x00,0xFE,0x7F, |
lixianyu | 0:d8f4c441e032 | 25 | 0x00,0xFE,0x7F,0x00,0xFE,0x7F,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0x00, |
lixianyu | 0:d8f4c441e032 | 26 | 0xF3,0xFF,0x00,0xF2,0x7F,0x00,0xE6,0x7F,0x00,0xC6,0x7F,0x00,0x0E,0x3F,0x00,0x3C, |
lixianyu | 0:d8f4c441e032 | 27 | 0x1E,0x00,0xF8,0x1F,0x00,0xE0,0x07,0x00,0x80,0x01 |
lixianyu | 0:d8f4c441e032 | 28 | }; |
lixianyu | 0:d8f4c441e032 | 29 | |
lixianyu | 0:d8f4c441e032 | 30 | void oled(float temp, float humi, float light, float pm25, float etoh) |
lixianyu | 0:d8f4c441e032 | 31 | { |
lixianyu | 0:d8f4c441e032 | 32 | u8g.firstPage(); |
lixianyu | 0:d8f4c441e032 | 33 | do { |
lixianyu | 0:d8f4c441e032 | 34 | u8g.setDefaultForegroundColor(); |
lixianyu | 0:d8f4c441e032 | 35 | |
lixianyu | 0:d8f4c441e032 | 36 | u8g.drawXBMP( 4, 1, 15, 32, bmp_tem); |
lixianyu | 0:d8f4c441e032 | 37 | u8g.drawXBMP( 70, 2, 24, 30, bmp_hum); |
lixianyu | 0:d8f4c441e032 | 38 | |
lixianyu | 0:d8f4c441e032 | 39 | setFont_M; //设置字体为大 |
lixianyu | 0:d8f4c441e032 | 40 | u8g.setPrintPos(20, 16); //设置文字开始坐标 |
lixianyu | 0:d8f4c441e032 | 41 | u8g.print("`C "); |
lixianyu | 0:d8f4c441e032 | 42 | setFont_L; //设置字体为大 |
lixianyu | 0:d8f4c441e032 | 43 | u8g.setPrintPos(20, 32); //设置文字开始坐标 |
lixianyu | 0:d8f4c441e032 | 44 | u8g.print(temp , 1); //温度 |
lixianyu | 0:d8f4c441e032 | 45 | |
lixianyu | 0:d8f4c441e032 | 46 | u8g.setPrintPos(100, 16); //设置文字开始坐标 |
lixianyu | 0:d8f4c441e032 | 47 | u8g.print("%"); |
lixianyu | 0:d8f4c441e032 | 48 | setFont_L; //设置字体为大 |
lixianyu | 0:d8f4c441e032 | 49 | u8g.setPrintPos(100, 32); //设置文字开始坐标 |
lixianyu | 0:d8f4c441e032 | 50 | u8g.print(humi , 0); //湿度 |
lixianyu | 0:d8f4c441e032 | 51 | |
lixianyu | 0:d8f4c441e032 | 52 | setFont_L; //设置字体 |
lixianyu | 0:d8f4c441e032 | 53 | u8g.setPrintPos(4, 49); //设置文字开始坐标 |
lixianyu | 0:d8f4c441e032 | 54 | u8g.print(light , 0); //光照强度 |
lixianyu | 0:d8f4c441e032 | 55 | setFont_M; //设置字体 |
lixianyu | 0:d8f4c441e032 | 56 | u8g.print(" Lux"); |
lixianyu | 0:d8f4c441e032 | 57 | |
lixianyu | 0:d8f4c441e032 | 58 | setFont_L; //设置字体 |
lixianyu | 0:d8f4c441e032 | 59 | u8g.setPrintPos(4, 63); //设置文字开始坐标 |
lixianyu | 0:d8f4c441e032 | 60 | u8g.print(pm25 , 0); //光照强度 |
lixianyu | 0:d8f4c441e032 | 61 | setFont_M; //设置字体 |
lixianyu | 0:d8f4c441e032 | 62 | u8g.print(" ug/m3"); |
lixianyu | 0:d8f4c441e032 | 63 | |
lixianyu | 0:d8f4c441e032 | 64 | |
lixianyu | 0:d8f4c441e032 | 65 | setFont_L; //设置字体 |
lixianyu | 0:d8f4c441e032 | 66 | u8g.setPrintPos(80, 49); //设置文字开始坐标 |
lixianyu | 0:d8f4c441e032 | 67 | u8g.print(etoh , 0); //光照强度 |
lixianyu | 0:d8f4c441e032 | 68 | setFont_M; //设置字体 |
lixianyu | 0:d8f4c441e032 | 69 | u8g.print(" ppm"); |
lixianyu | 0:d8f4c441e032 | 70 | |
lixianyu | 0:d8f4c441e032 | 71 | // setFont_M; //设置字体为大 |
lixianyu | 0:d8f4c441e032 | 72 | // u8g.setPrintPos(80, 63); //设置文字开始坐标 |
lixianyu | 0:d8f4c441e032 | 73 | // u8g.print(" LED:"); |
lixianyu | 0:d8f4c441e032 | 74 | |
lixianyu | 0:d8f4c441e032 | 75 | } while( u8g.nextPage() ); |
lixianyu | 0:d8f4c441e032 | 76 | } |
lixianyu | 0:d8f4c441e032 | 77 |