資源簡(jiǎn)介
ssd1306驅(qū)動(dòng)12864OLED顯示屏msp430g2553函數(shù)庫(kù),引腳需要自行定義,已測(cè)試可行
代碼片段和文件信息
#include?“OLEDssd1306.h“
#include?“io430.h“
#include?“in430.h“
#include?
#include?
#include?
///*********************************************************************
//*?功能描述:g2553?USCI_A0模塊初始化為SPI模式
//*?參數(shù):無(wú)
//*?返回:無(wú)
//*?備注:無(wú)
//**********************************************************************/
//void?USCIA0_SPI_init()???????//ssd1306中4線(xiàn)制SPI,g2553中3線(xiàn)SPI
//{
// UCA0CTL1|=UCSWRST;
// UCA0CTL0|=UCSYNC+UCMST;????//USCIA0選擇SPI模式,master模式
// UCA0CTL1|=UCSSEL0;?????????//SPI時(shí)鐘選擇輔助系統(tǒng)時(shí)鐘32768Hz?
// UCA0CTL1&=~UCSWRST;
//}
/*********************************************************************
*?功能描述:向oled中寫(xiě)入一字節(jié)的控制命令
*?參數(shù):控制命令(cmd)
*?返回:無(wú)
*?備注:無(wú)
**********************************************************************/
void?OLED_write_CommandByte(unsigned?char?cmd)
{
OLEDOUT&=~DC;
OLEDOUT&=~D0;
unsigned?char?i;
for(i=0;i<8;i++)
{
if((cmd&0x80)==0)?OLEDOUT&=~D1;
else?OLEDOUT|=D1;
OLEDOUT|=D0;
_NOP();
OLEDOUT&=~D0;
cmd<<=1;
}
}
/*********************************************************************
*?功能描述:向oled中寫(xiě)入一字節(jié)的展示數(shù)據(jù)
*?參數(shù):展示數(shù)據(jù)(data)
*?返回:無(wú)
*?備注:無(wú)
**********************************************************************/
void?OLED_write_DataByte(unsigned?char?data)
{
OLEDOUT|=DC;
OLEDOUT&=~D0;
unsigned?char?i;
for(i=0;i<8;i++)
{
if((data&0x80)==0)?OLEDOUT&=~D1;
else?OLEDOUT|=D1;
OLEDOUT|=D0;
_NOP();
OLEDOUT&=~D0;
data<<=1;
}
}
/*********************************************************************
*?功能描述:設(shè)置圖像的起始位置
*?參數(shù):起始位置x,y坐標(biāo)
*?返回:無(wú)
*?備注:無(wú)
**********************************************************************/
void?OLED_SetPos(unsigned?char?x?unsigned?char?y)
{
OLED_write_CommandByte(0xb0+y);????//設(shè)置起始頁(yè)
OLED_write_CommandByte(((x&0xf0)>>4)|0x10);???????//起始列低地址
OLED_write_CommandByte((x&0x0f)|0x01);?????????//起始列高地址
}
/*********************************************************************
*?功能描述:初始清屏
*?參數(shù):無(wú)
*?返回:無(wú)
*?備注:無(wú)
**********************************************************************/
void?OLED_clear()
{
unsigned?char?ij;
for(i=0;i<8;i++)
{
OLED_write_CommandByte(0xb0+i);
OLED_write_CommandByte(0x01);
OLED_write_CommandByte(0x10);
for(j=0;j<128;j++)
OLED_write_DataByte(0);
}
}
/*********************************************************************
*?功能描述:清除一頁(yè)
*?參數(shù):無(wú)
*?返回:無(wú)
*?備注:無(wú)
**********************************************************************/
void?OLED_clear_page(char?i)
{
unsigned?char?j;
OLED_write_CommandByte(0xb0+i);
OLED_write_CommandByte(0x01);
OLED_write_CommandByte(0x10);
for(j=0;j<128;j++)
OLED_write_DataByte(0);
}
/*********************************************************************
*?功能描述:顯示一句中文語(yǔ)句,漢字的大小為14x16
*?參數(shù):已經(jīng)取模轉(zhuǎn)換的中文語(yǔ)句數(shù)組ch[]位置坐標(biāo)x,y
*?返回:無(wú)
*?備注:無(wú)
**********************************************************************/
void?OLED_display_Chinese(unsigned?char?x?unsigned?char?y?cons
評(píng)論
共有 條評(píng)論