?? 12864指針式時鐘.txt
字號:
/*-- 宋體12; 此字體下對應的點陣為:寬x高=8x16 --*/
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,
/*-- 文字: . 11 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=8x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: -- 12 (空白) */
/*-- 宋體12; 此字體下對應的點陣為:寬x高=8x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 箭頭 13 --*/
/*-- 寬度x高度=8x16 --*/
0x00,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,
/*-- 文字: - 14 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=8x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
/*-- 文字: , 15 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=8x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,
/*-- 箭頭 16 --*/
/*-- 寬度x高度=8x16 --*/
0x00,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,
/*-- 箭頭(向上) 17 --*/
/*-- 寬度x高度=8x16 --*/
0x10,0x18,0x1C,0xFE,0xFE,0x1C,0x18,0x10,0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,
/*-- 文字: ! 18 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=8x16 --*/
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,
/*-- 文字: > 19 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=8x16 --*/
0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,
/*-- 箭頭(向下) 20 --*/
/*-- 寬度x高度=8x16 --*/
0x00,0x00,0x00,0xFC,0xFC,0x00,0x00,0x00,0x08,0x18,0x38,0x7F,0x7F,0x38,0x18,0x08,
};
//指針時鐘坐標
const unsigned char sec_x[] PROGMEM={
32,35,38,41,43,
45,48,50,52,54,
56,58,59,60,60,
60,60,60,59,58,
56,54,52,50,48,
45,43,41,38,35,
32,29,26,23,21,
19,16,14,12,10,
8,6,5,4,4,
4,4,4,5,6,
8,10,12,14,16,
19,21,23,26,29,
};
const unsigned char sec_y[] PROGMEM={
4,4,4,5,6,
8,10,12,14,16,
19,21,23,26,29,
32,35,38,41,43,
45,48,50,52,54,
56,58,59,60,60,
60,60,60,59,58,
56,54,52,50,48,
45,43,41,38,35,
32,29,26,23,21,
19,16,14,12,10,
8,6,5,4,4,
};
const unsigned char min_x[] PROGMEM={
32,34,36,38,40,
41,42,44,46,48,
49,50,51,52,53,
54,53,52,51,50,
49,46,45,44,42,
40,39,38,37,35,
32,29,27,26,25,
24,22,20,19,18,
15,14,13,12,11,
10,11,12,13,14,
15,16,18,20,22,
23,24,26,28,30,
};
const unsigned char min_y[] PROGMEM={
10,10,10,11,13,
14,15,17,19,21,
23,24,26,28,30,
32,34,36,38,40,
41,44,45,46,48,
49,50,51,52,53,
54,53,52,51,50,
49,48,46,45,44,
41,40,38,36,34,
32,30,28,26,24,
23,21,19,17,15,
14,13,11,10,10,
};
const unsigned char hour_x[] PROGMEM={
32,38,44,47,44,38,
32.26,20,15,20,26,
};
const unsigned char hour_y[] PROGMEM={
17,19,26,32,38,45,
47,45,38,32,26,19,
};
/****************************************************************************
函 數 名:Delay()
功 能: 軟件延時
說 明: 無
入口參數:count
返 回 值:無
*****************************************************************************/
void Delay(unsigned int count)
{
unsigned char i;
while(--count != 0)
{
for(i = 0; i < 100; i++)
{
;
}
}
}
/****************************************************************************
函 數 名:LCM12864_E()
功 能:LCM12864使能
說 明: 無
入口參數:無
返 回 值:無
*****************************************************************************/
void LCM12864_E(void)
{
CBI_E;
_delay_us(10);
SBI_E;
}
/*********************************************************************************************
定義LCM12864的指令
*********************************************************************************************/
#define LCM12864_DISP_ON 0x3f // 打開LCM12864顯示
#define LCM12864_DISP_OFF 0x3e // 關閉LCM12864顯示
#define LCM12864_START_ROW 0xc0 // 顯示起始行0,可以用LCM12864_START_ROW+x設置起始行。(x<64)
#define LCM12864_PAGE_START_ADDR 0xb8 // 頁起始地址,可以用LCM12864_PAGE_START_ADDR+x設置當前頁。(x<8)
#define LCM12864_COL_START_ADDR 0x40 // 列起始地址,可以用LCM12864_COL_START_ADDR+x設置當前列。(x<64)
//定義LCM12864的狀態屏蔽碼
//在BUSY和REST狀態時,除讀狀態指令外,其他指令均不對LCM12864產生作用。
//在對LCM12864操作之前要查詢BUSY狀態,以確定是否可以對LCM12864進行操作。
#define LCM12864_STATUS_BUSY 0x80 // LCM12864忙狀態屏蔽碼
#define LCM12864_STATUS_DISP_OFF 0x20 // LCM12864顯示關閉狀態屏蔽碼
#define LCM12864_STATUS_REST 0x10 // LCM12864復位狀態屏蔽碼
/****************************************************************************
函 數 名:LCM12864_TestBusy()
功 能:LCM12864測忙
說 明: 無
入口參數:無
返 回 值:無
*****************************************************************************/
void LCM12864_TestBusy(void)
{
DDRA=0x7f;
SBI_RW;
CBI_RS;
LCM12864_E();
while(LCM12864_indatabus & LCM12864_STATUS_BUSY);
DDRA=0xff;
}
/****************************************************************************
函 數 名:LCM12864_WriteCMD()
功 能:寫命令到LCM12864
說 明: 無
入口參數:LCM12864_data 欲寫入命令
返 回 值:無
*****************************************************************************/
void LCM12864_WriteCMD(unsigned char LCM12864_command) //LCM12864_command 欲寫入指令
{
LCM12864_TestBusy();
CBI_RW;
CBI_RS;
LCM12864_databus = LCM12864_command;
LCM12864_E();
}
/****************************************************************************
函 數 名:LCM12864_WriteData()
功 能:寫數據到LCM12864
說 明: 無
入口參數:LCM12864_data 欲寫入數據
返 回 值:無
*****************************************************************************/
void LCM12864_WriteData(unsigned char LCM12864_data) //LCM12864_command 欲寫入數據
{
LCM12864_databus = LCM12864_data;
CBI_RW;
SBI_RS;
LCM12864_E();
}
/****************************************************************************
函 數 名:LCM12864_ReadData()
功 能:LCM12864讀數據
說 明: 無
入口參數:無
返 回 值:LCM12864_data 讀出數據
*****************************************************************************/
unsigned char LCM12864_ReadData(void)
{
unsigned char LCM12864_data;
DDRA=0x00;
PORTA=0xff;
CBI_E;
SBI_RW;
SBI_RS;
Delay(10);
SBI_E;
Delay(10);
LCM12864_E();
Delay(10);
LCM12864_data = LCM12864_indatabus; //讀出8位數據
LCM12864_TestBusy(); //讀LCM忙
DDRA=0xff;
return LCM12864_data;
}
/****************************************************************************
函 數 名:LCM12864_Fill_Screen()
功 能:LCM12864全屏填充數據
說 明: 無
入口參數:t,LCM12864_FillData
返 回 值:無
*****************************************************************************/
void LCM12864_Fill_Screen( unsigned char t, //設置寫入速度
unsigned char LCM12864_FillData) //欲寫入的數據
{
unsigned char x,y;
CBI_CS1;CBI_CS2; // 選中左右半屏
LCM12864_WriteCMD(LCM12864_START_ROW+0); // 設置顯示起始行為0
for(x=0;x<8;x++)
{
Delay(t); // 寫入延時
LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+x); // 設置頁地址
LCM12864_WriteCMD(LCM12864_COL_START_ADDR);// // 設置列地址
for(y=0;y<64;y++)
{
LCM12864_WriteData(LCM12864_FillData);
}
}
SBI_CS1; // 不選中左右半屏
SBI_CS2;
}
/****************************************************************************
函 數 名:LCM12864_Clear_Screen()
功 能:LCM12864清屏
說 明: 無
入口參數:無
返 回 值:無
*****************************************************************************/
void LCM12864_Clear_Screen(void)
{
LCM12864_Fill_Screen(10,0x00); //寫入0到每個顯示區
}
/****************************************************************************
函 數 名:LCM12864_Disp_Char_x_16()
功 能:在LCM12864的指定點顯示點陣漢字16*16或8*16
說 明: 無
入口參數:t,b,Lcm12864_page,Lcm12864_col,x
返 回 值:無
*****************************************************************************/
void LCM12864_Disp_Char_x_16(unsigned char t, //設置寫入速度(為1直接顯示)
unsigned char b, //輸入8:8*16字符,16:16*16字符
unsigned char LCM12864_page, //LCM12864的頁地址(0~7)
unsigned char LCM12864_col, //LCM12864的列地址(0~128)注意:右半屏起始是64
unsigned char x) //16*16點陣漢字字模(縱向取模,字節倒序)
{
unsigned char j=0,i=0,data;
if(LCM12864_col < 64 )
{
CBI_CS1;
SBI_CS2; //判斷屏幕使能
}
else
{
SBI_CS1;
CBI_CS2;
LCM12864_col = LCM12864_col - 64;
}
if(b==16)
{
for(j=0;j<2;j++)
{
LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+LCM12864_page+j);
LCM12864_WriteCMD(LCM12864_COL_START_ADDR+LCM12864_col);
for(i=0;i<b;i++)
{
data=pgm_read_byte(hanzi+x*32+b*j+i);
LCM12864_WriteData(data);
_delay_us(t);
}
}
}
else
{
for(j=0;j<2;j++)
{
LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+LCM12864_page+j);
LCM12864_WriteCMD(LCM12864_COL_START_ADDR+LCM12864_col);
for(i=0;i<b;i++)
{
data=pgm_read_byte(shuzi+x*16+b*j+i);
LCM12864_WriteData(data);
_delay_us(t);
}
}
}
}
/********************************************************************
函 數 名:void LCM12864_dot()
功 能:畫點
說 明:在12864屏的指定位置畫一個點
mode=0 畫一個點
mode=1 清除一個點
mode=2 反白顯示一個點
入口參數:x : x座標
y : y座標
mode
返 回 值:無
***********************************************************************/
void LCM12864_dot(unsigned char x,unsigned char y,unsigned char mode)
{
unsigned char temp_y,read_data;
temp_y = y%8;
if(x<64)
{
CBI_CS1; SBI_CS2; //判斷屏幕位置
}
else
{
SBI_CS1; CBI_CS2;
x-=64;
}
LCM12864_WriteCMD(LCM12864_COL_START_ADDR+x);
LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+(y/8));
read_data=LCM12864_ReadData();
switch(mode)
{
case 0:
read_data|=(0x01<<temp_y);
break;
case 1:
read_data&=~(0x01<<temp_y);
break;
case 2:
read_data^=(0x01<<temp_y);
break;
}
LCM12864_WriteCMD(LCM12864_COL_START_ADDR+x);
LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+(y/8));
LCM12864_WriteData(read_data);
}
/********************************************************************
函 數 名:line()
功 能:畫線
說 明:在12864屏上畫直線或清除
入口參數:x,y,tx,ty,xe,ye,incx,incy,dist,xerr,yerr,t
返 回 值:無
**********************************************************************/
void line(unsigned char tx,unsigned char ty,unsigned char xe,unsigned char ye,unsigned mode)
{
unsigned char xerr,yerr,t,dist;
signed char incx,incy;
if(xe>tx)
incx=2;
if(xe<tx)
incx=0;
if(xe==tx)
incx=1;
if(ye>ty)
incy=2;
if(ye<ty)
incy=0;
if(ye==ty)
incy=1;
if(xe>=tx&&ye<ty) //第一象限
{
xe=xe-tx;
ye=ty-ye;
}
else
{
if(xe>tx&&ye>=ty) //第二象限
{
xe=xe-tx;
ye=ye-ty;
}
else
{
if(tx>xe&&ye>ty)
{
xe=xe-tx;
ye=ye-ty;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -