delay_us(5);
transfer_command_lcd(0x2c); /*升压步聚1*/ delay_us(5);
transfer_command_lcd(0x2e); /*升压步聚2*/ delay_us(5);
transfer_command_lcd(0x2f); delay_us(5);
transfer_command_lcd(0x25); 设置范围0x20~0x27*/
transfer_command_lcd(0x81); transfer_command_lcd(0x16); 度的值,可设置范围0x00~0x3f*/
transfer_command_lcd(0xa2); (bias)*/
transfer_command_lcd(0xc8); 上到下*/
transfer_command_lcd(0xa0); 左到右*/
transfer_command_lcd(0x40); 开始*/
transfer_command_lcd(0xaf); set(lcd_cs);
/*升压步聚3*/ /*粗调对比度,可/*微调对比度*/ /*0x1a,微调对比/*1/9偏压比/*行扫描顺序:从/*列扫描顺序:从/*起始行:第一行/*开显示*/ Clear_LCD(); }
/*全屏清屏*/ void Clear_LCD() {
u8 i,j; clr(lcd_cs); for(i=0;i<9;i++) {
transfer_command_lcd(0xb0+i); transfer_command_lcd(0x10); transfer_command_lcd(0x00); for(j=0;j<128;j++) {
transfer_data_lcd(0x00); } }
set(lcd_cs); }
/*设置显示位置*/
void set_ads_lcd(u8 page, u8 column) {
//设置 行 和 列,液晶本身不会自己跨行,但是我们的应用通常是不希望他跨行的,所以就不写了,这样超过范围的部分只是浪费掉而已 u8 page_address;
u8 column_address_L,column_address_H;
page_address = 0xb0 + page - 1; column = column - 1;
column_address_L = column & 0x0f;
column_address_H = ((column >> 4) & 0x0f) + 0x10;
transfer_command_lcd(page_address); /*Set Page Address*/
transfer_command_lcd(column_address_H); /*Set MSB of column Address*/
transfer_command_lcd(column_address_L); /*Set LSB of column Address*/ }
/*写指令到LCD模块*/
void transfer_command_lcd(u8 data1) {
u8 i; clr(lcd_rs); for(i=0;i<8;i++) {
clr(lcd_sclk);
if(data1&0x80) set(lcd_sid); else clr(lcd_sid); set(lcd_sclk); data1<<=1; } }
/*写数据到LCD模块*/
void transfer_data_lcd(u8 data1) {
u8 i; set(lcd_rs); for(i=0;i<8;i++)
{
clr(lcd_sclk);
if(data1&0x80) set(lcd_sid); else clr(lcd_sid); set(lcd_sclk); data1<<=1; } }
const u8 font_s[][6] = {
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 }, { 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 }, { 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 }, { 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, { 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 }, { 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 }, { 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 }, { 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 }, { 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 }, { 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 }, // sp// !// \// #// $// %// &// '// (// )// *