|
51hei.png (12.93 KB, 下載次數(shù): 113)
下載附件
2021-6-18 15:42 上傳
- void oled_init(void)//初始化ssd1306
- {
- delay_ms(500);//延時(shí)(必須有)
- oled_wr_byte(0xAE,0);//關(guān)閉oled面板
- oled_wr_byte(0x00,0);//設(shè)置低位列地址
- oled_wr_byte(0x10,0);//設(shè)置高位列地址
- oled_wr_byte(0x40,0);//設(shè)置起始行地址設(shè)置映射RAM顯示起始行(0x00~0x3F)
- oled_wr_byte(0x81,0);//--設(shè)置對(duì)比度控制寄存器
- oled_wr_byte(0xCF,0);//設(shè)置SEG輸出電流亮度
- oled_wr_byte(0xA1,0);//設(shè)置分段/列映射0xa0左右反置 0xa1型正常
- oled_wr_byte(0xC8,0);//設(shè)置COM/行掃描方向0xc0上下反置 0xc8型正常
- oled_wr_byte(0xA6,0);//設(shè)置正常顯示
- oled_wr_byte(0xA8,0);//設(shè)置復(fù)用比(1到64)
- oled_wr_byte(0x3F,0);//1/64負(fù)載
- oled_wr_byte(0xD3,0);//設(shè)置顯示偏移映射RAM計(jì)數(shù)器(0x00~0x3F)
- oled_wr_byte(0x00,0);//不補(bǔ)償
- oled_wr_byte(0xD5,0);//設(shè)置顯示時(shí)鐘分頻比/振蕩器頻率
- oled_wr_byte(0x80,0);//設(shè)置分頻比,將時(shí)鐘設(shè)置為100幀/秒
- oled_wr_byte(0xD8,0);
- oled_wr_byte(0x05,0);
- oled_wr_byte(0xD9,0);//設(shè)置預(yù)充電時(shí)間
- oled_wr_byte(0xF1,0);//將預(yù)充電設(shè)置為15個(gè)時(shí)鐘,放電設(shè)置為1個(gè)時(shí)鐘
- oled_wr_byte(0xDA,0);//設(shè)置com引腳硬件配置
- oled_wr_byte(0x12,0);//
- oled_wr_byte(0xDB,0);//設(shè)置vcomh
- oled_wr_byte(0x40,0);//設(shè)置VCOM取消選擇級(jí)別
- oled_wr_byte(0x20,0);//設(shè)置頁(yè)面尋址模式(0x00/0x01/0x02)
- oled_wr_byte(0x02,0);//
- oled_wr_byte(0x8D,0);//設(shè)置電荷泵啟用/禁用
- oled_wr_byte(0x14,0);//設(shè)置(0x10)禁用
- oled_wr_byte(0xA4,0);//禁用整個(gè)顯示打開(kāi)(0xa4/0xa5)
- oled_wr_byte(0xA6,0);//禁用反轉(zhuǎn)顯示打開(kāi)(0xa6/a7)
- oled_wr_byte(0xAF,0);//打開(kāi)oled面板
- fill_picture(0x00);//初始清屏
- oled_set_pos(0,0);//初始光標(biāo)
- }
復(fù)制代碼- #include"iic.h"
- int main()
- {
- oled_init();//初始化
- oled_showchinese(0,0,1);//顯示漢字
- oled_showchinese(16,0,0);
- oled_showchinese(32,0,2);
- oled_showchinese(48,0,2);
- oled_showchinese(64,0,3);
- oled_showchinese(80,0,4);
- oled_showchinese(112,0,5);
- delay_ms(3000);
- oled_showstring(0,2,"Presented by",32);//顯示字符串
- oled_showstring(0,3,"DarkStar244",32);
- oled_showstring(0,4,"114514",16);
- oled_wr_byte(0x2e,0);//關(guān)滾動(dòng)
- oled_wr_byte(0x29,0);//方向,29右,2a左
- oled_wr_byte(0x00,0);//空字節(jié)
- oled_wr_byte(0x04,0);//水平起始頁(yè)
- oled_wr_byte(0x0cf,0);//水平滾動(dòng)速度
- oled_wr_byte(0x01,0);//水平結(jié)束頁(yè)
- oled_wr_byte(0x00,0);//每次垂直滾動(dòng)位移
- oled_wr_byte(0x2f,0);//開(kāi)滾動(dòng)
- while (1){;}
- }
復(fù)制代碼 下載:
iic.rar
(5.06 KB, 下載次數(shù): 42)
2021-6-18 12:48 上傳
點(diǎn)擊文件名下載附件
軟件iic 下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|