微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 水果电池驱动LaunchPad(MSP430 G2553)+Nokia5110

水果电池驱动LaunchPad(MSP430 G2553)+Nokia5110

时间:11-13 来源:互联网 点击:

/*-----------------------------------------------------------------------
LCD_clear : LCD清屏函数
-----------------------------------------------------------------------*/
void LCD_clear(void)
{
unsigned int i;

LCD_write_byte(0x0c, 0);
LCD_write_byte(0x80, 0);

for (i=0; i<504; i++)
LCD_write_byte(0, 1);
}

/*-----------------------------------------------------------------------
LCD_set_XY : 设置LCD坐标函数

输入参数:X :0-83
Y :0-5
-----------------------------------------------------------------------*/
void LCD_set_XY(unsigned char X, unsigned char Y)
{
LCD_write_byte(0x40 | Y, 0);// column
LCD_write_byte(0x80 | X, 0); // row
}

/*-----------------------------------------------------------------------
LCD_write_char : 显示英文字符

输入参数:c :显示的字符;
-----------------------------------------------------------------------*/
void LCD_write_char(unsigned char c)
{
unsigned char line;

c -= 32;

for (line=0; line<6; line++)
LCD_write_byte(FONT6x8[c][line], 1);
}

/*-----------------------------------------------------------------------
LCD_write_english_String : 英文字符串显示函数

输入参数:*s :英文字符串指针;
X、Y : 显示字符串的位置,x 0-83 ,y 0-5
-----------------------------------------------------------------------*/
void LCD_write_english_string(unsigned char X,unsigned char Y,char *s)
{
LCD_set_XY(X,Y);
while (*s)
{
LCD_write_char(*s);
s++;
}
}
/*-----------------------------------------------------------------------
LCD_write_chinese_string: 在LCD上显示汉字

输入参数:X、Y :显示汉字的起始X、Y坐标;
ch_with :汉字点阵的宽度
num :显示汉字的个数;
line :汉字点阵数组中的起始行数
row :汉字显示的字间距
测试:
LCD_write_chi(0,0,12,7,0,0);
LCD_write_chi(0,2,12,7,0,0);
LCD_write_chi(0,4,12,7,0,0);
-----------------------------------------------------------------------*/
void LCD_write_chinese_string(unsigned char X, unsigned char Y,
unsigned char ch_with,unsigned char num,
unsigned char line,unsigned char row)
{
unsigned char i,n;

LCD_set_XY(X,Y); //设置初始位置

for (i=0;i{
for (n=0; n{
if (n==ch_with) //写汉字的下半部分
{
if (i==0) LCD_set_XY(X,Y+1);
else
LCD_set_XY((X+(ch_with+row)*i),Y+1);
}
LCD_write_byte(write_chinese[line+i][n],1);
}
i++;
LCD_set_XY((X+(ch_with+row)*i),Y);
}
}
/*-----------------------------------------------------------------------
LCD_write_byte : 使用SPI接口写数据到LCD

输入参数:data :写入的数据;
command :写数据/命令选择;

-----------------------------------------------------------------------*/
void LCD_write_byte(unsigned char dat, unsigned char command)
{
unsigned char i;
LCD_5110_OUT &= ~(0x01 < LCD_SCE);// msp430

if (command == 0) // 传送命令
LCD_5110_OUT &= ~(0x01 < LCD_DC);
else // 传送数据

LCD_5110_OUT |= (0x01 < LCD_DC);
for(i=0;i<8;i++)
{
if(dat&0x80)
LCD_5110_OUT |= (0x01 < LCD_DN);
else
LCD_5110_OUT &= ~(0x01 < LCD_DN);
//SCLK = 0;
LCD_5110_OUT &= ~(0x01 < LCD_SCLK);
dat = dat < 1;
LCD_5110_OUT |= (0x01 < LCD_SCLK);
}
LCD_5110_OUT |= (0x01 < LCD_SCE);
}
/*write_chinese_string_pixel.h

修改者:http://jiwm.blog.13.com
要显示的汉字字库
*/

char write_chinese[][24]={

//人
{0x00,0x00,0x00,0x80,0x60,0x1F,0x60,0x80,0x00,0x00,0x00,0x00,0x08,0x04,0x02,0x01,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x00},
//生
{0x20,0x10,0x8E,0x88,0x88,0xFF,0x88,0x88,0x88,0x08,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x0F,0x08,0x08,0x08,0x08,0x08,0x00},
//中
{0x00,0xF8,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0xF8,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x01,0x00,0x00},
//成
{0x00,0xFC,0x24,0x24,0xE4,0x04,0xFF,0x04,0x85,0x66,0x04,0x00,0x08,0x07,0x00,0x02,0x0B,0x04,0x02,0x01,0x02,0x04,0x0F,0x00},
//功
{0x04,0x04,0xFC,0x04,0x04,0x08,0xFF,0x08,0x08,0x08,0xF8,0x00,0x02,0x02,0x01,0x09,0x05,0x03,0x00,0x00,0x08,0x08,0x07,0x00},
//源
{0x11,0x22,0x00,0xFF,0x01,0xF9,0xAD,0xAB,0xA9,0xF9,0x01,0x00,0x04,0x02,0x08,0x07,0x04,0x02,0x08,0x0F,0x00,0x02,0x04,0x00},
//于
{0x20,0x21,0x21,0x21,0x21,0xFF,0x21,0x21,0x21,0x21,0x20,0x00,0x00,0x00,0x00,0x08,0x08,0x0F,0x00,0x00,0x00,0x00,0x00,0x00},
//不
{0x02,0x02,0x82,0x42,0x22,0xF2,0x0E,0x22,0x42,0x82,0x02,0x00,0x01,0x01,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x01,0x00},
//放
{0x08,0xF9,0x4A,0x48,0xC8,0x20,0x10,0xEF,0x08,0xF8,0x08,0x00,0x08,0x07,0x00,0x08,0x0F,0x00,0x08,0x05,0x02,0x05,0x08,0x00},
//弃
{0x04,0x24,0x34,0xEC,0x25,0x26,0x24,0xE4,0x34,0x64,0x04,0x00,0x01,0x09,0x05,0x03,0x01,0x01,0x01,0x0F,0x01,0x01,0x01,0x00},
};

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top