欢迎光临苏州启普微电子有限公司!

收藏网站 在线留言 网站地图

晶拓液晶屏

晶拓 —— 14年专注LCD液晶屏定制服务段码液晶屏设计及生产服务商

LCD液晶屏全国订制热线:400-0512-060

新闻资讯-聚焦行业,创新服务,晶拓品牌长远发展

HOLTEK合泰单片机驱动段码液晶屏显示程序

作者: 晶拓小编 编辑: 晶拓液晶屏 来源: 晶拓液晶屏工厂 发布日期: 2018.09.18
信息摘要:
HOLTEK合泰单片机驱动段码液晶屏显示程序

             //======================================================//
// 产品型号: 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; // 初始化切纸电机
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 ============================= */



【责任编辑】: 晶拓液晶

版权所有:http:// www.chipsz.com转载请注明出处,违者本网将依法追究责任。

推荐资讯
背光板

液晶屏背光板的分类及知识点

背光板是提供LCD显示器产品中一个背面光源的光学组件。由于液晶玻璃本身不具发光特性,因此根据需要会在液晶玻璃后面加上一个发光源,即背光板。应用范围遍及医疗,美容,仪器仪表,车载设备,工业设备、银行终端、办公自动化、通讯、电子玩具及消费...
2019-10-12
​VA彩屏液晶屏应用眼部按摩仪

​VA彩屏液晶屏应用眼部按摩仪

眼部按摩仪液晶显示屏,VA屏,集美观、实用于一体...
2019-04-19
VA彩屏液晶屏应用于电动车仪表

VA彩屏液晶屏应用于电动车仪表

电动车仪表盘,VA彩屏,集美观、实用于一体...
2019-04-19

咨询热线

400-0512-060