Author Topic: Using both rows fo the LCD  (Read 4532 times)

jlipkowski

  • Guest
Using both rows fo the LCD
« on: July 09, 2003, 10:00:42 am »
Hello all,

I\'m programming the Mini-Max with the sdcc c-compiler.  The example (lcd.c) given with the compiler only uses one of the row of the LCD.  Could someone provide me with an example that uses both rows?

Many thanks in advance  :)

Robert Doinov

  • Guest
Re: Using both rows of the LCD
« Reply #1 on: September 21, 2003, 01:13:02 pm »
Hi . I just got the same mini-max set a few days ago and had the same problem. The key to writing to the 2nd row lies in the initialization of the LCD. If you look at the LCD.c example code that came with it...find the WriteCtrl() function. This controls the mode(1 line or 2 line display), line choice and cursor position of the LCD. I modified the CursorSet function to take commands to choose which line and which cursor position to use.

void Cursor(unsigned char line,unsigned char pos)
{      
     if(line==1)
     {WriteCtrl(8);//8 chooses first line of LCD
     delay(1);
               WriteCtrl(pos);//cursor position
     delay(1);
     }
     if(line==2)
     {WriteCtrl(12);//12 chooses 2nd line of LCD
     delay(1);
               WriteCtrl(pos);//cursor position
     delay(1);
     }
}

so if you call this function from main() and want to use line 1 with the cursor at the beginning and write a message. The syntax would be:

Cursor(1,0);
WriteLCD("my message");

it would be the same for line 2

Cursor(2,0);
WriteLCD("my message on line 2");

Hope this helps...if you want a copy of the entire source code I wrote that works...just e-mail me
and I\'ll be happy to send it to you---Rob
Robdaslav@yahoo.com