Hello Kahjoo,
To produce a rotating display, here is a possibility - but I have not actually tried it.
I note that there is a "display shift left" control command ($18) available, and I am assuming that this will shift the contents of display by one position. So the approach would be to position the cursor one position beyond the RH end of the display line you are using. Then following the write of each new character, send the display shift left command. Once the end of the message is reached, continue to send space characters to keep the display moving.
I would presume that the shift process would affect both display lines, and that eventually the line 2 characters will show on line 1.
A slightly different approach could be to write the whole message into the invisible locations beyond the RH end of the second line (assuming the whole message will fit). Then progressively shift the message to the left until it dissappears into the invisible portion of the first line. The display could then be switched off ($08 command), and the contents quickly shifted to the right ($1C command) until the initial position was regained, and the display turned on again ($0C command). The shift process could then repeat to give the impression of continuous rotation.
Regards,
Mac
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
Hi Kahjoo
A 2 x 24 LCD display has 2 x 40 addresses. That means that if you want to wrap to the second line after 22 characters, you need to do one of the following:
a. insert 18 dummy characters after the 22nd character and the next will then appear at the start of the second line
b. command the cursor to 0xc0 after the 22nd character so that is at the start of the second line (this is the preferred solution).
The same is also valid when the last character of the second line has been entered, to return to the start of the first line, either insert 18 dummy characters or command 0x80.
Go to my web site www.mjbc.ch and download the free program VIPpanel. It includes an LCD simulator (several different types) and allows all possible commands to be tested, including creating your own characters in a user friendly dialog. Command - View | LCD Control Panel - It includes detailed user documentation and can also be used to establish a connection to an Internet enabled LCD in my lab, which you can also control to be sure that the commands are really accurate... See the LCD at the web cam http://212.254.22.36:8080 and configure VIPpanel to communicate withe the IP address 212.254.22.36 Port 1923.
The VIPpanel also allows complete front panels to be designed (with upto 256 keys and 256 LEDs and an LCD of choce). It can then be used as virtual front panel (hence the name VIPpanel = VIrtual Prototyping Panel) and controlled either via the COM port or via a TCP/IP socket connection - all details are in the user manual.
Regards
Mark Butcher
www.mjbc.ch