首页资源分类嵌入式处理器51内核 > OLED_drv share

OLED_drv share

已有 445025个资源

下载专区

上传者其他资源

    文档信息举报收藏

    标    签:ssd1306

    分    享:

    文档简介

    for oled 1306 drv reference.

    文档预览

    /* IQC program */ /* IC : ssd1306 4wire serial interface */ /* Module : 12864-COG */ #include "io51.h" #define SCL P1.0 #define SDA P1.1 #define DC P3.2 #define CS P3.4 /*#define RD P3.0 #define WR P3.1 */ #define RES P3.3 /*副程式宣告*/ void ssd1306(); void write_i(unsigned char ins); void write_d(unsigned char dat); void delay(unsigned int i); void fill(unsigned char dat1,unsigned char dat2); void showpic(); void pane(); const unsigned char show1[] = { 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x00,0x00,0x00,0x82,0xFF,0x80,0x00,0x00, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x00,0x00,0xC6,0xA1,0x91,0x89,0x86,0x00, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x00,0x00,0x42,0x81,0x89,0x89,0x76,0x00, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x00,0x00,0x10,0x2C,0x22,0xFF,0xA0,0x00, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x00,0x00,0x4F,0x89,0x89,0x89,0x71,0x00, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x00,0x00,0x00,0x82,0xFF,0x80,0x00,0x00,0x00,0x00,0xC6,0xA1,0x91,0x89,0x86,0x00, 0x00,0x00,0x42,0x81,0x89,0x89,0x76,0x00,0x00,0x00,0x10,0x2C,0x22,0xFF,0xA0,0x00, 0x00,0x00,0x4F,0x89,0x89,0x89,0x71,0x00,0x00,0x00,0x7E,0x89,0x89,0x8B,0x70,0x00, 0x00,0x00,0x03,0x01,0xF9,0x07,0x01,0x00,0x00,0x00,0x76,0x89,0x89,0x89,0x76,0x00, 0x00,0x00,0x0E,0xD1,0x91,0x91,0x7E,0x00,0x00,0x00,0x7E,0x81,0x81,0x81,0x7E,0x00, 0x00,0x00,0x00,0x82,0xFF,0x80,0x00,0x00,0x00,0x00,0xC6,0xA1,0x91,0x89,0x86,0x00, 0x00,0x00,0x42,0x81,0x89,0x89,0x76,0x00,0x00,0x00,0x10,0x2C,0x22,0xFF,0xA0,0x00, 0x00,0x00,0x4F,0x89,0x89,0x89,0x71,0x00,0x00,0x00,0x7E,0x89,0x89,0x8B,0x70,0x00, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0x00,0x03,0x01,0xF9,0x07,0x01,0x00, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0x00,0x76,0x89,0x89,0x89,0x76,0x00, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, 0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA, }; /*main start*/ main() { RD=1; WR=1; RES=1; delay(1000); RES=0; delay(1000); RES=1; delay(1000); ssd1306(); while(1) { fill(0x55,0xAA); pane(); /* showpic();*/ fill(0x33,0xcc); fill(0xFF,0xFF); delay(60000); delay(60000); delay(60000); delay(60000); delay(60000); delay(60000); } } /*main end*/ /*副程式*/ void write_i(unsigned char ins) { unsigned char m,da; unsigned int j; DC=0; CS=0; da=ins; for(j=0;j<8;j++) { m=da; SCL=0; m=m&0x80; if(m==0x80) { SDA=1; } else { SDA=0; } da=da<<1; SCL=1; } CS=1; } void write_d(unsigned char dat) { unsigned char m,da; unsigned int j; DC=1; CS=0; da=dat; for(j=0;j<8;j++) { m=da; SCL=0; m=m&0x80; if(m==0x80) { SDA=1; } else { SDA=0; } da=da<<1; SCL=1; } CS=1; } void delay(unsigned int i) { while(i>0) { i--; } } void ssd1306() { write_i(0xAE); /*display off*/ write_i(0x00); /*set lower column address*/ write_i(0x10); /*set higher column address*/ write_i(0x40); /*set display start line*/ write_i(0xB0); /*set page address*/ write_i(0x81); /*contract control*/ write_i(0xcf); /*128*/ write_i(0xA1); /*set segment remap*/ write_i(0xA6); /*normal / reverse*/ write_i(0xA8); /*multiplex ratio*/ write_i(0x3F); /*duty = 1/64*/ write_i(0xC8); /*Com scan direction*/ write_i(0xD3); /*set display offset*/ write_i(0x00); write_i(0xD5); /*set osc division*/ write_i(0x80); write_i(0xD9); /*set pre-charge period*/ write_i(0xf1); write_i(0xDA); /*set COM pins*/ write_i(0x12); write_i(0xdb); /*set vcomh*/ write_i(0x40); write_i(0x8d); /*set charge pump enable*/ write_i(0x14); write_i(0xAF); /*display ON*/ } void fill(unsigned char dat1,unsigned char dat2) { unsigned char x,y; write_i(0x00); /*set lower column address*/ write_i(0x10); /*set higher column address*/ write_i(0xB0); /*set page address*/ for(y=0;y<8;y++) { write_i(0xB0+y); /*set page address*/ write_i(0x00); /*set lower column address*/ write_i(0x10); /*set higher column address*/ for(x=0;x<64;x++) { write_d(dat1); write_d(dat2); } } delay(60000); /* delay(60000); */ } void showpic() { unsigned char x,y; unsigned int j=0; write_i(0x00); /*set lower column address*/ write_i(0x10); /*set higher column address*/ for(y=0;y<8;y++) { write_i(0xB0+y); /*set page address*/ write_i(0x00); /*set lower column address*/ write_i(0x10); /*set higher column address*/ for(x=0;x<128;x++) write_d(show1[j++]); } delay(60000); /* delay(60000); */ } void pane() { unsigned char x,y; /* PAGE 0*/ write_i(0x00); /*set lower column address*/ write_i(0x10); /*set higher column address*/ write_i(0xB0); /*set page address*/ write_d(0xFF); for(x=0;x<126;x++) write_d(0x01); write_d(0xFF); /* PAGE 1*/ write_i(0x00); /*set lower column address*/ write_i(0x10); /*set higher column address*/ write_i(0xB1); /*set page address*/ write_d(0xFF); for(x=0;x<126;x++) write_d(0x80); write_d(0xFF); /* PAGE 2*/ write_i(0x00); /*set lower column address*/ write_i(0x10); /*set higher column address*/ write_i(0xB2); /*set page address*/ write_d(0xFF); for(x=0;x<126;x++) write_d(0x01); write_d(0xFF); /* PAGE 3~6*/ for (y=3;y<7;y++) { write_i(0x00); /*set lower column address*/ write_i(0x10); /*set higher column address*/ write_i(0xB0+y); /*set page address*/ write_d(0xFF); for(x=0;x<126;x++) write_d(0x00); write_d(0xFF); } /* PAGE 7*/ write_i(0x00); /*set lower column address*/ write_i(0x10); /*set higher column address*/ write_i(0xB7); /*set page address*/ write_d(0xFF); for(x=0;x<126;x++) write_d(0x80); write_d(0xFF); delay(60000); /* delay(60000); */ }

    Top_arrow
    回到顶部
    EEWORLD下载中心所有资源均来自网友分享,如有侵权,请发送举报邮件到客服邮箱bbs_service@eeworld.com.cn 或通过站内短信息或QQ:273568022联系管理员 高员外,我们会尽快处理。