|
|
View previous topic :: View next topic |
Author |
Message |
art
Joined: 21 May 2015 Posts: 181
|
shift right/left using Flex_LCD420.c |
Posted: Mon Mar 12, 2018 2:28 am |
|
|
Hi,
I would like to shift right/left "Hello to the world" using Flex_LCD420.c .
However, it will display the same thing in line 1 and line 3 while line 2 will be same with line 4. I just want it to display in line 1 and 2 only.
What is wrong with below code ? Please help me.
Code: |
#include <18F4550.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#include "Flex_LCD420.c "
void lcd_scroll_right(void)
{
lcd_send_byte(0, 0x1E);
}
void lcd_scroll_left(void)
{
lcd_send_byte(0, 0x18);
}
void main()
{
int8 i;
lcd_init();
lcd_putc("\f"); // Clear the LCD
delay_ms(100);
lcd_putc("Hello to the Side scrolling \n");
lcd_putc("world. demo. ");
delay_ms(1000);
while(1)
{
for(i = 0; i < 20; i++)
{
lcd_scroll_left();
delay_ms(200);
}
delay_ms(2000);
}
} |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Mar 12, 2018 4:51 am |
|
|
You need to look at your LCD module's datasheet and see the 'memory map' for the addresses of the 'data display RAM' to see why it is happening.
You should see that line 3 is after line 1 and that the '21st' character of line 3 'wraps' around to line 1, character 1. The same operation happens with line 4 and 2.
Your scrolling function needs to have limits set in it. What I've done in the past is have a 2nd 'display buffer' of 20 bytes long. I scrolled the data within THAT buffer, then simply sent the buffer to the LCD. This doesn't use the LCD internal command of 'shift', you're in control.
You may find 'scrolling' code here (just try the 'search' button up top), if not Goggle will, something like 'LCD module scrolling' should limit the hits to less than a million...
Jay |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|