Hello.
After a long time, I decided to take my SmartGLCD from the drawer. But I can not go much further...
How should I use the User Code correctly? Well, I have this piece of code:
//--------------------- User code ---------------------//
//----------------- End of User code ------------------//
but when I put a code inside that, something like
char name;
name = 'x';
I have compilation errors I was able to execute code according to actions (eg pressing X button), but how could I do, for example, to get a data via USART and update a label? How to use interrupts?
I apologize for so many questions...
Best regards,
Leo
I need help to understand "User Code"
- jovana.medakovic
- mikroElektronika team
- Posts: 986
- Joined: 18 Dec 2018 10:36
Re: I need help to understand "User Code"
Hello,
Here is the link to the SmartGLCD page:
https://www.mikroe.com/smartglcd
There is a link to the examples for SmartGLCD, on the bottom of this page in the Downloads section, which can help you to write your project.
Regarding the error which you get, in this section, you can write:
char name = 'x';
After that, you can use name = 'x', but only inside some function.
Kind regards,
Jovana
Here is the link to the SmartGLCD page:
https://www.mikroe.com/smartglcd
There is a link to the examples for SmartGLCD, on the bottom of this page in the Downloads section, which can help you to write your project.
Regarding the error which you get, in this section, you can write:
char name = 'x';
After that, you can use name = 'x', but only inside some function.
Kind regards,
Jovana
Re: I need help to understand "User Code"
Hello jovana.medakovic,
Thank you! I did the download of the examples files. However, I still have some doubts. I'm trying to update a Label with the data coming from UART. Looks very simple, but didn't work.
main():
events_code:
Well, VelLabel is a string on screen. When I update its content and run DrawLavel, the VelLabel doesn't update correctly (shows a mix of other strings on screen).
How can I update a string with UART data? I'm going mad
Best regards,
Leo
Thank you! I did the download of the examples files. However, I still have some doubts. I'm trying to update a Label with the data coming from UART. Looks very simple, but didn't work.
main():
Code: Select all
Start_TP();
UART1_Init(9600);
while (1) {
Check_TP();
if(UART1_Data_Ready()){
rx_buffer = UART1_Read();
velocityShow(rx_buffer);
}
}
}
Code: Select all
void velocityShow(char string){
strcpy(VelLabel_Caption, string);
DrawLabel(&VelLabel);
}
How can I update a string with UART data? I'm going mad
Best regards,
Leo
- jovana.medakovic
- mikroElektronika team
- Posts: 986
- Joined: 18 Dec 2018 10:36
Re: I need help to understand "User Code"
Hello,
If you want to update a string on the label, you have to "delete" old text and then write a new.
Also, rx_buffer = UART1_Read() read only one byte. However, if you want to write some text on the label, you have to save it in some buffer, for example unsigned char message[20] = "";
I recommend you to look at UART1_Read_Text function in our help file.
Kind regards,
Jovana
If you want to update a string on the label, you have to "delete" old text and then write a new.
Also, rx_buffer = UART1_Read() read only one byte. However, if you want to write some text on the label, you have to save it in some buffer, for example unsigned char message[20] = "";
I recommend you to look at UART1_Read_Text function in our help file.
Code: Select all
void velocityShow(char string){
strcpy(Label1_Caption, " "); //char Label1_Caption[19] -> 19 space
DrawLabel(&Label1);
message[0] = string;
strcpy(Label1_Caption, message);
DrawLabel(&Label1);
}
Jovana
Re: I need help to understand "User Code"
Hello Jovana,
Thank you again But I can't erase the old string. I set the string in Visual GLCD as "40 km/h". So, I call this function:
In Smart GLCD, the "3" of "30 km/h" is written on top of the "4", showing an incorrect character. Works well only if I call DrawScreen(&Screen1), but calling DrawScreen is impractical slow
How can I fix it?
Thank you again But I can't erase the old string. I set the string in Visual GLCD as "40 km/h". So, I call this function:
Code: Select all
void atualizaVelocidade(char string){
strcpy(displayLabel_Caption, " ");
DrawLabel(&displayLabel);
strcpy(displayLabel_Caption,"30 km/h");
DrawLabel(&displayLabel);
}
How can I fix it?
- jovana.medakovic
- mikroElektronika team
- Posts: 986
- Joined: 18 Dec 2018 10:36
Re: I need help to understand "User Code"
Hello,
In the attachment, you can find the SmartGLCD Demo example.
After calibration, you will get this text on the display:
Smart GLCD 240x128
by MikroElektronika
When you send some characters from UART, instead of Smart GLCD 240x128 you will get 30 km/h.
Kind regards,
Jovana
In the attachment, you can find the SmartGLCD Demo example.
After calibration, you will get this text on the display:
Smart GLCD 240x128
by MikroElektronika
When you send some characters from UART, instead of Smart GLCD 240x128 you will get 30 km/h.
Kind regards,
Jovana
- Attachments
-
- SmartGLCD Demo.zip
- (415.73 KiB) Downloaded 93 times