#include <unistd.h> #include <string.h> #include <io.h> #include "system.h" #include "LCD.h" //------------------------------------------------------------------------- void LCD_Init() { lcd_write_cmd(LCD_16207_0_BASE,0x38); usleep(2000); lcd_write_cmd(LCD_16207_0_BASE,0x0C); usleep(2000); lcd_write_cmd(LCD_16207_0_BASE,0x01); usleep(2000); lcd_write_cmd(LCD_16207_0_BASE,0x06); usleep(2000); lcd_write_cmd(LCD_16207_0_BASE,0x80); usleep(2000); } //------------------------------------------------------------------------- void LCD_Show_Text(char* Text) { int i; for(i=0;i<strlen(Text);i++) { lcd_write_data(LCD_16207_0_BASE,Text); usleep(2000); } } //------------------------------------------------------------------------- void LCD_Line2() { lcd_write_cmd(LCD_16207_0_BASE,0xC0); usleep(2000); } //------------------------------------------------------------------------- void LCD_Test() { char Text1[16] = "<NIOS II on UP4>"; char Text2[16] = "Nice to See You!"; // Initial LCD LCD_Init(); // Show Text to LCD LCD_Show_Text(Text1); // Change Line2 LCD_Line2(); // Show Text to LCD LCD_Show_Text(Text2); } //-------------------------------------------------------------------------
这是de2板子上自带的例子程序,我可以把它下载到板子上去,而且正常显示,但是,当我把
char Text1[16] = "<NIOS II on UP4>"; char Text2[16] = "Nice to See You!";中的内容改掉后(比如该为nice)就显示不正常,好象是Text中的内容必须是16个字符,但是我想自显示几个字符,怎么办?难道一定要用空格符补充到16个字符吗?再有NIOS2中的C函数库是怎么调用的,谁有着方面的资料,能共享一下吗?
望各位高手赐教!!!
|