?? rd_uselcdsp027.c
字號:
/***********************************************************
* 函數庫說明:SP-027液晶段碼顯示器驅動函數庫 *
* 版本: v1.00 *
* 作者: 王卓然 *
* 創建日期: 2006年5月11日 *
* -------------------------------------------------------- *
* [支 持 庫] *
* 支持庫名稱:RD_UseLCDPS027.h *
* 需要版本: v1.00 *
* 支持庫說明:SP-027液晶段碼顯示器驅動函數庫 *
* -------------------------------------------------------- *
* [版本更新] *
* 修改: *
* 修改日期: *
* 版本: *
* -------------------------------------------------------- *
* [版本歷史] *
* -------------------------------------------------------- *
* [說 明] *
***********************************************************/
/********************
* 頭 文 件 配 置 區 *
********************/
# include "RD_UseLCDSP027.h"
/********************
* 系 統 宏 定 義 *
********************/
/*------------------*
* 硬 件 連 接 定 義 *
*------------------*/
#ifndef SP027_DI
#error None defined SP027 PIN: DI
#endif
#ifndef SP027_CLK
#error None defined SP027 PIN: CLK
#endif
# define SP027_NO_ICON 17
# define SP027_MID_LINE 18
# define SP027_CIRCLE 19
/********************
* 模塊變量聲明區 *
********************/
static unsigned char LCDSP027_DispBuff[5] = {0,0,0,0,0};
static unsigned char LCDSP027_DISPCODE[] = {0x09,0xcf,0x91,0x85,0x47,0x25,0x21,0x8f,0x01,0x05,
0x03,0x61,0x39,0xc1,0x31,0x33,0x29,0xff,0xf7,0x17};
/********************
* 函 數 聲 明 區 *
********************/
void Set_DISP_BUFF_SP027(char a,char b,char c,char d,char e);
void LCDSP027_refresh_DISP_BUFF(void);
void LCDSP027_Clear(void);
void LCDSP027_PrintN(int16 nNumber);
void LCDSP027_PrintU(uint16 nNumber);
/********************
* 模塊函數聲明區 *
********************/
static void LCDSP027_Send_Data(char Data);
void LCDSP027_PrintU(uint16 nNumber)
{
uint16 wAbsNUM = nNumber;
uint8 NumberA = 0;
uint8 NumberB = 0;
uint8 NumberC = 0;
uint8 NumberD = 0;
NumberD = wAbsNUM % 10;
wAbsNUM = wAbsNUM * 0.1;
NumberC = wAbsNUM % 10;
wAbsNUM = wAbsNUM * 0.1;
NumberB = wAbsNUM % 10;
wAbsNUM = wAbsNUM * 0.1;
NumberA = wAbsNUM % 10;
Set_DISP_BUFF_SP027
(
NumberA,
NumberB,
NumberC,
NumberD,
SP027_NO_ICON
);
}
void LCDSP027_PrintN(int16 nNumber)
{
uint16 wAbsNUM = ABS(nNumber);
uint8 NumberA = 0;
uint8 NumberB = 0;
uint8 NumberC = 0;
NumberC = wAbsNUM % 10;
wAbsNUM = wAbsNUM * 0.1;
NumberB = wAbsNUM % 10;
wAbsNUM = wAbsNUM * 0.1;
NumberA = wAbsNUM % 10;
if (nNumber < 0)
{
Set_DISP_BUFF_SP027
(
SP027_MID_LINE,
NumberA,
NumberB,
NumberC,
SP027_CIRCLE
);
}
else
{
Set_DISP_BUFF_SP027
(
SP027_NO_ICON,
NumberA,
NumberB,
NumberC,
SP027_CIRCLE
);
}
}
/***********************************************************
* 函數說明:顯示緩沖區設置函數 *
* 輸入: 要顯示的5個數字量(BCD) *
* 輸出: 無 *
* 調用函數:LCDSP027_refresh_DISP_BUFF() *
***********************************************************/
void Set_DISP_BUFF_SP027(char a,char b,char c,char d,char e)
{
LCDSP027_DispBuff[0] = a;
LCDSP027_DispBuff[1] = b;
LCDSP027_DispBuff[2] = c;
LCDSP027_DispBuff[3] = d;
LCDSP027_DispBuff[4] = e;
//LCDSP027_refresh_DISP_BUFF();
}
/***********************************************************
* 函數說明:刷新顯示緩沖區函數 *
* 輸入: 無 *
* 輸出: 無 *
* 調用函數:LCDSP027_Send_Data() *
***********************************************************/
void LCDSP027_refresh_DISP_BUFF(void)
{
char n = 0;
//LCDSP027_Clear();
for (n = 0;n<5;n++)
{
if (n == 2)
{
LCDSP027_Send_Data
(
LCDSP027_DISPCODE[LCDSP027_DispBuff[n]] & ~BIT(0)
);
}
else
{
LCDSP027_Send_Data(LCDSP027_DISPCODE[LCDSP027_DispBuff[n]]);
}
}
SP027_CLK = LOW;
SP027_CLK = HIGH;
}
/***********************************************************
* 函數說明:清屏函數 *
* 輸入: 無 *
* 輸出: 無 *
* 調用函數:無 *
***********************************************************/
void LCDSP027_Clear(void)
{
/*
char n = 0;
for (n = 0;n<40;n++)
{
SP027_CLK = LOW;
SP027_DI = HIGH;
SP027_CLK = HIGH;
}
*/
Set_DISP_BUFF_SP027
(
SP027_NO_ICON,
SP027_NO_ICON,
SP027_NO_ICON,
SP027_NO_ICON,
SP027_NO_ICON
);
}
/***********************************************************
* 函數說明:發送數據函數 *
* 輸入: 無 *
* 輸出: 無 *
* 調用函數:無 *
***********************************************************/
static void LCDSP027_Send_Data(char Data)
{
char n = 0;
for (n = 0;n<8;n++)
{
SP027_CLK = LOW;
if (Data<<n>>7)
{
SP027_DI = HIGH;
}
else
{
SP027_DI = LOW;
}
SP027_CLK = HIGH;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -