Hello Kahjoo,
Firstly, to write a command byte to the display, you would use the function lcd_cmd() from within the file LCD.C. Because a 2 x 24 display uses the same controller chip as a 2 x 40 display, the commands are the same for either, including the position in display memory for the start of each line. There seems to be some confusion about this.
Since Line 1 of the display must remain intact, I don't think the shift left command will be suitable. My current understanding of your requirement is that you have a buffer that receives incoming serial characters. Normally the buffer characters will be displayed, starting with the first character. However, should the number of characters exceed the display length, you wish to display only the last portion of the buffer that will fit the display.
A method of handling this, without disturbing the first lne of the display, would be to re-write the contents of the buffer to the display, begining at the start of the line, whenever a new character is entered in the buffer. However, if the number of characters will overflow the display line, only the last 22 characters would be written to the display, with the 23rd position being effectively the current cursor location.
The following code represents a new function that should accomplish this, but has not been tested.
#include "string.h"
#define LCD_LINE_LEN 24
void LCDPutpart_L2 (char *sptr)
{
char *ptr;
int len;
lcd_cmd(0xC0); // Position cursor to L2 start
len = strlen (sptr);
if (len > (LCD_LINE_LEN - 2))
ptr = sptr + (len - (LCD_LINE_LEN - 2));
else
ptr = sptr;
for ( ; *ptr; ptr++)
LCDputch (*ptr);
}
This function would be used in the same manner as the existing LCDPuts_Line2() function.
Regards,
Mac