code examples.

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

xull1x
LCD?
Posts: 8
Joined: Sat Dec 01, 2001 4:00 pm
Location: markham, on
Contact:

Post by xull1x »

i'm writing a program in perl. i'm having a hard time.. figuring out all the control codes.

ie. to turn on a black light.. you have to do something like
sub backlighton_lcd { syswrite LH, sprintf ("%cB%c", 254, 0); }
where as LH is a filehandle to your serial port. (254 ascii, B(66 ascii), 0 ascii).

can someone give me examples of similar stuff.. like ie creating custom characters, moving the cursor around, etc.

also henry, where can i find sources to your programs? :-) thanks.
Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3014
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

depends on the program, some i have source for some I don't... let me know specificaly what you want. All of our software written here is in Borland C++ Builder 5.0, with ZCOMM serial library...
Henry J.
President
Matrix Orbital
xull1x
LCD?
Posts: 8
Joined: Sat Dec 01, 2001 4:00 pm
Location: markham, on
Contact:

Post by xull1x »

doesn't matter. paste any bc code..
i just need to look at sample code snippets to figure out.. how to move the cursor around (ie what ascii char's to pass.. to the serial port).
xull1x
LCD?
Posts: 8
Joined: Sat Dec 01, 2001 4:00 pm
Location: markham, on
Contact:

Post by xull1x »

Alpha Demo's source would be nice.
Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3014
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

Turning GPOs on and of, and writing text to the screen

Code: Select all

 if (CheckBox1 -> Checked)
  {
    ZComm1->WriteCommByte(0xfe);
    ZComm1->WriteCommByte('W');
    ZComm1->WriteCommByte(1);  //turns GPO on
    ZComm1->WriteCommByte(0xfe);
    ZComm1->WriteCommByte('W');
    ZComm1->WriteCommByte(2);  //turns LED on
    ZComm1->WriteCommByte(0xfe);
    ZComm1->WriteCommByte('G');
    ZComm1->WriteCommByte(1);
    ZComm1->WriteCommByte(1);
    ZComm1->Text=("Fan #1 [ON] /  OFF  ");
  }
  else
  {
    ZComm1->WriteCommByte(0xfe);
    ZComm1->WriteCommByte('V');
    ZComm1->WriteCommByte(1); //turns GPO off
    ZComm1->WriteCommByte(0xfe);
    ZComm1->WriteCommByte('W');
    ZComm1->WriteCommByte(2); //turns LED off
    ZComm1->WriteCommByte(0xfe);
    ZComm1->WriteCommByte('G');
    ZComm1->WriteCommByte(1);
    ZComm1->WriteCommByte(1);
    ZComm1->Text=("Fan #1  ON  / [OFF] ");
  }
}
_________________
Henry J.
Technical Support
Matrix Orbital

<font size=-1>[ This Message was edited by: Henry on 2001-12-02 01:18 ]</font>
Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3014
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

Clearing the screen:

Code: Select all

{
  ZComm1->WriteCommByte(0xfe);
  ZComm1->WriteCommByte('X');
}

_________________
Henry J.
Technical Support
Matrix Orbital

<font size=-1>[ This Message was edited by: Henry on 2001-12-02 01:18 ]</font>
Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3014
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

backlight on and off:

Code: Select all


{
 static int backlighton = true;
  if (backlighton)
   {
    ZComm1->WriteCommByte(0xfe);
    ZComm1->WriteCommByte('F');
    backlighton=false;
   }
   else
   {
    ZComm1->WriteCommByte(0xfe);
    ZComm1->WriteCommByte('B');
    ZComm1->WriteCommByte(0);
    backlighton=true;
    }

}
Henry J.
President
Matrix Orbital
xull1x
LCD?
Posts: 8
Joined: Sat Dec 01, 2001 4:00 pm
Location: markham, on
Contact:

Post by xull1x »

cursor moving? :smile: so far i have this:
(note this is perl)

# sub that clears the LCD.
sub clear_lcd { syswrite LH, sprintf ("%c", 12); }

#move the cursor down by a line.
sub cursorbyline_lcd { syswrite LH, sprintf("n"); }

#turn on backlight
sub backlighton_lcd { syswrite LH, sprintf ("%cB%c", 254, 0); }

#turn off backlight
sub backlightoff_lcd { syswrite LH, sprintf ("%cF", 254); }
Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3014
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

Cursor Left
ASCII 'L', Hex 4C, Decimal 76
Syntax 0xFE 0x4C

To move the cursor one space to the left of current position, send a command prefix followed by the character 'L'.

Cursor Right
ASCII 'M', Hex 4D, Decimal 77
Syntax 0xFE x04D


Go To Position
ASCII 'G', Hex 47, Decimal 71
Syntax 0xFE 0x47<column number><row number>
To set the current cursor position, send a command prefix followed by the character 'G' and two values defining the column and row of the desired cursor position. Example:

<command prefix> 0xFE
<command> 0x47
<column number> 0x01 to 0x14 for a twenty column display
<row number> 0x01 to 0x04 for a four line display

Go To Top Left
ASCII 'H', Hex 48, Decimal 72
Syntax 0xFE 0x48
This command resets the current cursor position to the top left of the LK screen. To execute this command send a command prefix followed by character 'H'.



_________________
Henry J.
Technical Support
Matrix Orbital

<font size=-1>[ This Message was edited by: Henry on 2001-12-02 01:26 ]</font>
xull1x
LCD?
Posts: 8
Joined: Sat Dec 01, 2001 4:00 pm
Location: markham, on
Contact:

Post by xull1x »

lastly custom characters? :smile:
henry.. i'll write you a nice program..
it uses Perl/Tk =)
xull1x
LCD?
Posts: 8
Joined: Sat Dec 01, 2001 4:00 pm
Location: markham, on
Contact:

Post by xull1x »

oh i just remembered.. cursor on / off?
Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3014
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

ok, this is a tad harder... but here it goes...

0xFE //command prefix
0x4E //this starts the custom characters
0x00 //0x00 to 0x07 for 8 custom characters.
0xC //here you just send 8 bytes of the custom character.
0x12 //Here is the degree symbol
0x12
0xC
0x00
0x00
0x00
0x00

ok, now it is defined.

so any time you need to display the character you send our 0x00 for the first custom character. 0x01, 0x02 and so on for the other. You only need to do the define once, then you just type the custom character. That simple.
Henry J.
President
Matrix Orbital
Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3014
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

On 2001-12-02 01:29, xull1x wrote:
oh i just remembered.. cursor on / off?
Cursor Blink On
ASCII 'S', Hex 53, Decimal 83
Syntax 0xFE 0x53

To turn on the blinking cursor at the current position, send a command prefix followed by the character 'S'. Please note that the blinking cursor is on by default at power up.

Cursor Blink Off
ASCII 'T', Hex 54, Decimal 84
Syntax 0xFE 0x54
To turn off the blinking cursor at the current position send a command prefix followed by the character 'T'.


Just check any of the manuals for the command set... some units have more then others, depending on the fetures of the specific display.
Henry J.
President
Matrix Orbital
Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3014
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

BTW, what are you making?
Henry J.
President
Matrix Orbital
xull1x
LCD?
Posts: 8
Joined: Sat Dec 01, 2001 4:00 pm
Location: markham, on
Contact:

Post by xull1x »

a bomb :wink: jk.. just a really good interface.. that works @ 19200 bps.. and does a lot of stuff.. like oscilliscope etc.

it's like the programs out there, but will be better. honestly.. those programmers don't know how to give an lcd the looks :wink:
Post Reply