- /*
- Eagler8系列實驗程序列表
- 第十類 板載端口擴展實驗
- 32 0.96寸OLED12864液晶屏模塊(顯示器類,IIC接口)
- 實驗接線:A4---SDA, A5---SCL
- 項目五:顯示漢字“雕爺學編程”
- */
- #include "stdio.h"
- #include "stdlib.h"
- #include "U8glib.h"
- U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI
- //U8GLIB_SSD1306_128X64 u8g(10, 9, 12, 11); // SW SPI Com: SCL = 10, SDA = 9, CS = 12, DC = 11,RES=RESET
- static const unsigned char wendu[5][80] PROGMEM={
- {0x00,0x14,0xFE,0x24,0x92,0x02,0x92,0x7E,0xBA,0x13,0x92,0x12,0xFE,0x7E,0x82,0x12,
- 0xBA,0x12,0xAA,0x7E,0xAA,0x12,0xBA,0x12,0x82,0x12,0x82,0x7E,0xA2,0x02,0x41,0x02},/*"雕",0*/
- {0x20,0x02,0x10,0x04,0x18,0x0A,0x24,0x11,0xC0,0x00,0x30,0x03,0x0C,0x0C,0x03,0x70,
- 0xF8,0x0F,0x40,0x08,0x40,0x08,0x40,0x08,0x40,0x0A,0x40,0x04,0x40,0x00,0x40,0x00},/*"爺",1*/
- {0x44,0x10,0x88,0x10,0x88,0x08,0x00,0x04,0xFE,0x7F,0x02,0x40,0x01,0x20,0xF8,0x07,
- 0x00,0x02,0x80,0x01,0xFF,0x7F,0x80,0x00,0x80,0x00,0x80,0x00,0xA0,0x00,0x40,0x00},/*"學",2*/
- {0x08,0x01,0x08,0x02,0xC4,0x3F,0x44,0x20,0x52,0x20,0xDF,0x3F,0x48,0x00,0x44,0x00,
- 0xC2,0x3F,0xDF,0x2A,0xC2,0x2A,0xA0,0x3F,0xB8,0x2A,0xA7,0x2A,0x92,0x22,0x80,0x30},/*"編",3*/
- {0x10,0x00,0xB8,0x3F,0x8F,0x20,0x88,0x20,0x88,0x20,0xBF,0x3F,0x08,0x00,0x0C,0x00,
- 0x9C,0x7F,0x2A,0x04,0x2A,0x04,0x89,0x3F,0x08,0x04,0x08,0x04,0xC8,0x7F,0x08,0x00},/*"程",4*/
- };
- void draw(void) {
- //畫出16*16漢字
- u8g.drawXBMP( 0, 0, 16, 16, wendu[0]);
- u8g.drawXBMP( 16, 0,16, 16, wendu[1]);
- u8g.drawXBMP( 32, 0,16, 16, wendu[2]);
- u8g.drawXBMP( 48, 0,16, 16, wendu[3]);
- u8g.drawXBMP( 64, 0,16, 16, wendu[4]);
- u8g.drawXBMP( 0, 16,16, 16, wendu[0]);
- u8g.drawXBMP( 16, 16,16, 16, wendu[1]);
- u8g.drawXBMP( 32, 16,16, 16, wendu[2]);
- u8g.drawXBMP( 48, 16,16, 16, wendu[3]);
- u8g.drawXBMP( 64, 16,16, 16, wendu[4]);
- u8g.setFont(u8g_font_osb18);//設置要顯示字符的字體
- u8g.drawStr(0, 64, "Arduino");//顯示字符ABC
- u8g.setColorIndex(1);//顯示對象為不透明
- }
- void setup(void) {
- }
- void loop(void) {
- u8g.firstPage();
- do {
- draw();
- } while( u8g.nextPage() );
- }
復制代碼
|