Does anyone know how to make the texts scroll in an LCD display 16x2 characters....I used the code below and it does display the text but unfortunately i cant make it to scroll...please help...it would greatly apprecited...
[/code]#include <dos.h>
#include <string.h>
#define PORTADDRESS 0x378 /* Enter Your Port Address Here */
#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2
#define outportb
#define inportb
#define delay
void main(void)
{
char string[] = {"Testing 1,2,3 "
"It' Works ! "};
char init[10];
int count;
int len;
init[0] = 0x0F; /* Init Display */
init[1] = 0x01; /* Clear Display */
init[2] = 0x38; /* Dual Line / 8 Bits */
outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port - Make sure Forward Direction */
outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer (Register Select) */
for (count = 0; count <= 2; count++)
{
outportb(DATA, init[count]);
outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
delay(20); /* Larger Delay for INIT */
outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe (Enable)*/
delay(20); /* Larger Delay for INIT */
}
outportb(CONTROL, inportb(CONTROL) & 0xF7); /* Reset Select Printer (Register Select) */
len = strlen(string);
for (count = 0; count < len; count++)
{
outportb(DATA, string[count]);
outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
delay(2);
outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
delay(2);
}
}
Our new official repo is on github
LCD Smartie version 5.6 is released!
Download it now: https://github.com/LCD-Smartie/LCDSmartie/releases
LCD Smartie version 5.6 is released!
Download it now: https://github.com/LCD-Smartie/LCDSmartie/releases
Problems with scrolling function HELP!
Moderators: _X7JAY7X_, caesar, IFR, mattcro, limbo, Fast351, hydrolisk1792
-
- Forum Supporter
- Posts: 590
- Joined: March 8th, 2006, 1:58 pm
- Location: Scotland
The HD44780-type LCD modules don't have any intelligence built-in to do the scrolling. They can do a limited amount of scrolling functionality by internally shifting all characters left or right, but if you keep shifting, your text appears on another line - it doesn't scroll nicely within one line.
In LCDSmartie and other programs, the scrolling is done by sending the text to the LCD, waiting a short time (depending on scroll speed), then manipulating the text and sending again, manipulating and sending again... and so on.
The string must be shifted in software by 1 character each time, and the character that "drops off the end" must be added to the start of the string. You need to keep track of several things - the width of the display, the number of characters in the string, and the number of characters you've scrolled by...
If you can understand C code, have a look at the source code for the scroll plugin to get an idea how to do the scrolling.
Matt.
In LCDSmartie and other programs, the scrolling is done by sending the text to the LCD, waiting a short time (depending on scroll speed), then manipulating the text and sending again, manipulating and sending again... and so on.
The string must be shifted in software by 1 character each time, and the character that "drops off the end" must be added to the start of the string. You need to keep track of several things - the width of the display, the number of characters in the string, and the number of characters you've scrolled by...
If you can understand C code, have a look at the source code for the scroll plugin to get an idea how to do the scrolling.
Matt.