求助用msp430g2553写LCD12864半宽字符显示程序

2019-03-24 11:09发布

#include<msp430g2553.h>

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个 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
1条回答
施森林
1楼-- · 2019-03-24 17:53
< 啊啊啊!来人啊!解答给钱啦!!!

一周热门 更多>

相关问题

    相关文章