欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
單片機軟件模擬IIC在OLED12864任意位置顯示字符及漢字oled12864.h下載
[打印本頁]
作者:
nxw_toyosz
時間:
2024-5-4 08:21
標題:
單片機軟件模擬IIC在OLED12864任意位置顯示字符及漢字oled12864.h下載
制作出來的電路實物圖如下:
51hei圖片_20240504081312.jpg
(134.66 KB, 下載次數: 46)
下載附件
2024-5-4 08:14 上傳
STC15F2K60S2單片機源程序如下:
oled12864.h
/*********************************************************************************************************************
*1.oled12864模塊頭文件( SSD1306驅動IC)
*2.文件:oled12864.h
*4.版本: V1.0
*************************************************說明事項*****************************************************************
* ssd1306本身支持多種總線驅動方式包括SPI以及并口等,通過芯片的相應IO口拉低拉高來選擇哪一種接口,0x78為IIC接口,0x7A為SOI接口
*使用I2C接口時,SSD1306允許有最多兩個7位的I2C地址,同樣通過相應的IO口拉低拉高來切換,一般默認是0x3c,在屏幕模塊的背面,
*可以看到一個I2C地址切換提示,需要改變模塊I2C地址時,只需要把提示位置的電阻取下焊接到另外一端即可。
*要注意的是板上的I2C地址是加上了第零位讀寫位后的數值,即0x78 = 0x3c<<1 0x7A = 0x3d<<1,
*SSD1306支持多種控制方式,I2C、6800、8080、4線SPI、3線SPI,通過SSD1306的3個引腳 BS0、BS1、BS2接不同的電平來選擇控制方式,
*I2C控制:BS0=0、BS1=1、BS2=0;
*6800控制:BS0=0、BS1=0、BS2=1;
*8080控制:BS0=0、BS1=1、BS2=1;
*4線SPI控制:BS0=0、BS1=0、BS2=0;
*3線SPI控制:BS0=1、BS1=0、BS2=0;
*從機地址是由七個位組成的,如上圖框起來的高七位,這里說明了SSD1306的從地址高六位是固定的,只有第七位受SA0控制,
*如果這個位為邏輯0,地址則是0x78,如果為邏輯1則是0x7A。一般情況下看一下背面就可以了,廠家一般會默認選擇搞成0x78
***********************************************************************************************************************/
#ifndef _OLED12864_H_
#define _OLED12864_H_
#include "IIC.h"
#include "Font.h"
#define BIRGTHNESS //OLED的亮度 00~255,0xcf;
#define X_WIDTH 128 //屏幕寬度
#define Y_HIGH (8*8) //屏幕高度
#define IIC_OLED_ADDR_W 0x78 //OLED器件地址,7位地址,高位為0表示寫,為1表示讀,//通過調整0R電阻,屏可以0x78和0x7A兩個地址 -- 默認0x78
#define Brightness 0xCF
//void OLED_Write_Command(unsigned char IIC_Command);
//void OLED_Write_Data(unsigned char IIC_Data);
void OLED_Init(void);
void OLED_Clear(void);
void OLED_ON(void);
void OLED_OFF(void);
//void OLED_ShowStr(unsigned char x, unsigned char y, unsigned char ch[]);
void OLED_ShowChinese(unsigned char x, unsigned char y, unsigned char Num);
void OLED_ShowStr(unsigned char x, unsigned char y, unsigned char ch[], unsigned char TextSize);
/****************************************************************************
*函數名稱:void OLED_Write_Command(unsigned char IIC_Command)
*函數功能:寫OLED命令; 此函數實測OK
*輸入: unsigned char IIC_Command
*輸出: 無
*****************************************************************************/
/***************/
void OLED_Write_Command(unsigned char IIC_Command)
{
IIC_Start(); //啟動I2C
IIC_Send_Byte(IIC_OLED_ADDR_W); //D/C #=0; R/W #=0;寫IIC器件地址
IIC_Wait_Ack();
IIC_Send_Byte(0x00); //寄存器地址,告訴指令解析器,接下來的是一個指令
IIC_Wait_Ack();
IIC_Send_Byte(IIC_Command); //寫命令
IIC_Wait_Ack();
IIC_Stop();
}
/****************************************************************************
*函數名稱:bit OLED12864_Write_Commmand(unsigned char cmd, bit start, bit stop)
*函數功能:寫指令函數,第一個參數為指令,第二、三個參數選擇是否需要通信開始和結束函數,=1有,=0沒有
*輸入: unsigned char IIC_Command
*輸出: 無
*****************************************************************************/
/***************/
/*****************************************************
bit OLED12864_Write_Commmand(unsigned char cmd, bit start, bit stop)
{
if(start)
{
IIC_Start(); //啟動I2C
IIC_Send_Byte(IIC_OLED_ADDR_W);//寫從機地址,并且加上讀寫標志位(最后一位)
if(!Test_ack())
{
return 0;
} //執行從機應答檢測函數,如果從機發送了非應答信號,那么就退出數據發送函數
}
}
**********************************************************/
/*********************************************************
unsigned char OLED_Write_Command(unsigned char IIC_Command)
{
I2C_Start(); //啟動I2C
IIC_Send_Byte(I2C_OLED_ADDR_W); //D/C #=0; R/W #=0;寫IIC器件地址
if(IIC_Wait_Ack())
return 1;
IIC_Send_Byte(0x00); // 告訴指令解析器,接下來的是一個指令
if(IIC_Wait_Ack())
return 2;
IIC_Send_Byte(IIC_Command); //寫命令
if(IIC_Wait_Ack())
return 3;
I2C_Stop();
return 0;
}
***********************************************************/
/****************************************************************************
*函數名稱:unsigned char OLED_Write_Data(unsigned char IIC_Data)
*函數功能:寫OLED數據; 此函數實測OK
*輸入: unsigned char IIC_Data
*輸出: 無
*****************************************************************************/
/***************/
void OLED_Write_Data(unsigned char IIC_Data)
{
IIC_Start(); //啟動I2C
IIC_Send_Byte(IIC_OLED_ADDR_W); //D/C #=0; R/W #=0;寫IIC器件地址
IIC_Wait_Ack();
IIC_Send_Byte(0x40); //寄存器地址告訴指令解析器,接下來的是一個數據
IIC_Wait_Ack();
IIC_Send_Byte(IIC_Data); //寫數據
IIC_Wait_Ack();
IIC_Stop();
}
/*****************************************************
static unsigned char OLED_Write_Data(unsigned char IIC_Data)
{
I2C_Start(); //啟動I2C
IIC_Send_Byte(I2C_OLED_ADDR_W); //D/C #=0; R/W #=0;寫IIC器件地址
if(IIC_Wait_Ack());
return 1;
IIC_Send_Byte(0x40); //告訴指令解析器,接下來的是一個指令
if(IIC_Wait_Ack());
return 2;
IIC_Send_Byte(IIC_Data); //寫數據
if(IIC_Wait_Ack());
return 3;
I2C_Stop();
return 0;
}
*******************************************************/
/****************************************************************************
*函數名稱:void OLED_SetCursor(unsigned char x,unsigned char y)
*函數功能:設置行列的起始地址位置;此函數實測OK
*輸入: unsigned char x,unsigned char y;;// x列,y行
*輸出: 無
*****************************************************************************/
/***************/
void OLED_SetCursor(unsigned char x,unsigned char y)// x列,y行
{
//x += 4;
OLED_Write_Command(0xb0|y); //y就是第y頁,也就是第y行
OLED_Write_Command(((x&0xf0)>>4)|0x10); //x的高4位
OLED_Write_Command((x&0x0f)); //x的低4位
// OLED_Write_Command((x&0x0f)|0x01);
//列起始地址由指令0x1m和0x0n來確定,m是高四位,n是低四位,使用12864,則m,n合起來的8位數數值范圍在0-127之間
}
/****************************************************************************
*函數名稱:void OLED_Clear(void)
*函數功能:OLED清屏函數,復位清屏;;此函數實測OK
*輸入: 無
*輸出: 無
*****************************************************************************/
/***************/
void OLED_Clear(void)
{
unsigned char x,y;
for(y=0;y<Y_HIGH/8;y++) //OLED_HIGH=8*8
{
OLED_Write_Command(0xb0+y); // 從0 ~ 7頁依次寫入
OLED_Write_Command(0x00); // 低位列地址
OLED_Write_Command(0x10); // 高位列地址
for(x=0; x<X_WIDTH; x++) //OLED_WIDTH=128
OLED_Write_Data(0x00);
}
}
/****************************************************************************
*函數名稱:void OLED_Fill(unsigned char bmp_dat)
*函數功能:OLED全屏函數, 此函數實測OK
*輸入: unsigned char bmp_dat, 0XFF為全屏亮,0X00為全屏滅
*輸出: 無
*****************************************************************************/
/***************/
void OLED_Fill(unsigned char bmp_dat)
{
unsigned char x,y;
for(y=0;y<Y_HIGH/8;y++) //OLED_HIGH=8*8
{
OLED_Write_Command(0xb0+y);
OLED_Write_Command(0x00);
OLED_Write_Command(0x10);
for(x=0; x<X_WIDTH; x++)//OLED_WIDTH=128
OLED_Write_Data(bmp_dat);
}
}
/****************************************************************************
*函數名稱:void OLED_ON(void)
*函數功能:打開顯示
*輸入: 無
*輸出: 無
*****************************************************************************/
/***************/
/*********
void OLED_ON(void)
{
OLED_Write_Command(0x8D); //設置電荷泵
OLED_Write_Command(0x14); //開啟電荷泵
OLED_Write_Command(0xAF); //oled喚醒
}
*****************/
/****************************************************************************
*函數名稱:void OLED_OFF(void)
*函數功能:打開顯示
*輸入: 無
*輸出: 無
*****************************************************************************/
/***************/
/*****************
void OLED_OFF(void)
{
OLED_Write_Command(0x8D);//設置電荷泵
OLED_Write_Command(0x10); //開啟電荷泵
OLED_Write_Command(0xAE); //oled休眠
}
********************/
/****************************************************************************
*函數名稱:void OLED_Init(void)
*函數功能:OLED12864初始化,此函數實測OK
*輸入: 無
*輸出: 無
*****************************************************************************/
/***************/
void OLED_Init(void)
{
//IIC_Init(); //iic初始化SDA,SCL的IO口的函數,可要可不要
delay_ms(100); //從上電到下面開始初始化要有足夠的時間,即等待RC復位完畢
/* Init LCD */
//A3H,垂直滾動區域,A是固定區域的頂行號,B是行數
OLED_Write_Command(0xAE); //0xAE為SSD1306關閉顯示,
OLED_Write_Command(0x20); //設置存儲地址的模式,水平、豎直、頁、[無效],四種,復位頁模式
OLED_Write_Command(0x10); //00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid(無效)
OLED_Write_Command(0xB0); //設置頁地址,0-7
OLED_Write_Command(0x00); //設置起始列地址的低位,00H~0F,只在頁地址模式有效
OLED_Write_Command(0x10); //設置起始列地址的高位,10H~1F,只在頁地址模式有效
OLED_Write_Command(0x40); //設置顯示的起始行,(0x00~0x3F),40H~7FH總共64行
OLED_Write_Command(0x81); //設置對比度控制,實際取值是A[] + 1
OLED_Write_Command(Brightness); // 這里Brightness=0xcf,Set SEG Output Current Brightness, 256
OLED_Write_Command(0xA1); //設置段(SEG)重映射,A0H/A1H,A1H是列翻轉, 0xa0左右反置 0xa1正常
OLED_Write_Command(0xC8); //設置COM輸出掃描方向C0H/C8H,C8H是行反轉。 0xc0上下反置 0xc8正常,// 重映射模式,COM[N-1]~COM0掃描
OLED_Write_Command(0xA6); //設置反白顯示,A6h --- “1”點亮像素點,//A7h --- “0”點亮像素點,A6H/A7H,0xa7逆顯示,
OLED_Write_Command(0xA4); //A4/A5設置全局顯示,A5H強制全局顯示
OLED_Write_Command(0xA8); //設置驅動路數,起始也就是命令為0xA8,參數取值16~63,效果是垂直方向顯示的范圍
OLED_Write_Command(0x3F); //// 64duty
OLED_Write_Command(0xD3); //設置顯示偏移,圖像豎直向上偏移,復位是00H,(0x00~0x3F)
OLED_Write_Command(0x00); // 無偏移
OLED_Write_Command(0xD5); //設置震蕩器分頻,默認值80H
OLED_Write_Command(0xF0); //--set divide ratio
OLED_Write_Command(0xD9); //設置預充電周期,同步亮度的,復位22H
OLED_Write_Command(0x22); //默認值22H,官方推薦值0xF1,/將預充電設置為15個時鐘加上其放電設置為1個時鐘
OLED_Write_Command(0xDA); //設置COM引腳硬件配置,復位是12H,加上重映射總共八種玩法,
OLED_Write_Command(0x12); //使用默認值
OLED_Write_Command(0xDB); //設置Vcomh取消選擇等級,可調節亮度(默認)
OLED_Write_Command(0x20); //默認值0x20,0x00:0.65*Vcc,0x10:0.71*Vcc,0x20:0.77*Vcc,0x30:0.83*Vcc
OLED_Write_Command(0x8D); //電荷泵設置,復位是0B,啟用電荷泵需要配置成1B
OLED_Write_Command(0x14); //開顯示 set(0x10) disable
OLED_Write_Command(0xAF); //0xAF為SSD1306打開顯示
//OLED_Fill(0x00); //初始屏幕填充數據0
//OLED_SetCursor(0,0); //
OLED_Clear();//初始必須清屏
}
/****************************************************************************
*函數名稱:void OLED_P6x8Str(unsigned char x, y,unsigned char ch[]);此函數實測OK
*函數功能:顯示6*8一組標準寬度x高度=6x8,ASCII字符串 顯示的坐標(x,y),x為列范圍,y為頁范圍0~7*
*輸入: unsigned char x, x為列,unsigned char y,y為行, unsigned char ch[]為字體數組
*輸出: 無
*****************************************************************************/
/***************/
void OLED_P6x8Str(unsigned char x, y,unsigned char ch[])
{
unsigned char c=0,i=0,j=0;
while (ch[j]!='\0')
{
c =ch[j]-32; //減去前面字符串有32個字符,第33個字符為A
if(x>126){x=0;y++;}
OLED_SetCursor(x,y);
for(i=0;i<6;i++) //寫6列數據
OLED_Write_Data(OLED_F6x8[c][i]);//如果要顯示第1個6列,則為
x+=6; //列數+6
j++; //行數加1
}
}
//每行顯示數據:生成數組的大小,字符的長(頁)x字符的寬(如8*16字體,2頁*8列 = 16;如12*24字體,3頁*12列 = 36;如16*32字體,4頁*16列 = 64)
/****************************************************************************
*函數名稱:void OLED_Font8x16Str(unsigned char x, unsigned char y, unsigned char ch[])
*函數功能:顯示8*16一組標準ASCII字符串, 顯示的坐標(x,y),y為頁范圍0~7;;此函數實測OK
*輸入: unsigned char x, x為列,unsigned char y,y為行, unsigned char ch[]為字體數組
*輸出: 無
*****************************************************************************/
/***************/
void OLED_P8x16Str(unsigned char x, unsigned char y, unsigned char ch[])
{
unsigned char c=0,i=0,j=0;
while (ch[j] != '\0')
{
c = ch[j]-32;
if (x>120)
{
x = 0;
y++;
}
OLED_SetCursor(x,y);
for(i=0;i<8;i++)
OLED_Write_Data(OLED_F8x16[c*16+i]);
OLED_SetCursor(x,y+1);
for(i=0; i<8; i++)
OLED_Write_Data(OLED_F8x16[c*16+i+8]);
x+=8;
j++;
}
}
/*****************************************************************************************************
*函數名稱:void OLED_ShowStr(unsigned char x,unsigned char y,unsigned char *chr,unsigned char TextSize)
*函數功能:顯示字符串函數,包括了OLED_P6x8Str(),OLED_P8x16Str()兩個函數.
*使用方法:只需更改后面的TextSize的值,字符大小(1:6*8 ; 2:8*16)
*輸入: unsigned char x,unsigned char y,unsigned char *chr,unsigned char TextSize)
* : x,y:起點坐標,x為0-127列,y為頁0-7,*chr:為要顯示的字符串
* TextSize為字號可以填入1與2,當填入1時,函數調用的為codetab.h中的6*8點陣數組,當填入2時調用的是8*16點陣數組。
* 所謂6*8,8*16就是在oled上占格的大小,oled分辨率為64*128,所以在應用時要計算好格數,以免oled上顯示不全
* 如果 TextSize為1則為6*8,為2,則為8*16
*輸出: 無
********************************************************************************************************/
/***************/
void OLED_ShowStr(unsigned char x, unsigned char y, unsigned char ch[], unsigned char TextSize)
{
unsigned char c = 0,i = 0,j = 0;
switch(TextSize)
{
case 1:
{
while(ch[j] != '\0')
{
c = ch[j] - 32;
if(x > 126)
{
x = 0;
y++;
}
OLED_SetCursor(x,y);
for(i=0;i<6;i++)
OLED_Write_Data(OLED_F6x8[c][i]);
x += 6;
j++;
}
}break;
case 2:
{
while(ch[j] != '\0')
{
c = ch[j] - 32;
if(x > 120)
{
x = 0;
y++;
}
OLED_SetCursor(x,y);
for(i=0;i<8;i++)
OLED_Write_Data(OLED_F8x16[c*16+i]);
OLED_SetCursor(x,y+1);
for(i=0;i<8;i++)
OLED_Write_Data(OLED_F8x16[c*16+i+8]);
x += 8;
j++;
}
}break;
}
}
/*****************************************************************************************************
*函數名稱:void OLED_ShowChinese(unsigned char x, unsigned char y, unsigned char Num)
*函數功能:顯示 bsp_font.h 中的16*16點陣漢字(宋體), 此函數實測OK
*輸入: unsigned char Line, unsigned char Column, unsigned char Num
y:起始點行坐標:0 ~ 7,x:起始點列坐標:0 ~127,Num為第幾個字
*輸出: 無
********************************************************************************************************/
/***************/
/****************************
void OLED_P16x16Ch(unsigned char x, unsigned char y, unsigned int Num)
{
unsigned char i=0;
unsigned int wide = 32*Num; //字寬
OLED_SetCursor(x,y); //參數2:把光標設置在第幾頁. 參數1:把光標設置在第幾列
for (i = 0; i < 16; i++)
{
OLED_Write_Data(OLED_F16x16[wide]); //顯示上半部分內容
wide+=1;
}
OLED_SetCursor(x,y+1); //參數2:把光標設置在第幾頁. 參數1:把光標設置在第幾列
for (i = 0; i < 16 ; i++)
{
OLED_Write_Data(OLED_F16x16[wide]); //顯示下半部分內容
wide+=1;
}
}
******************************
/*****************************************************************************************************
*函數名稱:void OLED_P16x16Ch(unsigned char x, unsigned char y, unsigned char Num)
*函數功能:顯示 bsp_font.h 中的漢字(宋體)
*輸入: unsigned char Line, unsigned char Column, unsigned char Num
y:起始點行坐標:1 ~ 8, x:起始點列坐標:1 ~8,Num為第幾個字
*輸出: 無
********************************************************************************************************/
/***************/
void OLED_P16x16Ch(unsigned char x, unsigned char y, unsigned char Num)
{
unsigned char i=0;
unsigned char wide = 16; //字寬,如:16x16字體,32x32字體,
OLED_SetCursor((x-1)*wide,(y-1)); //參數1:把光標設置在第幾列,參數2:把光標設置在第幾頁.
for (i = 0; i < wide; i++)
{
OLED_Write_Data(OLED_F16x16[Num][i]); //顯示上半部分內容
}
OLED_SetCursor((x-1)*wide,(y-1)+1); //參數2:把光標設置在第幾頁. 參數1:把光標設置在第幾列
for (i = 0; i < wide ; i++)
{
OLED_Write_Data(OLED_F16x16[Num][i+wide]); //顯示下半部分內容
}
}
/****************************************************************************
*函數名稱:void OLED_ShowCHinese(unsigned char x,unsigned char y,unsigned char no,unsigned char font_width,unsigned char font_height)
*函數功能: 顯示任意大小漢字
******** x1,y1 -- 起點對角線(結束點)的坐標(x1:0~127,y1:0~7)
*輸入: unsigned char x, x為列,unsigned char y,y為行, unsigned char ch[]為字體數組,
* : *no: 表示要顯示的漢字(模組)在hzk[][]數組中的行號,通過行號來確定在數組中要顯示的漢字
* 這里字體的寬font_width的值必須與用字模制作軟件生成字模時的點陣值大小一致
* font_height的值為用字模制作軟件生成字模時字體的高,由于我的屏像素為32*128-----0~7共8頁,每頁4個位
*輸出: 無
*****************************************************************************/
/***************/
void OLED_ShowCHinese(unsigned char x,unsigned char y,unsigned char no,unsigned char font_width,unsigned char font_height)
{
unsigned char t, i;
for(i=0;i<(font_height/8);i++) /*font_height最大值為32,這張屏只有8個頁(行),每頁4個位*/
{
OLED_SetCursor(x,y+i);
for(t=0;t<font_width;t++) /*font_width最大值為128,屏幕只有這么大*/
{
//OLED_Write_Data(OLED_F32x32[(font_height/8)*no+i][t]);
if((font_width==16)&(font_height==16)) //16x16字體
{
OLED_Write_Data(OLED_F16x16[no][font_width*i+t]);
}
else if((font_width==32)&(font_height==16)) //32x16字體
{
OLED_Write_Data(OLED_F32x16[no][font_width*i+t]);
}
else if((font_width==32)&(font_height==32)) //32x32字體
{
OLED_Write_Data(OLED_F32x32[no][font_width*i+t]);
}
else if((font_width==64)&(font_height==32)) //64x32字體
{
OLED_Write_Data(OLED_F64x32[no][font_width*i+t]);
}
else if((font_width==64)&(font_height==64)) //64x64字體
{
OLED_Write_Data(OLED_F64x64[no][font_width*i+t]);
}
}
}
}
/****************************************************************************
*函數名稱:void OLED_DrawBMP(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, unsigned char BMP[])
*函數功能:顯示顯示BMP圖片128×64起始點坐標(x0, y0),x的范圍0~127,y為頁的范圍0~7
******** x1,y1 -- 起點對角線(結束點)的坐標(x1:0~127,y1:0~7)
*輸入: unsigned char x, x為列,unsigned char y,y為行, unsigned char ch[]為字體數組
*輸出: 無
*****************************************************************************/
/***************/
void OLED_DrawBMP(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, unsigned char BMP[])
{
unsigned int j=0;
unsigned char x, y;
if(y1%8 == 0)
y = y1/8;
else
y = y1/8+1;
for (y=y0; y<y1; y++)
{
OLED_SetCursor(x0,y);
for(x=x0; x<x1; x++)
{
OLED_Write_Data(BMP[j++]);
}
}
}
/*****************************************************************************************************
*函數名稱:void OLED_ShowChinese(unsigned char Line, unsigned char Column, unsigned char Num)
*函數功能:顯示 bsp_font.h 中的漢字(宋體)
*輸入: unsigned char Line, unsigned char Column, unsigned char Num
Line:起始點行坐標:0 ~ 7,Column:起始點列坐標:0 ~127
*輸出: 無
********************************************************************************************************/
/***************/
/***************************************
void OLED_ShowChinese(unsigned char Line, unsigned char Column, unsigned char Num)
{
unsigned char i=0;
unsigned char wide = 32; //字寬
OLED_SetCursor(( Line - 1 ) * 2, ( Column - 1 )* wide); //參數1:把光標設置在第幾頁. 參數2:把光標設置在第幾列
for (i = 0; i < wide; i++)
{
OLED_Write_Data(OLED_F16x16[Num][i]); //顯示上半部分內容
}
OLED_SetCursor(( Line - 1 ) * 2 + 1,( Column - 1) * wide);
for (i = 0; i < wide ; i++)
{
OLED_Write_Data(OLED_F16x16[Num][i+wide]); //顯示下半部分內容
}
}
****************************************/
/**
* 描述:顯示6*8一組標準ASCII字符串,顯示的坐標(x,y),y為頁范圍0~7
*/
/****************************************************************************
*函數名稱:void OLED_Font6x8Str(unsigned char x, unsigned char y, unsigned char ch[])
*函數功能:顯示6*8一組標準ASCII字符串, 顯示的坐標(x,y),y為頁范圍0~7
*輸入: unsigned char x, x為列,unsigned char y,y為行, unsigned char ch[]為字體數組
*輸出: 無
*****************************************************************************/
/***************/
/****************************
void OLED_Font6x8Str(unsigned char x, unsigned char y, unsigned char ch[])
{
unsigned char c=0, i=0, j=0;
while (ch[j] != '\0')
{
c = ch[j]-32;
if(x>126) {x=0; y++;}
OLED_SetCursor(x,y);
for(i=0; i<6; i++)
OLED_Write_Data(F6x8[c][i]);
x += 6;
j++;
}
}
**************************/
#endif
復制代碼
原理圖: 無
仿真: 無
STC15F2K60S2單片機完整Keil代碼工程文件下載:
STC15F2K60S2 OLED12864任意位置顯示字符和漢字.zip
(93.21 KB, 下載次數: 48)
2024-5-4 08:09 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
yechuan220
時間:
2024-8-23 09:48
謝謝樓主分享,我還在學習中
作者:
cooleaf
時間:
2024-8-27 14:57
謝謝樓主分享
作者:
wkman
時間:
2024-8-30 16:51
注釋很詳細很重要! ssd1306本身支持多種總線驅動方式
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1