哈哈,以前都没发过贴,因为总是个菜鸟,怕被骂,但是总有一天要成长的,这几天抽了点空学了学板子上的液晶,今天燕子让活跃一下就支持下吧,首先提个建议,为什么板子上没有电源控制开关,下程序的时候老是插拔很不方便。 NHD-C12832A1Z-FSW-FBW-3V3是FSTN液晶显示器和分辨率128 x 32像素,包含一个LCD控制器(ST7565R)和液晶面板(C12832_A1Z),白色背光。两种模式,并行和串行SPI,这里用的是SPI,优点是接口少,缺点人们只能写信号给显示器,因为阅读显示数据时仅支持使用并行接口。这里有个什么电源设置好像,没弄懂,3.3v转6v吧 不知道怎么弄得,但是电路图上好像是3.3V,希望给弄明白哈,呵呵,然后背光的亮度是可调的通过定时器控制PWM来实现,英文不太好。 LCD的软件操作大同小异,但是也好久没有弄LCD了,没有用demo给的液晶写字符的程序,自己琢磨了一下,写了一个贴出来,帮忙看看,哈哈 #include <board.h> #include <sysclk.h> #include <st7565r.h> unsigned char aa[28][8]={ {0x7E,0x10,0x10,0x7E,0x00,0x00,0x00,0x00},/*"H",0*/ /* (4 X 16, 黑¨²体¬? )*/ {0x30,0x68,0x58,0x00,0x00,0x00,0x00,0x00},/*"e",1*/ /* (4 X 16, 黑¨²体¬? )*/ {0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00},/*"l",2*/ /* (4 X 16, 黑¨²体¬? )*/ {0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00},/*"l",3*/ /* (4 X 16, 黑¨²体¬? )*/ {0x30,0x48,0x48,0x30,0x00,0x00,0x00,0x00},/*"o",4*/ /* (4 X 16, 黑¨²体¬? )*/ {0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00},/*",",5*/ /* (4 X 16, 黑¨²体¬? )*/ {0x30,0x68,0x58,0x00,0x00,0x00,0x00,0x00},/*"e",6*/ /* (4 X 16, 黑¨²体¬? )*/ {0x30,0x68,0x58,0x00,0x00,0x00,0x00,0x00},/*"e",7*/ /* (4 X 16, 黑¨²体¬? )*/ {0x7E,0x48,0x58,0x20,0x00,0x00,0x00,0x00},/*"b",8*/ /* (4 X 16, 黑¨²体¬? )*/ {0x30,0x48,0x48,0x30,0x00,0x00,0x00,0x00},/*"o",9*/ /* (4 X 16, 黑¨²体¬? )*/ {0x20,0x68,0x78,0x00,0x00,0x00,0x00,0x00},/*"a",10*/ /* (4 X 16, 黑¨²体¬? )*/ {0x00,0x30,0x08,0x00,0x00,0x00,0x00,0x00},/*"r",11*/ /* (4 X 16, 黑¨²体¬? )*/ {0x30,0x48,0x7C,0x00,0x00,0x00,0x00,0x00},/*"d",12*/ /* (4 X 16, 黑¨²体¬? )*/ {0x00,0x4E,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",13*/ /* (4 X 16, 黑¨²体¬? )*/ {0x00,0x4E,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",13*/ /* (4 X 16 , 黑¨²体¬? )*/ {0x00,0x4E,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",13*/ /* (4 X 16 , 黑¨²体¬? )*/ {0x00,0x4E,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",13*/ /* (4 X 16 , 黑¨²体¬? )*/ {0x00,0x4E,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",13*/ /* (4 X 16 , 黑¨²体¬? )*/ {0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00},/*"I",14*/ /* (4 X 16, 黑¨²体¬? )*/ {0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",15*/ /* (4 X 16, 黑¨²体¬? )*/ {0x78,0x38,0x10,0x78,0x00,0x00,0x00,0x00},/*"m",16*/ /* (4 X 16, 黑¨²体¬? )*/ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",17*/ /* (4 X 16, 黑¨²体¬? )*/ {0x40,0x68,0x58,0x00,0x00,0x00,0x00,0x00},/*"z",18*/ /* (4 X 16, 黑¨²体¬? )*/ {0x40,0x68,0x58,0x00,0x00,0x00,0x00,0x00},/*"z",19*/ /* (4 X 16, 黑¨²体¬? )*/ {0x10,0x68,0x68,0x00,0x00,0x00,0x00,0x00},/*"s",20*/ /* (4 X 16, 黑¨²体¬? )*/ {0x30,0x68,0x58,0x00,0x00,0x00,0x00,0x00},/*"e",21*/ /* (4 X 16, 黑¨²体¬? )*/ {0x20,0x68,0x78,0x00,0x00,0x00,0x00,0x00},/*"a",22*/ /* (4 X 16, 黑¨²体¬? )*/ {0x00,0x4E,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",23*/ /* (4 X 16, 黑¨²体¬? )*/ }; void lcd_init_display() { uint8_t page_address; uint8_t column_address; for (page_address = 0; page_address < 4; page_address++) { st7565r_set_page_address(page_address); for (column_address = 0; column_address < 128; column_address++) { st7565r_set_column_address(column_address); st7565r_write_data(0x00); } } } void lcd_display(char geshu,char hang,char lie) { uint8_t page_address; uint8_t column_address; uint8_t i=0; char j=0; lie*=8; j=geshu; for (page_address = (hang-1); page_address < hang; page_address++) { st7565r_set_page_address(page_address); for (column_address = (lie-8); column_address < lie; column_address++) { st7565r_set_column_address(column_address); st7565r_write_data(aa[j]); i++; } } } void lcd_display_str(char zishu) { char ii; if(zishu>16) { for(ii=0;ii<16;ii++) { lcd_display(ii,1,(ii+1)); } for(ii=16;ii<zishu;ii++) { lcd_display(ii,2,(ii-15)); } } else { for(ii=0;ii<zishu;ii++) { lcd_display(ii,1,ii); } } } int main(void) { board_init(); sysclk_init(); st7565r_init(); st7565r_set_page_address(0); st7565r_set_column_address(0); lcd_init_display(); lcd_display_str(28); gpio_set_pin_high(NHD_C12832A1Z_BACKLIGHT); while(1) {;} }
|