〖說明〗標準8段數碼管驅動程序不用使用者更改另外送多個時序函數,還有贈送按鍵掃描及兩鍵驅動程序,全中文提示使用更方便快捷 http://www.mcuzb.com 坐標網時時更新為您的工作帶來方便。 默認11.0592Mhz的晶振。 —————————————————————*/ #include <reg51.h> /*-------------------------------------------- 調用方式:自行I/O 口定義﹫2001/05/12 函數說明:私有函數,各接口定義 --------------------------------------------*/ sbit HD7279_CS=P1^4; // HD7279_CS--P1.4 sbit HD7279_CLK=P1^5; // HD7279_CLK-- P1.5 sbit HD7279_DATA=P1^6; // HD7279_DATA-- P1.2 sbit HD7279_KEY =P1^7; // HD7279_KEY-- P1.3 /*-------------------------------------------- 調用方式: HD7279A 各指令定義﹫2001/05/12 函數說明:私有函數,接口定義 --------------------------------------------* /#define HD7279_RESET 0xa4 //復位 #define HD7279_TEST 0xbf //測試 #define HD7279_RLC 0xa3 //循環左移 #define HD7279_RRC 0xa2 //循環右移 #define HD7279_RL 0xa1 //左移 #define HD7279_RR 0xa0 //右移 #define HD7279_DECODE0 0x80 //譯碼方式0 #define HD7279_DECODE1 0xc8 //譯碼方式1 #define HD7279_UNDECODE 0x90 //譯碼方式2: 不譯碼 #define HD7279_HIDE 0x98 //消隱 #define HD7279_FLASH 0x88 //閃爍 #define HD7279_SEGON 0xe0 //段亮 #define HD7279_SEGOFF 0xc0 //段滅 #define HD7279_READ 0x15 //讀 /*-------------------------------------------- 調用方式: void HD7279_LongDelay(void) 等侍函數﹫2001/05/12 函數說明 私有函數,>500ms --------------------------------------------*/ void HD7279_LongDelay(void) { unsigned char i; for (i=0;i<6;i++); } /*-------------------------------------------- 調用方式:void HD7279_ShortDelay(void) 等侍函數﹫2001/05/12 函數說明:私有函數,=500ms --------------------------------------------* /void HD7279_ShortDelay(void) {;} /*-------------------------------------------- 調用方式:void Delay10ms(unsigned char time) 等侍函數﹫2001/05/12 函數說明:私有函數, 6M晶振 --------------------------------------------*/ void Delay10ms(unsigned char time) { unsigned char i; unsigned int j; for(i=0;i<time;i++) { for(j=0;j<931;j++) {;} } } /*-------------------------------------------- 調用方式:void HD7279_ShortDelay(void) 函數﹫2001/05/12 函數說明:私有函數,送指令 --------------------------------------------*/ void HD7279_SendByte( unsigned char out_byte) { unsigned char i; HD7279_CS=0; HD7279_LongDelay(); for(i=0;i<8;i++) { if(out_byte&0x80) { HD7279_DATA=1; } else { HD7279_DATA=0; } HD7279_CLK=1; HD7279_ShortDelay(); HD7279_CLK=0; HD7279_ShortDelay(); out_byte=out_byte<<1; } HD7279_DATA=0; } /*-------------------------------------------- 調用方式:void Write7279(unsigned char command, unsigned char dta) 函數﹫2001/05/12 函數說明:私有函數,寫函數 --------------------------------------------*/ void Write7279(unsigned char command, unsigned char dta) { HD7279_SendByte( command ); HD7279_SendByte( dta ); } /*-------------------------------------------- 調用方式:自定義函數﹫2001/05/12 函數說明:私有函數,自行定義 --------------------------------------------*/ #define RunKey 0xXX #define StopKey 0xXX /*-------------------------------------------- 調用方式:unsigned char HD7279_ReceiveByte(void)函數﹫2001/05/12 函數說明:私有函數,接受一個BYTE函數 --------------------------------------------*/ unsigned char HD7279_ReceiveByte(void) { unsigned char i, in_byte; HD7279_DATA=1; HD7279_LongDelay(); for(i=0;i<8;i++) {HD7279_CLK=1; HD7279_ShortDelay(); in_byte=in_byte<<1; if(HD7279_DATA) { in_byte=in_byte|0x01; } HD7279_CLK=0; HD7279_ShortDelay(); } HD7279_DATA=0; return (in_byte); } /*-------------------------------------------- 調用方式:unsigned char HD7279_GetKey()函數﹫2001/05/12 函數說明:私有函數,讀鍵盤函數 --------------------------------------------*/ unsigned char HD7279_GetKey() { unsigned char key; if(!HD7279_KEY) { HD7279_SendByte(HD7279_READ); key=HD7279_ReceiveByte(); switch( key ) {case RunKey: case StopKey: while(!HD7279_KEY); default: return(0xff); } } return(0xff); } /*-------------------------------------------- 調用方式:main()函數﹫2001/05/12 函數說明:私有函數,例函數 --------------------------------------------*/
main() {HD7279_SendByte(0xa4);//復位 Write7279(0x80,0)//顯示‘0’ }
function ImgZoom(Id)//重新設置圖片大小 防止撐破表格
{
var w = $(Id).width;
var m = 488;
if(w < m)
{
return;
}
else
{
var h = $(Id).height;
$(Id).height = parseInt(h*m/w);
$(Id).width = m;
}
}
window.onload = function()
{
var Imgs = $("content").getElementsByTagName("img");
var i=0;
for(;i
|