Hi there guys! I have to utilize the half of the 16 x 2 LCD, where the first half prints strings and the other half prints variable floating values.
For example, the first half of the row 1 (char 1 to char 8) will print the words (INCHES, FEET, YARDS) when a button is pressed while the other half (from char 9 to char 16) will print numerical float values of 0.00 to 99999.99 when another button is pressed. The values changing in the other half will increment or decrement by value of 0.25...
By the way, i'm using a serial LCD that only uses the TX/RX and a data pin in the arduino, and the coding is different from the base LCD coding. Its data rate is 9600 bps.
I have a few parallax serial LCD's and they use special codes. MySerial is an instance of NewSoftSerial, to be replaced by Serial.
/*
Par27979.h - library for Arduino & Parallax 27979 serial display
Copyright (c) 2010. All right reserved.
This library is free software; you can redistribute it and/or
modify it as long as you leave this copyright notice intact
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef Par27979_h
#define Par27979_h
#define DISPLAYOFF mySerial.print((char)21)
#define DISPLAYON mySerial.print((char)22)
#define DISPLAYCLR mySerial.print((char)12); delay(10)
#define BACKLIGHTOFF mySerial.print((char)18)
#define BACKLIGHTON mySerial.print((char)17)
#define GOTOXY(x,y) mySerial.print((char)(128 + y*20 + x))
#define LEFT mySerial.print((char)8)
#define RIGHT mySerial.print((char)9)
#define LINEFEED mySerial.print((char)10)
#define FORMFEED mySerial.print((char)12)
#define RETURN mySerial.print((char)13)
#endif
By the way, i'm using a serial LCD that only uses the TX/RX and a data pin in the arduino, and the coding is different from the base LCD coding. Its data rate is 9600 bps.
How will I code it? Thanks for your replies...
There are no standard instruction sets for the various serial LCDs that are available. The answer to your question depends on which specific serial LCD you are using.
Back Space BS (0x08) – move cursor to the left by one character
Horizontal Tab HT (0x09) – jump cursor to the right by three characters
Carriage Return CR (0x0D) – move cursor to start of next line from the current cursor position.
You could create a sort of GotoXY(x, y) function from these three... but that would be quite tricky
Sorry, seems that you need to look at another Serial.lcd or rewrite the whole screen every time.
Too bad with the 0.25 increment. Otherwise my phi_prompt library would be perfect you. You can position the number anywhere you want but you do need to modify it to use your serial LCD.
The following blog page has some information and videos of the library in action:
At the moment the library doesn't handle floats. If you rescale your number to integers, you an use this library. The left half of line one can be a simple select list with select_list function. The when you select an option (say feet) you press enter to call input_integer() to render the right half. You may use up/down keys to change the number and confirm with enter. All in all you need 3 buttons and two phi_prompt function calls.
Back Space BS (0x08) – move cursor to the left by one character
Horizontal Tab HT (0x09) – jump cursor to the right by three characters
Carriage Return CR (0x0D) – move cursor to start of next line from the current cursor position.
You could create a sort of GotoXY(x, y) function from these three... but that would be quite tricky
Sorry, seems that you need to look at another Serial.lcd or rewrite the whole screen every time.
Using the code from Serial LCD in the Arduino Reference
void cursorSet(int xpos, int ypos){
Serial.print(254, BYTE);
Serial.print(71, BYTE);
Serial.print(xpos); //Column position
Serial.print(ypos); //Row position
}
How will I be having a cursorSet using the following codes:
Back Space BS (0x08)
– move cursor to the left by one character
Horizontal Tab HT (0x09)
– jump cursor to the right by three characters
Carriage Return CR (0x0D)
– move cursor to start of next line from the
current cursor position.
Clear Screen, ESC E (0x1B, 0x45)
– Clear the whole LCD screen
Cursor OFF, ESC C 0 (0x1B, 0x63, 0x30)
– Turn OFF cursor
Cursor ON, ESC C 1 (0x1B, 0x63, 0x31)
– Turn ON cursor
The hex codes above should be converted to decimal, for example...
That is the worst advice that you could possibly give. The codes are typically expressed in hex on the data sheet and that is the way they should be used.
When you convert the codes to another radix the absolute best that you can expect to accomplish is to get the conversion correct.
When you or someone else look at your code and try to compare it to the data sheet they first have to convert your decimal codes back to hex and again, the best that they can do is get it right.
Have you checked if the print(xx,BYTE) still works in arduino 1.0? I didn't find anything in the source code to support this call. Maybe someone can help me locate where the word BYTE is defined and whether it is 0.