📄 lcd.c
字号:
/* the start of Lcd.c */
//============================================================
// name : Lcd.c
// task : LCD Display
// history
//=============================================================*/
//------------------------------------------------------------------
// Include file and variable
//------------------------------------------------------------------
#include <hms800.h> //
#include "MC80C7208.h" // SFR define
#define USER_EXTERN extern
#include "Variable.h" //
//------------------------------------------------------------------
// external prototype function
//------------------------------------------------------------------
void Hex_to_Dec(void);
void Lcd_Off(void);
void Lcd_On(void);
//=========================================================================
// New Display Font Table 1/4 duty
//
// aaaaa 11111
// f b 1
// f b 1 Seg0 ---- gfed
// f b 1 0000 1110
// ggggg 11111
// e c 1 Seg1 ---- abch
// e c 1 0000 0011
// e c 1
// ddddd hh 1111111
//
//=========================================================================
CODE unsigned char Font_ASCII[] =
{
0xEB, // Chr0 1110_1011b 0
0x60, // Chr1 0110_0000b 1
0xC7, // Chr2 1100_0111b 2
0xE5, // Chr3 1110_0101b 3
0x6C, // Chr4 0110_1100b 4
0xAD, // Chr5 1010_1101b 5
0xAF, // Chr6 1010_1111b 6
0xE8, // Chr7 1110_1000b 7
0xEF, // Chr8 1110_1111b 8
0xEC, // Chr9 1110_1100b 9
0xEE, // ChrA 1110_1110b A
0x2F, // ChrB 0010_1111b b
0x8B, // ChrC 1000_1011b C
0x67, // ChrD 0110_0111b d
0x8F, // ChrE 1000_1111b E
0x8E, // ChrF 1000_1110b F
0x20, // Chr_ 0010_0000b - 10
0xD0, // ChrL 1100_0000b L 11
0xE4, // ChrO 1110_0100b o 12
0x73, // ChrP 0110_0011b P 13
0xB5, // ChrS 1010_0101b S 14
0x76, // ChrH 0110_0110b H 15
0x00, // Space 0000_0000b 0x16
0x64, // ChrN 0110_0100b n 17
0xF0, // ChrT 1110_0000b t 18
0xD6, // ChrU 1100_0110b u 19
0x60 // ChrR 0110_0000b r 1A
};
//=======================================================================
// Display function
//=======================================================================
//-------------------------------------------------------------------------
// Task : Lcd On
//
// SUBM(7) REFENB(6) LCDEN(5) VBEN(4) DTY1/0 LCK1/0
// Internal 0 0 1 1 00 11 (booster mode)
// External 0 1 1 0 00 11 (bias mode)
//-------------------------------------------------------------------------
void Lcd_On(void)
{
// if (DEBUG) //
// LCR = 0x33; // 0011_0011 booster mode under MC80F7208 and Emulator
// else
LCR = 0x62; // 0110_0010 bias mode under MC80F7108,MC80F7208
}
//-------------------------------------------------------------------------
// Task : Lcd Off Booster disable
//-------------------------------------------------------------------------
void Lcd_Off(void)
{
LCR = 0x00;
}
//-------------------------------------------------------------------------
// Task : Lcd All clean up
//-------------------------------------------------------------------------
void Lcd_Clear(void)
{
LCR = 0x00; // Lcd_Off()
asm("
lda #00h ;
ldy #24 ;
Lcd_Buf_Clear:
sta !460h+Y ;SEG0
dbne Y, Lcd_Buf_Clear ;
");
SEG32 = 0; //
SEG33 = 0; //
SEG34 = 0; //
R5PSR = 0x00; //
R6PSR = 0x00; //
R7PSR = 0x00; //
Lcd_On(); //
// LCR = 0x62; // 0110_0010 bias mode under MC80F7108,MC80F7208
}
//-------------------------------------------------------------------------
// Task : Key display
// input :
//-------------------------------------------------------------------------
void Key_Display(void)
{
i = (rKey_Command >> 4) & 0x0F; //
i = Font_ASCII[i]; //
SEG20 = (i >> 4) & 0x0F; //
SEG21 = i & 0x0F; //
i = rKey_Command & 0x0F; //
i = Font_ASCII[i]; //
SEG18 = (i >> 4) & 0x0F; //
SEG19 = i & 0x0F; //
}
//-------------------------------------------------------------------------
// Task : Clock display
// input : rLcd_Buf[0] ~ rLcd_Buf[3]
//-------------------------------------------------------------------------
void Clock_Display(void)
{
LCR = 0x62; // 0110_0010 bias mode under MC80F7108,MC80F7208
i = Font_ASCII[rLcd_Buf[0]]; //
SEG1 = (i >> 4) & 0x0F; //
SEG0 = i & 0x0F; //
i = Font_ASCII[rLcd_Buf[1]]; //
i = (i >> 4) & 0x0F; //
SEG3 = i | 0x01; //
i = Font_ASCII[rLcd_Buf[1]]; //
SEG2 = i & 0x0F; //
i = Font_ASCII[rLcd_Buf[2]]; //
i = (i >> 4) & 0x0F; //
SEG5 = i | 0x01; // Clock Logo
i = Font_ASCII[rLcd_Buf[2]]; //
SEG4 = i & 0x0F; //
i = Font_ASCII[rLcd_Buf[3]]; //
SEG7 = (i >> 4) & 0x0F; //
SEG6 = i & 0x0F; //
}
//-------------------------------------------------------------------------
// Task : Alram display
// input :
//-------------------------------------------------------------------------
void Alram_Display(void)
{
SEG14 = 0x07; //
SEG15 = 0x0F; //
}
//-------------------------------------------------------------------------
// Task : Clock display
// input : rLcd_Buf[0] ~ rLcd_Buf[3]
//-------------------------------------------------------------------------
void Alarm_Display(void)
{
i = Font_ASCII[rLcd_Buf[0]]; //
SEG15 = (i >> 4) & 0x0F; //
SEG14 = i & 0x0F; //
i = Font_ASCII[rLcd_Buf[1]]; //
SEG13 = (i >> 4) & 0x0F; //
SEG12 = i & 0x0F; //
i = Font_ASCII[rLcd_Buf[2]]; //
SEG11 = (i >> 4) & 0x0F; //
SEG10 = i & 0x0F; //
i = Font_ASCII[rLcd_Buf[3]]; //
SEG9 = (i >> 4) & 0x0F; //
SEG8 = i & 0x0F; //
}
//=======================================================================
// task : LCD display
//=======================================================================
void Process_Lcd(void) // LCD display check
{
if (rTimer_4ms[TIME_Lcd]) //
return; //
rTimer_4ms[TIME_Lcd] = 250; // 1 sec
switch(rLcd_Mode) //
{
case MODE_ALRAM: //
Alram_Display(); // Menu display
break; //
case MODE_CLOCK: //
Clock_Display(); // Clock display
break; //
} //
}
//========================================================================
/* end of Lcd.C */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -