|
求助用msp430g2553写LCD12864半宽字符显示程序
[复制链接]
#include
void LCD_init(void);
void LCD_write_com(int com);
void LCD_send_byte(int byte);
void LCD_write_char(int x, int y, char word);
void LCD_write_string(int x, int y, char *s);
void LCD_clear(void);
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
while (1)
{
LCD_init();
LCD_write_string(1, 1, "fucking!!");
LCD_write_char(2, 2, 'f');
_delay_cycles(20000000);
}
}
void LCD_init(void)
{
P2DIR |= BIT4 + BIT5;
_delay_cycles(300);
LCD_write_com(0x30);
LCD_write_com(0x0c);
LCD_write_com(0x01);
LCD_write_com(0x02);
LCD_write_com(0x80);
}
void LCD_write_com(int com)
{
unsigned char temp;
_delay_cycles(100);
LCD_send_byte(0xf8);
temp = com & 0xf0;
LCD_send_byte(temp);
temp = (com << 4) & 0xf0;
LCD_send_byte(temp);
_delay_cycles(100);
}
void LCD_send_byte(int byte)
{
unsigned int i;
for (i = 8; i > 0; i--)
{
if ((byte >> (i - 1)) & 0x01)
P2OUT |= BIT4;
else
P2OUT &= ~BIT4;
_delay_cycles(100);
P2OUT |= BIT5;
_delay_cycles(100);
P2OUT &= ~BIT5;
_delay_cycles(100);
}
}
void LCD_write_string(int x, int y, char *s)
{
for (; *s; s++, y++)
LCD_write_char(x, y, *s);
}
void LCD_write_char(int x, int y, char word)
{
switch (x)
{
case 0:
LCD_write_com(0x7f + y);
break;
case 1:
LCD_write_com(0x8f + y);
break;
case 2:
LCD_write_com(0x87 + y);
break;
case 3:
LCD_write_com(0x97 + y);
break;
default:
break;
}
_delay_cycles(100);
LCD_send_byte(0xfa);
unsigned char temp;
temp = word & 0xf0;
LCD_send_byte(temp);
temp = (word << 4) & 0xf0;
LCD_send_byte(temp);
_delay_cycles(100);
}
void LCD_clear(void)
{
LCD_write_com(0x01);
}
上面的程序是中文字符显示,我想显示英文字符,一行却只能显示8个,求解怎么一行显示16个
|
|