this seems like a very stupid query, but it may be so simple i cant figure it out. Embarrassing to have to ask this...
using ZBasic i have a BPI-216L http://www.seetron.com/slcds.htm backpack LCD display tied to COM1 -
i can write to it with Console.Write(line) and Debug.Print commands just fine (after reconfiguring the port for 9600 baud) but i cant get the ascii commands out to it.
But i need to send commands to it that set the cursor position and reset/clear the display etc.
The display recognizes a command by preceeding the command with an ASCII 254 sent to it followed by the command (in the range of 128-253 decimal).
when i send Console.Write 254 & 1 (which is supposed to be a reset/clear screen command, it appears that an implied conversion occurs that appears on the serial port out as three characters representing "254", which of course the LCD sees as just ascii 2 followed by ascii 5 followed by ascii 4 then an ascii "1". Four bytes on the serial port.
similary to move the cursor to the first line column 1, the sequence is
console.write 254 & 128.... but what is emitted on the serial port is "254128"
i have tried all kinds of variants/conversions/byte arrays print statemenets etc... always wants to convert my hex FE/dec 254 to "254" on the output.
what is the obvious magic syntax cookie that i am missing that will allow me to take control of the LCD so that i can sent it a value over 127 decimal?
feel like an idiot asking this, but i guess thats what this forum is for...
regards,
-bob
Newbie to ZBasic - BPI-216 Backpack LCD, how to send control
Re: Newbie to ZBasic - BPI-216 Backpack LCD, how to send con
Console.Write requires a String type parameter. Moreover, if you specify a numeric value, the compiler will add code to convert the value to a string type. That's why you see "2541" going out the serial port. In other words, you got exactly what you asked for.rpb wrote:when i send Console.Write 254 & 1
What you probably want is a two-byte string with the first byte having the value 254 and the second byte having the value 1. You can get this by using the Chr() function and the & operator, e.g.
Code: Select all
Console.Write(Chr(254) & Chr(1))
Code: Select all
Dim bv(1 to 5) as Byte
bv(1) = 254
bv(2) = 1
Dim s as String
s = MakeString(bv.DataAddress, 2)
Console.Write(s)
- Don Kinzer
You might get a little help from some of the uploaded files in the "files" section of the forum. In particular there is the "SparkFun serial LCD adapter API" which shows how one method to access the functions of a serial backpack-type LCD. The general idea being high-level and low-level functions. The user API uses primarily high-level functiones which access the low level functions.
THe advantage of this is that you can change the low-level functions to suit new hardware, but maintain the SAME high level access functions. Your software does not keed to know that the hardware changed!
This API uses some older, but still functional, techniques and syntax. ZBasic has made siginificant advances since this code was written. It will show you how to do the string manipulation, and how to use com ports and their queues.
-Tony
P.S. Those scott edwards displays are a little pricey. Check out www.sparkfun.com for some alternatives. NB, the backlight control functions in the past were not well implemented, but that is likely to have changed in the last couple of years.
THe advantage of this is that you can change the low-level functions to suit new hardware, but maintain the SAME high level access functions. Your software does not keed to know that the hardware changed!
This API uses some older, but still functional, techniques and syntax. ZBasic has made siginificant advances since this code was written. It will show you how to do the string manipulation, and how to use com ports and their queues.
-Tony
P.S. Those scott edwards displays are a little pricey. Check out www.sparkfun.com for some alternatives. NB, the backlight control functions in the past were not well implemented, but that is likely to have changed in the last couple of years.