C++ using customer characters? OK204-25-USB

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

Moderators: Henry, Mods

Post Reply
mascenzi
LCD?
Posts: 9
Joined: Thu Apr 25, 2019 9:18 am

C++ using customer characters? OK204-25-USB

Post by mascenzi »

What am I missing? So I've been messing with my OK204-25-USB for about a week. I've figured out the communication on most of the functionality. Creating and using bars, medium/large numbers, moving cursor around, displaying text, etc. However, creating custom Characters I'm confused.

Lets look at the command for Creating a Custom Character {254, 78}. Here you supply the ID for the character and 8 bytes that will represent a 5x8 batch of pixels.

Can I then use that custom character without saving it? Or do I have to save it first? I understand if I switch bank or power down that character will be lost, but can I use it util either of those occur?

Now lets say I have to save it first. No problem. So I'll use Saving Custom Characters {254, 193}. Here I supply the bank I want to store it in, the ID of the custom character and then 8 bytes that, again, represent a 5x8 batch of pixels.

Whats the reason for having to supply the 8 bytes again if I've already created it previously? Why couldn't I just supply the bank I want to store it in and the ID I assigned to the custom character when I used the command {254, 78}?

Ok lets say I save it in bank "0" and ID "1". How do I use it? How do I send it to the display? I don't see any commands to use a custom character in the manual? Am I overlooking it? I see how to load a bank of custom characters [254, 192], but once I have the bank I want, how do I call say ID 4?

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: C++ using customer characters? OK204-25-USB

Post by Daniel Divino »

Hi mascenzi,

It won't be necessary for you to save your custom characters in order to use them.
Once a character is created, you can draw it on screen it by sending the assigned custom character ID to the display.

I have a pseudo code example demonstrating how to use custom characters below:

ClearScreen(); //Clears the display
CreateACustom(0x00, 0x0A, 0x0A, 0x0A, 0x00, 0x00, 0x11, 0x0E, 0x00); //Creates a custom smiley face character with an ID of 0
WriteString(HelloWorld); //Writes 'Hello World' to the display
WriteValue(0x00); //Sends Hex value 0x00 to the display. This will draw the custom smiley face character on screen

Using saved custom characters will follow a similar procedure:

ClearScreen(); //Clears the display
SaveACustom(0x00, 0x00, 0x0A, 0x0A, 0x0A, 0x00, 0x00, 0x11, 0x0E, 0x00); //Saves a custom smiley face character with an ID of 0 in memory bank 0
WriteString(HelloWorld); //Writes 'Hello World' to the display
LoadCustomCharacters(0x00); //Loads custom character bank 0
WriteValue(0x00); //Sends Hex value 0x00 to the display. This will draw the custom smiley face character on screen

Hopefully this helps clarify how custom characters can be used.

If you have any other questions or concerns, please let me know!

Cheers,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

mascenzi
LCD?
Posts: 9
Joined: Thu Apr 25, 2019 9:18 am

Re: C++ using customer characters? OK204-25-USB

Post by mascenzi »

Daniel,

Thank you so much for following up with me. I'm glad to hear that I can skip the saving part and just store them in my program and send them as I need them. This gives me a lot more options for creating imagery on the display.

However, I'm still not sure what commands I'll need to send. In your pseudo code you give:

Code: Select all

ClearScreen(); //Clears the display
CreateACustom(0x00, 0x0A, 0x0A, 0x0A, 0x00, 0x00, 0x11, 0x0E, 0x00);
WriteString(HelloWorld);
WriteValue(0x00); 
When I'm writing the software the first three are easy. The commands I would use are.

Code: Select all

unsigned char clearScreen[] = {0xFE, 0x58};
unsigned char customChar[] = {0xFE, 0x4E, 0x0A, 0x0A, 0x0A, 0x00, 0x11, 0x0E, 0x00};
unsigned char message[] = "Hello World!";
and I would send each of them this way.

Code: Select all

WriteFile (my_port, &clearScreen, sizeof (clearScreen), &bytes_written, NULL);
WriteFile (my_port, &customChar, sizeof (customChar), &bytes_written, NULL);
WriteFile (my_port, &message, sizeof (message), &bytes_written, NULL);
but with the WriteValue(0x00);

Would that just be

Code: Select all

unsigned char value[] = {0x00};
or is there a command that I need to send like

Code: Select all

unsighed char value[] = {0xFE, 0x??, 0x00};

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: C++ using customer characters? OK204-25-USB

Post by Daniel Divino »

Hi Mascenzi,

You should be able to send either of the following:

WriteFile(my_port,"\0x00", 1, &bytes_written, NULL);

or

unsigned char b = 0x00;
WriteFile(my_port,&b, 1, &bytes_written, NULL);

No command will be needed to draw the custom character on the screen.

Cheers,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

mascenzi
LCD?
Posts: 9
Joined: Thu Apr 25, 2019 9:18 am

Re: C++ using customer characters? OK204-25-USB

Post by mascenzi »

Daniel,

Thank you for your time and help.

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: C++ using customer characters? OK204-25-USB

Post by Daniel Divino »

No worries Mascenzi,

Let me know if you have any other questions!

Thanks,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

cdeveau
LCD?
Posts: 4
Joined: Tue Mar 16, 2021 2:51 pm

Re: C++ using customer characters? OK204-25-USB

Post by cdeveau »

I have a similar question about how to do this using ASCII characters/decimal codes. I'm essentially using VB, and I'm familiar with using something like:

print #2, CHR(254),CHR(71),CHR(16),CHR(1), "Text"

to put the word Text in the upper right corner of the display. How do I call the startup bank using 192 and 0, and then the characters? I'm effectively trying to recreate the logo on the startup screen on an info screen.

Thanks in advance!
Cecil

Raquel
Matrix Orbital
Matrix Orbital
Posts: 796
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Re: C++ using customer characters? OK204-25-USB

Post by Raquel »

Hello Cecil,

Do you only need to put "Text" at the upper right corner of the display as your start up screen? Try this:
254 64 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 T e x t
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 // 20x spaces
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 // 20x spaces
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 // 20x spaces

If you need to use the custom characters you created, just simply put the index, for eg:
254 64 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 T e x t
0 1 2 3 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 // custom characters 0-3 placed on second row, columns 1 to 4
4 5 6 7 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 // custom characters 4-7 placed on third row, columns 1 to 4
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 // 20x spaces

You will only need to use Load Custom Characters 254 192 command when during run time you want to load the predefined custom character banks (0-4). At power up, Start-Up Characters bank is loaded (default).

Hope this helps.
Raquel Malinis
Design and Development
Matrix Orbital

Post Reply