熱門關(guān)鍵詞: 蘇州控制板生產(chǎn)廠家 液晶模塊種類 LCD液晶屏工作原理 什么是LED背光源
//======================================================//
// 產(chǎn)品型號(hào): 2323223323 //
// 微控制器: HT49R30A-1 //
// 軟件版本: 2.00 for RC (2.8MHz) //
// 2323232332323
//
//======================================================//
#include
#include "RS7001RC.h"
void main()
{
initial();
DispLCD(Length);
while (1)
{
_clrwdt();
ScanKey();
ScanStart();
LengthSetup();
Start_End();
}
}
/* ============================ Delay ========================== */
void delay(unsigned char cnt)
{
unsigned char i,j;
for (i=0;i<=cnt;i++)
{
for (j=0;j<=100;j++){ _clrwdt(); }
_clrwdt();
}
}
/* ========================== Initial ========================== */
void initial(void)
{
C_MT1 = 0; C_MT2Z = 0; C_MT2F = 0;
delay(20);
SwitchStart=0; KeyDown=0; KeySetup=0; KeyUp=0;
StartFlag=1; StopFlag=0;
CutFlag=0; SetupFlag=0; ResendFlag=0;
BusyFlag=0; InitFlag=0; ResetFlag=0;
LCD_count=0; Cut_count=0; LC_Str=1;
if(!_to) { Length = 45; }
_tmrc = 0xb0; _tmr = 0x38;
_tmrc = 0xa0; _tmrc = 0xb0;
_eti = 1; // Timer0 interrupt
_eei0 = 1; // INT0 interrupt
_emi = 1; // Total interrupt
if(End) { CutFlag=1; Cut_count=5100; }
}
/* ========================= ScanKey =========================== */
void ScanKey(void)
{
if(Start){ StartFlag=1; }
if( Down==0 | Setup==0 | Up==0 )
{
delay(5);
if( Down==0 | Setup==0 | Up==0 )
{
if(Down==0)
{
if(SetupFlag)
{
while(!Down) { _clrwdt(); }
KeyDown = 1;
}
else
{
if(Up==0)
{
while(!Up) { _clrwdt(); }
InitFlag = 1;
}
}
}
if(Setup==0)
{
while(!Setup) { _clrwdt(); }
KeySetup = 1;
}
if(Up==0)
{
if(SetupFlag)
{
while(!Up) { _clrwdt(); }
KeyUp = 1;
}
}
}
else
{
KeyDown=0; KeySetup=0; KeyUp=0; InitFlag=0;
}
}
}
void LengthSetup(void)
{
if(KeySetup)
{
KeySetup = 0;
SetupFlag = !SetupFlag;
}
if(KeyDown)
{
KeyDown = 0;
if(Length==45) Length = 255;
else Length--;
}
if(KeyUp)
{
KeyUp = 0;
if(Length>245) Length = 45;
else Length += 10;
}
if(!SetupFlag) { DispLCD(Length); }
if(ON_Flag) { ON_Flag=0; DispLCD(Length);}
if(OFF_Flag){ OFF_Flag=0; LCD_Off(); }
}
/* ===================== Start & End Motor ===================== */
void ScanStart(void)
{
if(Start==0)
{
delay(5);
if(!SetupFlag & !BusyFlag)
{
if(StartFlag) { SwitchStart = 1; }
}
}
}
void Start_End(void)
{
if (SwitchStart)
{
SwitchStart = 0;
StartFlag =
0;
BusyFlag = 1;
Length_count = Length-35;
Length_count = 2*Length_count;
ResetFlag = 1;
_nop(); _nop();
Start_SendPaper();
}
if (InitFlag) { initial(); }
Hand = 1; Kee = Hand;
if(!Kee)
{
if(!SetupFlag)
{
_emi = 0; C_MT1 = 1;
StartFlag = 0;
while(!Kee)
{
_clrwdt(); Hand =1; Kee = Hand;
C_MT1 = 1;
C_MT2F = 0; C_MT2Z = 0;
}
C_MT1 = 0; _emi = 1;
CutFlag=1;
Cut_count=0;
ResetFlag = 1;
}
}
}
/* ======================= Display LCD ========================= */
void DispDigit(unsigned char Digit)
{
switch(Digit)
{
case 0: LCD_H = DIGIT[0]&0x0f;
LCD_L = DIGIT[0]&0xf0; LCD_L >>= 4;
break;
case 1: LCD_H = DIGIT[1]&0x0f;
LCD_L = DIGIT[1]&0xf0; LCD_L >>= 4;
break;
case 2: LCD_H = DIGIT[2]&0x0f;
LCD_L = DIGIT[2]&0xf0; LCD_L >>= 4;
break;
case 3: LCD_H = DIGIT[3]&0x0f;
LCD_L = DIGIT[3]&0xf0; LCD_L >>= 4;
break;
case 4: LCD_H = DIGIT[4]&0x0f;
LCD_L = DIGIT[4]&0xf0; LCD_L >>= 4;
break;
case 5: LCD_H = DIGIT[5]&0x0f;
LCD_L = DIGIT[5]&0xf0; LCD_L >>= 4;
break;
case 6: LCD_H = DIGIT[6]&0x0f;
LCD_L = DIGIT[6]&0xf0; LCD_L >>= 4;
break;
case 7: LCD_H = DIGIT[7]&0x0f;
LCD_L = DIGIT[7]&0xf0; LCD_L >>= 4;
break;
case 8: LCD_H = DIGIT[8]&0x0f;
LCD_L = DIGIT[8]&0xf0; LCD_L >>= 4;
break;
case 9: LCD_H = DIGIT[9]&0x0f;
LCD_L = DIGIT[9]&0xf0; LCD_L >>= 4;
break;
default: LCD_H = 0x00; LCD_L = 0x00; break;
}
}
void DispLCD(unsigned char data)
{
unsigned char digit1,digit2,digit3,temp,i;
_bp = 0x01;
temp = data%100;
digit1 = data/100;
digit2 = temp/10;
digit3 = temp%10;
DispDigit(digit1);
LCD[0] = LCD_H; LCD[1] = LCD_L;
DispDigit(digit2);
LCD[2] = LCD_H; LCD[3] = LCD_L;
DispDigit(digit3);
LCD[4] = LCD_H; LCD[5] = LCD_L;
for(i=8;i<20;i++){ LCD[i] = 0x00; }
}
void LCD_Off(void)
{
unsigned char i;
_bp = 0x01;
for(i=0;i<18;i++){ LCD[i] = 0x00; }
}
/* ==================== Interrupt Processor ==================== */
void INT0_isr(void)
{
dat0 = PulseInput;
if(!dat0)
{ Length_count--;
if(Length_count==0)
{
Stop_SendPaper();
if(ResetFlag)
{
CutFlag=1; // 初始化切紙電機(jī)
Cut_count=0;
}
else
{
Stop_count = 2000; //2000
StopFlag = 1;
if(Start) { StartFlag = 1; }
else { StartFlag = 0; }
}
}
}
}
void INT1_isr(void)
{
// dat1 = End;
// if(!dat1 && Cut_count>800)
if(Cut_count>800)
{
Stop_CutPaper();
_nop(); _nop();
_eei1 = 0;
CutFlag = 0;
Cut_count = 0;
if(ResetFlag)
{
Length_count = INIT_LENGTH;
ResetFlag = 0;
ResendFlag = 1;
ResendCount = 2000; //500
}
else
{ Stop_count = 2000; StopFlag = 1; } //2000
}
}
void Time
r0_isr(void)
{
if(SetupFlag) // LCD setup
{
LCD_count++;
if(LCD_count==600) { ON_Flag = 1; }
else if(LCD_count==2400)
{ LCD_count=0; OFF_Flag=1; }
}
if(StopFlag)
{
Stop_count--;
if(Stop_count==0)
{ StopFlag=0; BusyFlag=0; }
}
if(ResendFlag)
{
ResendCount--;
if(ResendCount==0)
{
Start_SendPaper();
ResendFlag = 0;
}
}
if(CutFlag) { Cut_count++; }
if(Cut_count==1000) //800
{
Start_CutPaper();
_eei1 = 1;
}
else if(Cut_count==1010) //810
{
Start_CutPaper();
_eei1 = 1;
}
else if (Cut_count==5000) //5000
{ Stop_CutPaper(); }
else if (Cut_count==5500) //5500
{
ResetFlag = 0;
_eei1 = 1;
_nop(); _nop();
Exit_CutPaper();
}
else if (Cut_count==9500) //9500
{
Cut_count = 0;
ResetFlag = 0;
BusyFlag = 0;
Stop_CutPaper();
_nop(); _nop();
_eei1 = 0;
}
}
/* =========================== END ============================= */
【責(zé)任編輯】: 晶拓液晶
版權(quán)所有:http:// www.djtvv.com轉(zhuǎn)載請(qǐng)注明出處,違者本網(wǎng)將依法追究責(zé)任。
咨詢熱線
13862038982