马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
mikroE的编译器mikroC ,mikroBasic, mikroPascal 中提供了多种附加工具,如LCD定制字符工具,GLCD位图编辑器,七段编辑器,UART终端,UDP终端,HID终端,ASCII图表,现场注释编辑器,先进的统计功能,等等。
LCD定制字符工具可以设计为任意你想要显示的字符,以下以mikroC PRO for PIC编译器为例,说明如何使用LCD定制字符工具的。
比如,如果你想要在你的lcd 1602屏的第一行,第3个字符显示美元的单位符号 $ ,你可以在mikroC PRO for PIC 中打开LCD Custom Character 工具,然后点击需要显示出的字符,在此工具窗口的底部有两个图标:Generate Code ,CopyCode to Clipboard , 先点第一个Generate Code ,生成代码后,再点击CopyCode to Clipboard ,然后把代码粘贴到编译器的代码编辑器中。
代码如下:
// Lcd module connections sbit LCD_RS at LATB4_bit; sbit LCD_EN at LATB5_bit; sbit LCD_D4 at LATB0_bit; sbit LCD_D5 at LATB1_bit; sbit LCD_D6 at LATB2_bit; sbit LCD_D7 at LATB3_bit; sbit LCD_RS_Direction at TRISB4_bit; sbit LCD_EN_Direction at TRISB5_bit; sbit LCD_D4_Direction at TRISB0_bit; sbit LCD_D5_Direction at TRISB1_bit; sbit LCD_D6_Direction at TRISB2_bit; sbit LCD_D7_Direction at TRISB3_bit; // End Lcd module connections
const char character[] = {4,14,21,12,6,21,14,4};
void CustomChar(char pos_row, char pos_char) { char i; Lcd_Cmd(64); for (i = 0; i<=7; i++) Lcd_Chr_CP(character); Lcd_Cmd(_LCD_RETURN_HOME); Lcd_Chr(pos_row, pos_char, 0); }
void main(){ ANSELB = 0; // Configure PORTB pins as digital Lcd_Init(); // Initialize Lcd Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off CustomChar(1,3); }
如果要在LCD中显示两种定制的字符,请参考以下的代码。
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
// The first custom character
const char characterUp[] = {0,4,4,10,17,4,4,4};
void CustomCharUp(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(characterUp);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
// End of the first custom character
// The second custom character
const char characterDown[] = {4,4,4,4,17,10,4,4};
void CustomCharDown(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(characterDown);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
//End of the second custom character
void main() {
ANSEL = 0;
ANSELH = 0;
C1ON_bit = 0;
C2ON_bit = 0;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
while(1){
CustomCharUp(1,1);
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
CustomCharDown(2,1);
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
}
关于mirkoE 的编译器请参考 :http://www.hkemsys.com/ProductList.asp?ID=500&SortID=500&SortPath=0,500, |