欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
基于MSP430F5529的OLED驅(qū)動程序
[打印本頁]
作者:
afeffaef
時間:
2020-7-15 17:25
標(biāo)題:
基于MSP430F5529的OLED驅(qū)動程序
壓縮包中代碼
單片機源程序如下:
/*
* OLED_IIC.c
*
* Created on: 2020年7月15日
* Author: 13293
*/
#include "OLED_IIC.h"
#include "stdlib.h"
#include "OLED_FONT.h"
#include <msp430.h>
//OLED延時功能
void delayms(uint x)
{
uint i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
//IIC開始
void oled_IIC_Start()
{
oled_SCL_1;
oled_SDA_1;
oled_SDA_0;
oled_SCL_0;
}
//IIC停止
void oled_IIC_Stop()
{
oled_SCL_0;
oled_SDA_0;
oled_SCL_1;
oled_SDA_1;
}
//IIC寫字節(jié)
void oled_Write_IIC_Byte(uchar IIC_Byte)
{
uchar i;
for(i=0;i<8;i++)
{
if(IIC_Byte & 0x80)
oled_SDA_1;
else
oled_SDA_0;
oled_SCL_1;
oled_SCL_0;
IIC_Byte<<=1;
}
oled_SDA_1;
oled_SCL_1;
oled_SCL_0;
}
//IIC寫入數(shù)據(jù)
void OLED_12864_Write_data(uint dat)
{
oled_IIC_Start();
oled_Write_IIC_Byte(0x78);
oled_Write_IIC_Byte(0x40);
oled_Write_IIC_Byte(dat);
oled_IIC_Stop();
}
//IIC寫入命令
void OLED_12864_Write_commomand(uint dat)
{
oled_IIC_Start();
oled_Write_IIC_Byte(0x78);
oled_Write_IIC_Byte(0x00);
oled_Write_IIC_Byte(dat);
oled_IIC_Stop();
}
//OLED設(shè)置起始坐標(biāo)
void OLED_SetPos(uchar x, uchar y)
{
OLED_12864_Write_commomand(0xb0+y);
OLED_12864_Write_commomand(((x&0xf0)>>4)|0x10);
OLED_12864_Write_commomand((x&0x0f)|0x01);
}
//IIC OLED屏幕填充
void OLED_Fill(uchar bmp_dat)
{
uchar y,x;
for(y=0;y<8;y++)
{
OLED_12864_Write_commomand(0xb0+y);
OLED_12864_Write_commomand(0x01);
OLED_12864_Write_commomand(0x10);
for(x=0;x<128;x++)
OLED_12864_Write_data(bmp_dat);
}
}
//OLED12864初始化
void OLED_12864_Init()
{
oled_IO_init;
delayms(500); //初始化之前的延時很重要!
OLED_12864_Write_commomand(0xae);
OLED_12864_Write_commomand(0x00);
OLED_12864_Write_commomand(0x10);
OLED_12864_Write_commomand(0x40);
OLED_12864_Write_commomand(0x81);
OLED_12864_Write_commomand(0xFF);//設(shè)置OLED亮度
OLED_12864_Write_commomand(0xa1);
OLED_12864_Write_commomand(0xc8);
OLED_12864_Write_commomand(0xa6);
OLED_12864_Write_commomand(0xa8);
OLED_12864_Write_commomand(0x3f);
OLED_12864_Write_commomand(0xd3);
OLED_12864_Write_commomand(0x00);
OLED_12864_Write_commomand(0xd5);
OLED_12864_Write_commomand(0x80);
OLED_12864_Write_commomand(0xd9);
OLED_12864_Write_commomand(0xf1);
OLED_12864_Write_commomand(0xda);
OLED_12864_Write_commomand(0x12);
OLED_12864_Write_commomand(0xdb);
OLED_12864_Write_commomand(0x40);
OLED_12864_Write_commomand(0x20);
OLED_12864_Write_commomand(0x02);
OLED_12864_Write_commomand(0x8d);
OLED_12864_Write_commomand(0x14);
OLED_12864_Write_commomand(0xa4);
OLED_12864_Write_commomand(0xa6);
OLED_12864_Write_commomand(0xaf);
OLED_Fill(0x00); //清屏
OLED_SetPos(0,0);
}
//IIC OLED顯示單個字符
void OLED_8x16Str(uchar x, uchar y, uchar ch)
{
uchar i=0;
if(x>120)
{
x=0;y++;
}
OLED_SetPos(x,y);
for(i=0;i<8;i++)
{
OLED_12864_Write_data(F8X16[ch*16+i]);
}
OLED_SetPos(x,y+1);
for(i=0;i<8;i++)
{
OLED_12864_Write_data(F8X16[ch*16+i+8]);
}
}
//IIC OLED顯示字符串
void OLED_ShowStr(uchar x, uchar y, uchar ch[])
{
uchar c = 0,i = 0,j = 0;
//'\0'位字符串結(jié)束標(biāo)志
while(ch[j] != '\0')
{
c = ch[j] - 32;
if(x > 120)
{
x = 0;
y++;
}
OLED_SetPos(x,y);
for(i=0;i<8;i++)
OLED_12864_Write_data(F8X16[c*16+i]);
OLED_SetPos(x,y+1);
for(i=0;i<8;i++)
OLED_12864_Write_data(F8X16[c*16+i+8]);
x += 8;
j++;
}
}
//顯示16*32的坐標(biāo)(x,y),y為頁范圍0~7---分四部分
void OLED_16x32(uchar x, uchar y, uchar ch)
{
uchar i=0;
if(x>120)
{
x=0;y++;
}
OLED_SetPos(x,y);
for(i=0;i<16;i++)
{
OLED_12864_Write_data(F16X32[ch*64+i]);
}
OLED_SetPos(x,y+1);
……………………
…………限于本文篇幅 余下代碼請從51黑下載附件…………
復(fù)制代碼
所有資料51hei提供下載:
OLED.rar
(4.3 KB, 下載次數(shù): 126)
2020-7-15 17:24 上傳
點擊文件名下載附件
源、頭文件
下載積分: 黑幣 -5
作者:
Burannn
時間:
2020-9-24 14:37
這個oled是所有oled都適用嘛
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1