P2n_pure_input(0x0f); //All COM outputs are high impedance, and COM
s voltage is the midpoint
if(scan_index & 1) // Reverse scan
{
P1 = ~LCD_buff[j];
P2 = ~(LCD_buff[j|4] & 0xf0);
}
else // Normal phase scan
{
P1 = LCD_buff[j];
P2 = LCD_buff[j|4] & 0xf0;
}
P2n_push_pull(T_COM[j]); //A COM is set as push-pull output mode
if(++scan_index >= 8) scan_index = 0;
}
/****************** Load display functions for numbers 1 to 6 ***************************/
void LCD_load(u8 n, u8 dat) // n is the number
dat is the number to be displayed
{
u8 code t_display[]={ // Standard font
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71,
//black -
0x00,0x40
};
u8 code T_LCD_mask[4] = {~0xc0,~0x30,~0x0c,~0x03};
u8 code T_LCD_mask4[4] = {~0x40,~0x10,~0x04,~0x01};
u8 i,k;
u8 *p;
if((n == 0) || (n > 6)) return;
i = t_display[dat];
if(n <= 4) //1~4
{
n--;
p = LCD_buff;
}
else
{
n = n - 5;
p = &LCD_buff[4];
}
k = 0;
if(i & 0x08) k |= 0x40; //D
*p = (*p & T_LCD_mask4[n]) | (k>>2*n);
p++;
k = 0;
if(i & 0x04) k |= 0x40; //C
if(i & 0x10) k |= 0x80; //E
*p = (*p & T_LCD_mask[n]) | (k>>2*n);
p++;
k = 0;
if(i & 0x02) k |= 0x40; //B
if(i & 0x40) k |= 0x80; //G
*p = (*p & T_LCD_mask[n]) | (k>>2*n);
p++;
k = 0;