Page 1 of 1

Displaying custom characters

Posted: Thu Feb 20, 2003 11:16 am
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.

Posted: Thu Feb 20, 2003 2:45 pm
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.

Posted: Thu Feb 20, 2003 3:07 pm
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)

Posted: Thu Feb 20, 2003 3:43 pm
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.

Posted: Tue Feb 25, 2003 12:54 pm
by linear
That's what he's doing. That capital N is the 0x4E in the sprintf string.

Posted: Wed Feb 26, 2003 1:03 pm
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.

Got it working

Posted: Wed Feb 26, 2003 3:00 pm
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.