Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

mikroC LCD text scrolling problem

Status
Not open for further replies.

shaomme05

Newbie level 5
Joined
Jun 12, 2009
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,358
mikroc lcd

hi, i am new with mikroC.

i want to scroll a 30 character text on a 16x2 lcd.
i used lcd_shift_right and lcd_shift_left to scroll text.

But some problems here.

My lcd has two rows only. when i scroll the 30 character text, the text scrolls over the two rows. half of the text scrolls at the 1st row and rest scrolls at the 2nd row.

moreover, both two row scrolls.

but I want to scroll the text at the second row only.
1st row has an another text which is to be static.

how to do this?

please help me!!!!
 

lcd scrolling text

First, you have to realize how the memory in an LCD is mapped. The two rows in memory aren't separate. Assuming you are using an HD44780-based display, the first row starts at like 0x00 and the second row starts at like 0x40. If you want to scroll just the second row, you need to write your own routine that will only shift the characters over from a certain address upward and loop them around back to that address.

A good LCD reference: http://home.iae.nl/users/pouweha/lcd/lcd.shtml
 
  • Like
Reactions: Eric_O

    Eric_O

    Points: 2
    Helpful Answer Positive Rating
mikroc scroll text in lcd

can u please give me a programming example?
 

lcd tekt

So you want me to do a bit of your homework :D? Well, one thing you can do is create a display buffer internal to the microcontroller like so:
Code:
char lcdBuffer[40][2];
#define MAX_ROWS 2
#define MAX_COLS 40
Then, make some functions that act as go-betweens between the built in lcd routines and your new buffer you just made:
Code:
void writeBuffer(char row, char col, char* text);
void shiftBufferRowRight(char row);
Inside your writeBuffer you would do something like this:
Code:
void writeBuffer(char row, char col, char* text)
{
  //first, write the text to your buffer:
  char offset = 0;
  while(1)
  {
    if (text[offset]==0) { break; }
    if (offset + col >= MAX_COLS) { row++; }
    if (row >= MAX_ROWS) { break; } //can't keep going if there isn't space
    lcdBuffer[col + offset][row] = text[offset];
    offset++;
  }
  //and when you are done with that, use those built commands to output the entire buffer into the lcd
  //...
}

void shiftBufferRowRight(char row)
{
  char i,j,temp;
  if (row> MAX_ROWS - 1 || row < 0) { return; } //if the row doesn't exist, don't bother
  //shift the given row right
  temp = lcdBuffer[39][row]; //the last character shall be first
  for(i = 0;i < MAX_COLS;i++)
  {
    j = lcdBuffer[i][row];
    lcdBuffer[i][row] = temp;
    temp = j;
  }
  //do the same thing that you did earlier to output the buffer to the lcd using those handy dandy built in functions...
}

Now, if that isn't a programming example I don't know what is. I am sure there are more efficient ways to do it, but I don't care enough to put too much thought into it.
 
  • Like
Reactions: Eric_O

    Eric_O

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top