Displaying custom characters

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

Moderators: Henry, Mods

Post Reply
gareth_curtis
LCD?
Posts: 2
Joined: Thu Feb 20, 2003 11:06 am

Displaying custom characters

Post by gareth_curtis »

Hi all,

I wonder if some could give me a few pointers on where I might be going wrong. I'm trying to set up some custom characters and can't get the unit to write anything to the screen.

This is the perl code I'm using:

my $set = sprintf "%cN%c%c%c%c%c%c%c%c%c", 0xfe, 0x07,
0x04, 0x0e, 0x1f, 0x00, 0x1f, 0x0e, 0x04, 0x00;

print DISPLAY "$set\n";

$char = sprintf ("%c", 0x07);

$test_string = "This is a test: $char";

display_text ($test_string);

I can get it to display normal text and the built in characters such as the -> but I can't seem to display anything which I try and create!

I'm not totally sure about the numbers in $set but it doesn't seem to matter what I put in.

Any help gratefully received.

Thanks,

Gareth.

linear
evil Dr. linear
evil Dr. linear
Posts: 288
Joined: Wed Aug 15, 2001 6:00 pm
Location: USA
Contact:

Post by linear »

What I see looks good. I'm guessing you've looked over the Display.pm you can download from MO.

The only thing I wonder about (based on what you're showing me) is display_text(). Does

print DISPLAY ""$char\n";

work at all? I can't see what display_text() is doing obviously.
BLK202A-4BR-BK + LK202-25-WB-V + LK204-25-V + VK204-25-V + LK-202-24-USB + MX212

gareth_curtis
LCD?
Posts: 2
Joined: Thu Feb 20, 2003 11:06 am

Post by gareth_curtis »

The display_text is just one of the functions I have in Display.pm

sub display_text
{

my ($text) = @_;

print DISPLAY "$text\n";

}

I tried what you suggested just:

print DISPLAY "$char\n";

but that doesn't put anything at all to the screen.

I don't understand it, I've been trying for ages and haven't got anywhere!

Perhaps I'm not defining the characters correctly?

I assume that all the LCD modules can do this, I guess so as the manual says that it can (LK202-25)

Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3014
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

Well.. let's take a more basic look at this.

First you have to define the custom char...


I'm going to do this in HEX, and then just show the bytes have to be sent.

0xFE //command refix
0x4E //define custom character command
0x00 //custom character value, we are defining 0

0xC //here you just send 8 bytes of the custom character.
0x12 //Here is the degree symbol
0x12
0xC
0x00
0x00
0x00
0x00

Now if you send 0x00 as the char, you will display the degree symbol.
Henry J.
President
Matrix Orbital

linear
evil Dr. linear
evil Dr. linear
Posts: 288
Joined: Wed Aug 15, 2001 6:00 pm
Location: USA
Contact:

Post by linear »

That's what he's doing. That capital N is the 0x4E in the sprintf string.
BLK202A-4BR-BK + LK202-25-WB-V + LK204-25-V + VK204-25-V + LK-202-24-USB + MX212

ctimmer
LCD!
Posts: 15
Joined: Thu Oct 25, 2001 6:00 pm
Location: Alaska

Post by ctimmer »

You didn't show how "DISPLAY" was opened/set.
Try setting binmode (binmode DISPLAY;). This should be used whenever non-ascii output is used.

Also try disabling output buffering on DISPLAY so all text is flushed after each print.

garethcurtis
LCD?
Posts: 1
Joined: Mon Jan 27, 2003 8:28 am

Got it working

Post by garethcurtis »

Hello,

Thanks for your input, I got it working, silly really. I was setting up the DISPLAY file to write to in a Perl module and setting up the custom characters in another module so it was just a simple case of moving the custom character command over to the module which was setting up the display.

Thanks,

Gareth.

Post Reply