1557|0

6628

帖子

0

TA的资源

五彩晶圆(高级)

楼主
 

MSP430有关LCD5110驱动编程实例 [复制链接]

单片机源程序如下:
#include "5110.h"

unsigned char Font_code[][6] =
{
    {0x00,0x00,0x00,0x00,0x00,0x00},// (0)
    {0x00,0x00,0x00,0x4F,0x00,0x00},//!(1)
    {0x00,0x00,0x07,0x00,0x07,0x00},//"(2)
    {0x00,0x14,0x7F,0x14,0x7F,0x14},//#(3)
    {0x00,0x24,0x2A,0x7F,0x2A,0x12},//$(4)
    {0x00,0x23,0x13,0x08,0x64,0x62},//%(5)
    {0x00,0x36,0x49,0x55,0x22,0x50},//&(6)
    {0x00,0x00,0x05,0x03,0x00,0x00},//'(7)
    {0x00,0x00,0x1C,0x22,0x41,0x00},//((8)
    {0x00,0x00,0x41,0x22,0x1C,0x00},//)(9)
    {0x00,0x14,0x08,0x3E,0x08,0x14},//*(10)
    {0x00,0x08,0x08,0x3E,0x08,0x08},//+(11)
    {0x00,0x00,0x50,0x30,0x00,0x00},//,(12)
    {0x00,0x08,0x08,0x08,0x08,0x08},//-(13)
    {0x00,0x00,0x60,0x60,0x00,0x00},//.(14)
    {0x00,0x20,0x10,0x08,0x04,0x02},///(15)
    {0x00,0x3E,0x51,0x49,0x45,0x3E},//0(16)
    {0x00,0x00,0x42,0x7F,0x40,0x00},//1(17)
    {0x00,0x42,0x61,0x51,0x49,0x46},//2(18)
    {0x00,0x21,0x41,0x45,0x4B,0x31},//3(19)
    {0x00,0x18,0x14,0x12,0x7F,0x10},//4(20)
    {0x00,0x27,0x45,0x45,0x45,0x39},//5(21)
    {0x00,0x3C,0x4A,0x49,0x49,0x30},//6(22)
    {0x00,0x01,0x71,0x09,0x05,0x03},//7(23)
    {0x00,0x36,0x49,0x49,0x49,0x36},//8(24)
    {0x00,0x06,0x49,0x49,0x29,0x1E},//9(25)
    {0x00,0x00,0x36,0x36,0x00,0x00},//:(26)
    {0x00,0x00,0x56,0x36,0x00,0x00},//;(27)
    {0x00,0x08,0x14,0x22,0x41,0x00},//<(28)
    {0x00,0x14,0x14,0x14,0x14,0x14},//=(29)
    {0x00,0x00,0x41,0x22,0x14,0x08},//>(30)
    {0x00,0x02,0x01,0x51,0x09,0x06},//?(31)
    {0x00,0x32,0x49,0x79,0x41,0x3E},//@(32)
    {0x00,0x7E,0x11,0x11,0x11,0x7E},//A(33)
    {0x00,0x7F,0x49,0x49,0x49,0x3E},//B(34)
    {0x00,0x3E,0x41,0x41,0x41,0x22},//C(35)
    {0x00,0x7F,0x41,0x41,0x22,0x1C},//D(36)
    {0x00,0x7F,0x49,0x49,0x49,0x41},//E(37)
    {0x00,0x7F,0x09,0x09,0x09,0x01},//F(38)
    {0x00,0x3E,0x41,0x49,0x49,0x7A},//G(39)
    {0x00,0x7F,0x08,0x08,0x08,0x7F},//H(40)
    {0x00,0x00,0x41,0x7F,0x41,0x00},//I(41)
    {0x00,0x20,0x40,0x41,0x3F,0x01},//J(42)
    {0x00,0x7F,0x08,0x14,0x22,0x41},//K(43)
    {0x00,0x7F,0x40,0x40,0x40,0x40},//L(44)
    {0x00,0x7F,0x02,0x04,0x02,0x7F},//M(45)
    {0x00,0x7F,0x04,0x08,0x10,0x7F},//N(46)
    {0x00,0x3E,0x41,0x41,0x41,0x3E},//O(47)
    {0x00,0x7F,0x09,0x09,0x09,0x06},//P(48)
    {0x00,0x3E,0x41,0x51,0x21,0x5E},//Q(49)
    {0x00,0x7F,0x09,0x19,0x29,0x46},//R(50)
    {0x00,0x46,0x49,0x49,0x49,0x31},//S(51)
    {0x00,0x01,0x01,0x7F,0x01,0x01},//T(52)
    {0x00,0x3F,0x40,0x40,0x40,0x3F},//U(53)
    {0x00,0x1F,0x20,0x40,0x20,0x1F},//V(54)
    {0x00,0x3F,0x40,0x38,0x40,0x3F},//W(55)
    {0x00,0x63,0x14,0x08,0x14,0x63},//X(56)
    {0x00,0x03,0x04,0x78,0x04,0x03},//Y(57)
    {0x00,0x61,0x51,0x49,0x45,0x43},//Z(58)
    {0x00,0x00,0x7F,0x41,0x41,0x00},//[(59)
    {0x00,0x15,0x16,0x7C,0x16,0x15},//\(60)
    {0x00,0x00,0x41,0x41,0x7F,0x00},//](61)
    {0x00,0x04,0x02,0x01,0x02,0x04},//^(62)
    {0x00,0x40,0x40,0x40,0x40,0x40},//_(63)
    {0x00,0x00,0x01,0x02,0x04,0x00},//`(64)
    {0x00,0x20,0x54,0x54,0x54,0x78},//a(65)
    {0x00,0x7F,0x48,0x44,0x44,0x38},//b(66)
    {0x00,0x38,0x44,0x44,0x44,0x20},//c(67)
    {0x00,0x38,0x44,0x44,0x48,0x7F},//d(68)
    {0x00,0x38,0x54,0x54,0x54,0x18},//e(69)
    {0x00,0x08,0x7E,0x09,0x01,0x02},//f(70)
    {0x00,0x0C,0x52,0x52,0x52,0x3E},//g(71)
    {0x00,0x7F,0x08,0x04,0x04,0x78},//h(72)
    {0x00,0x00,0x44,0x7D,0x40,0x00},//i(73)
    {0x00,0x20,0x40,0x44,0x3D,0x00},//j(74)
    {0x00,0x7F,0x10,0x28,0x44,0x00},//k(75)
    {0x00,0x00,0x41,0x7F,0x40,0x00},//l(76)
    {0x00,0x7E,0x02,0x0C,0x02,0x7C},//m(77)
    {0x00,0x7E,0x04,0x02,0x02,0x7C},//n(78)
    {0x00,0x38,0x44,0x44,0x44,0x38},//o(79)
    {0x00,0x7C,0x14,0x14,0x14,0x08},//p(80)
    {0x00,0x08,0x14,0x14,0x18,0x7C},//q(81)
    {0x00,0x7C,0x08,0x04,0x04,0x08},//r(82)
    {0x00,0x48,0x54,0x54,0x54,0x20},//s(83)
    {0x00,0x04,0x3F,0x44,0x40,0x20},//t(84)
    {0x00,0x3C,0x40,0x40,0x20,0x7C},//u(85)
    {0x00,0x1C,0x20,0x40,0x20,0x1C},//v(86)
    {0x00,0x3C,0x40,0x30,0x40,0x3C},//w(87)
    {0x00,0x44,0x28,0x10,0x28,0x44},//x(88)
    {0x00,0x0C,0x50,0x50,0x50,0x3C},//y(89)
    {0x00,0x44,0x64,0x54,0x4C,0x44},//z(90)
    {0x00,0x00,0x08,0x36,0x41,0x00},//{(91)
    {0x00,0x00,0x00,0x7F,0x00,0x00},//|(92)
    {0x00,0x00,0x41,0x36,0x08,0x00},//}(93)
    {0x00,0x08,0x04,0x08,0x10,0x08},//~(94)
    {0x00,0x08,0x08,0x2A,0x1C,0x08},//?ú(127)
    {0x00,0x08,0x1C,0x2A,0x08,0x08},//??(128)
    {0x00,0x04,0x02,0x7F,0x02,0x04},//?ü(129)
    {0x00,0x10,0x20,0x7F,0x20,0x10},//?y(130)
    {0x00,0x1C,0x2A,0x32,0x2A,0x1C},//D|??(131)
    {0x00,0x1C,0x22,0x44,0x22,0x1C} //°?D?(132)
};

/*--------------------------------------------------------------*/
// 写一个字节的命令或者数字
//commond==0写指令, commond==1写数据
void LCD_write_byte(uchar date, uchar commond)
{
  uchar i;
  CE0;
  if(commond == 1)
  {
    DC1;
  }
  else
  {
    DC0;
  }
  for(i = 8; i > 0; i--)
  {
    if(date & 0x80)
    {
      DIN1;
    }
    else
    {
      DIN0;
    }
    CLK0;
    date = date << 1;
    CLK1;
  }
  CE1;
}

/*--------------------------------------------------------------*/
//设定开始写的位置
void LCD_set_XY(uchar X, uchar Y)
{
  LCD_write_byte(0x40 | Y, 0);// 行 0-5
  LCD_write_byte(0x80 | X, 0);// 列 0-83/12
}

/*--------------------------------------------------------------*/
//清屏
void LCD_clr_scr(void)//
{
  unsigned int i;
  LCD_write_byte(0x80, 0);
  LCD_write_byte(0x40, 0);
  for(i = 504; i; i--)
  {
    LCD_write_byte(0x00, 1);
  }
}

/*--------------------------------------------------------------*/
//字符输出(6*8字体)
//x: 0 - 13
//y: 0 - 5
void LCD_printc(unsigned char x, unsigned char y, unsigned char c_dat)
{
    unsigned char i;
    c_dat -= 32;        
    x *= 6;            
    LCD_set_XY(x, y);
    for(i = 0; i < 6; i++)
    {
        LCD_write_byte(Font_code[c_dat][i], 1);
    }
}

/*--------------------------------------------------------------*/
//字符串输出(6*8字体)
//x: 0 - 13
//y: 0 - 5
void LCD_prints(unsigned char x, unsigned char y, unsigned char *s_dat)
{
    while(*s_dat && x < 14)
    {
        LCD_printc(x++, y, *s_dat);
        s_dat++;
    }
}

/*--------------------------------------------------------------*/
//字符串输出,自动换行(6*8字体)
//x: 0 - 13
//y: 0 - 5
void LCD_printsl(unsigned char x, unsigned char y, unsigned char *s_dat)
{
    while(*s_dat)
    {
        LCD_printc(x++, y, *s_dat);
        s_dat++;
        if(x == 14)
        {
            x = 0;
            y++;
        }
        if(y == 6)
        {
            y = 0;
        }
    }
}

/*--------------------------------------------------------------*/
//定位输出数字
//x: 0 - 13
//y: 0 - 5
//num: 0 - 65535    要显示的数字
//num_bit: 0 - 5    数字的位数
void LCD_printn(unsigned char x, unsigned char y, unsigned int num, unsigned char num_bit)
{
    signed   char i;
    unsigned char ii;
    unsigned char dat[6];
    for(i = 0; i < 6; i++)
    {
        dat[i] = 0;   
    }
    i = 0;
    while(num / 10)                     
    {
        dat[i] = num % 10;              
        num /= 10;
        i++;
    }
    dat[i] = num;                     
    ii = i;                             
    for(; i >= 0; i--)
……………………

 
点赞 关注

回复
举报
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表