To rotate the Character of the LCD display.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

To rotate the Character of the LCD display.

8,426 Views
Malaysia
Contributor I
Hi,
 
    For currently, I'm using 2x24 LCD display for my project. I'm facsing a problem if I want to display the character longer than 22 character. The attached file are my LCD module file and I'm using the M9S12NE64. How the things is the string data will send coming from Serial Comm, and will display in the LCD whatever input from Serial Comm. How I going to rotate the string from right to left and the first character will appear from the right again an continue moving from right to left. below are the example from what I've do.
 
 
char buff[32];
 
sprintf (buff, "The data is %c                        ", SCI);
LCDPuts_Line2(buff);
 
How to include the Serial data if the serial data is more longer. Thanks.
 
regards
 
kahjoo
Labels (1)
0 Kudos
5 Replies

2,007 Views
bigmac
Specialist III

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

 

0 Kudos

2,007 Views
Malaysia
Contributor I
Hi all,
 
 Thanks for reply. Sorry for not mension probaly. For the current project, we can used 2x40 for due to the size of the product, so we decide not to used the longer LCD. In the LCD have two line, but in the 1st line we already have the preset character to display on the line 1, so I can't change the character on the line. The line 2 are used for display the character inpur from Serial Comm. If the character from Serial Comm are more than 22 Character, then the character after 22nd will not display in the LCD.
 
   If the case occur then I need to rotate from Right to Left instead to display the full character from Serial Comm. By the way, when I probaly suitable to put the "display shift left (0x18)"? Can you show me how to write the function in this case?
 
Thanks
 
Regards
 
kahjoo
0 Kudos

2,007 Views
bigmac
Specialist III

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

 

0 Kudos

2,007 Views
Malaysia
Contributor I
Hi Bigmac,
 
  Thanks for your information. I've test it and it's works. So thanks a lot of your help. Once again Thank you.
 
Regards
 
Kahjoo
0 Kudos

2,007 Views
mjbcswitzerland
Specialist V

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

 

0 Kudos