KS0108 Component Symbols Question?? (postponed)

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

KS0108 Component Symbols Question?? (postponed)

Post by Jordy101091 »

Hi all,

Im very busy with my new project.
What I really need are some costume symbols to show receiving strenght SD card thermometer symbol ect.

My question can a make these symbols in for example: GLCD Font Creator
and copy the hex data into the ASCII Pixel Data Table in the costum component.

If somebody can explain how to do this, that would be nice.
It a lot of work to make costum chars :p

Regards Jordy
Last edited by Jordy101091 on Fri Aug 10, 2012 10:49 pm, edited 1 time in total.
the will to learn, should not be stopped by any price

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Benj »

Hi Jordy,

You could use monochrome bitmaps images if you have access to a SD card in your application.

Otherwise I would maybe create a macro to manually draw your graphics using the pixel macro or maybe create an array of data in RAM or ROM and then cycle through this dynamically.

Another option might be to create a monochrome bitmap of what you want and then translate the data for this into your array variable using a text editor, textpad seems to work quite well with binary files like bitmaps.

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

Hi benj,

At the moment I don't have access to my sd card because I have the wrong footprint selected for my level translator :evil:
I need to fix this soon :oops:

How can I use the rom or ram location for drawing these symbols. can you explain this to my perhaps with a example.
If you wish I can upload a txt file that contains the hex value of every symbol I want to use.

Regards Jordy
the will to learn, should not be stopped by any price

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

Hi benj,

Can you help me out with this, I cant figure out on how to show my costum graphics its driving me nuts.
Hope you have some time tomorrow to help me.

Here is some data of a symbol that stand for "No RF Signal"

Code: Select all

0xF8, 0x00, 0x88, 0x00, 0x50, 0x00, 0x20, 0x00, 
0x24, 0x40, 0x22, 0x80, 0x21, 0x00, 0x22, 0x80, 
0x24, 0x40,
Image

Hope we can figure something out,

Regards Jordy
the will to learn, should not be stopped by any price

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Benj »

Hi Jordy,

This should help and I've checked that it simulates on a standard gLCD so you can test things out before moving it over to your display.
Attachments
gLCD_Custom_Symbol.fcf
(14.5 KiB) Downloaded 470 times

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

Nice Ben,

I will check it as fast as possible I'm not home wright now but when I tested this I will let you know.
the will to learn, should not be stopped by any price

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

Hi ben,

I really like you solution superb, but before I can use it I need to understand what your doing, can you explain this to me so I can use this with
this symbol and the others that I want to include.
That would be greet.

Regards Jordy
the will to learn, should not be stopped by any price

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Benj »

Hi Jordy,

Right first of all I am filling a string buffer with the custom symbol data. The buffer must be at least big enough to hold the symbol data but it doesn't matter if it's bigger. You could use one string buffer for all the symbols you wish to show or you could create a string buffer for every symbol. If RAM is becoming an issue then you can move the buffers into ROM and use C calls but this will not simulate. Using a single buffer you would have to populate then draw then populate then draw....

The macro itself has the following parameters.

width - width of the symbol in bytes
height - height of the symbol in rows (pixels)
symbol data - string buffer
X, Y - Pixel coordinates specifying top left pixel of where the symbol will be drawn

The macro will draw out the contents of the buffer like this. assume a width of 3 and height of 2.

0,1,2
3,4,5

Now I am outputting the data to the display a pixel at a time. I seem to remember that with the KS0108 type displays you can manipulate a byte at a time so this could be a way to speed up the symbol outputting if it is too slow on the hardware with a lot of symbols. If you do decide to do this then beware as you might have to be very specific about the order you draw the symbols or they might corrupt each other if they overlap a byte boundary. At the moment my function only displays pixels which are set, you could change this so that in the no branch of the decision you switch the foreground colour to white, draw the pixel and then change the colour back. This would ensure that there is no leftover data behind the clear portions of the symbol but again be aware about the byte boundary issue.

Example Symbol Simulation
symbol.JPG
symbol.JPG (3.47 KiB) Viewed 14914 times
Example v5 Macro - Macro -> Import
Print_Symbol.fcm
(4.63 KiB) Downloaded 396 times

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

Hi benj I have loaded your program into my PIC, but it doesnt work that well.
The pixels are all over the place, dont know what wrong. I send you my program by PM hope you can spot something.
the will to learn, should not be stopped by any price

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Benj »

Hi Jordy,

Hmm I am surprised by that, I wonder if your setpixel function is not working correctly and this is causing the corruption. Can you print text and draw diagonal lines to the display without any corruption? Can you also send me the project C file so I can see how the setpixel function is coded, I think it should be a read-modify-write type routine that is required to mask off the single pixel from the 8 bit data byte in the display's RAM.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Benj »

Looking at the C file the pixel modify function does seem to be correctly doing the read/modify/write process. How about the draw line functions do these work as expected when drawing diagonal lines?

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

Shoot sorry ben,

Not tested jet I will do that now.
the will to learn, should not be stopped by any price

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

Hi benj,

I have tested the draw line function and this is my result:

Image

I dont know if I confugerd the x2 and y2 correclty but I have set these to 1 and 1

This is the result with plot pixel

Image
the will to learn, should not be stopped by any price

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

Ben, a quick question different subject,

I'm using my rotary encoder to dail in a temperature lets say 25.9 or 259.
In my flowcode I have set rotary_count ad 250 default this is the same variable that holds the result of the count encoder macro.

When I turn my rotary encoder to increment I'm expecting to see 251, 252, 253 but it does not, I need to turn the encoder until it reaches 250 and then continues as aspected.
Is this a bug or something.

Basically I want to count up and down from 250 is this possible.

Regards Jordy
the will to learn, should not be stopped by any price

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

Hi ben,

I have found a solution to my rotary encoder problem i just used this calculation:

Rotary_Count = 700 + Rotary_Count and works perfectly increment aswell in decrement.

Man, what is flowcode fantastic software.

Regards Jordy

PS, I have send you my C code by PM if not already have it chears.
the will to learn, should not be stopped by any price

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: KS0108 Component Symbols Question??

Post by JonnyW »

Hello. Ben is away for a fortnight. I can help a little.
I dont know if I confugerd the x2 and y2 correclty but I have set these to 1 and 1
The screenshot you have posted looks this way. The x2 and y2 should be (to draw a single pixel) x1+1 and y1+1. What you are seeing on your screenshot is a line drawn from (1, 1) to whatever your (x1, y1) is.
Hi benj I have loaded your program into my PIC, but it doesnt work that well.
The pixels are all over the place, dont know what wrong. I send you my program by PM hope you can spot something.
Could you PM me your program please?

What I would do is in the macro Ben sent you, change the line:
.xpix = .xpix + 1
To:
.xpix = .xpix + 8

This then means 'width' is not the number of bytes, but the number of pixels, so pass in 8 as the width to use one byte per line of your monochrome bitmap (instead of passing 1 for the current macro). There are a few other ammendments.

I have made the changes here and posted a demo - I have only tested this in simulation though.
bitmap_demo.fcf
Demo of Bens macro
(13.67 KiB) Downloaded 347 times
Jonny

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

Hi Jonny,

The first thing I've don was chnaging the calculation to .xpix = .xpix + 8 the result was the same only in a different pattern.
Then a copyed you program in to my flowcode and tryed that, it was suprising to see only the vertical line of my antena symbol showed up not else, strange. The A tryed your smiley face to test, but it showed only 4 dots in a vertical line.


Also the compiler gives me a warning message:

Code: Select all

AquaTronics_Controller_V2.0.c(7019:58): warning: local variable 'FCL_PRINT_SYMBOL_YPIX' may be used uninitialized
AquaTronics_Controller_V2.0.c(7030:93): warning: local variable 'FCL_PRINT_SYMBOL_YPIX' may be used uninitialized
AquaTronics_Controller_V2.0.c(7045:26): warning: local variable 'FCL_PRINT_SYMBOL_YPIX' may be used uninitialized
AquaTronics_Controller_V2.0.c success
Dont know what that is???

I will sen dyou my program wright now
the will to learn, should not be stopped by any price

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

Wait a minute,

I was to soon with clicking the submit button,

Image

This is some kind of smiley but not what you have in the demo file

This is a picture of symbol:

Image
the will to learn, should not be stopped by any price

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

How can I modify your code to work with symbol width of 11 or even 20,
Can you tell me,

Thanks in advance,

Jordy Kleian
the will to learn, should not be stopped by any price

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: KS0108 Component Symbols Question??

Post by JonnyW »

Hi Jordy. Does that mean the code is working OK now?

To modify this to show an image of any width or height simply write out the bit-pattern. I would suggest for testing just have an empty program with your bitmap drawing to the LCD - this makes debugging much easier.

Remember that the bits in the X are always byte-aligned, so if you want 11 pixels by 8, say, then your bitmap is 2 bytes by 8 bytes or 16 bytes long.

This is not true in the Y - if you want a bitmap 8 pixels by 11 in the y your bitmap will be 11 bytes long.

Jonny

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

Jonny,

The program is not working I have come to the point where I can display this image:

Image

The settings of the macro are width 8 height 8
After I have changed this to width 11 height 8 I get this image:

Image

Can you tell me what part of youre macro I need to edit.

Thanks in advance

Jordy
the will to learn, should not be stopped by any price

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: KS0108 Component Symbols Question??

Post by JonnyW »

Hi Jordy. What you are seeing is what the computer thinks is an 8x8 bitmap 'smeared' over 11 pixel lines. You need to pad each line out to a byte boundary based on your 11x8 bitmap.

Here is a modified file showing a bitmap and the same image as 11x8 - runs in simulation.

Note I have used strings to denote the data fror convenience. I would advise storing the data as a byte array - null terminating strings do not behave well otherwise (i.e. adding a \x00 character to the string). I believe you can pass byte arrays as strings to macros.
bitmap_demo.fcf
(13.99 KiB) Downloaded 316 times
This diagram hopefully explains what is being done with the pixels.
large_bitmap.png
(3.3 KiB) Downloaded 7212 times
For any width of your bitmap, (say 11) round the value up to a multiple of 8 (so 16), divide by 8 (so 2) and this is the number of bytes per line you need.

Jonny

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

Thanks Jonny for the detailed explanation you gave me.
I will try this when I'm back home from work.

Thanks again,

Regards Jordy
the will to learn, should not be stopped by any price

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: KS0108 Component Symbols Question??

Post by Jordy101091 »

Hi Jonny,

I'm having a hard time to put your detailed explenation to practise,I dont ffuly understand what you are trying to say these are the bits that confuses me.
You need to pad each line out to a byte boundary based on your 11x8 bitmap.
I would advise storing the data as a byte array - null terminating strings do not behave well otherwise (i.e. adding a \x00 character to the string).
I dont know what you mean, would you mind to explain this again for me. If it helps I use this program to make my costum characters : http://www.iseasoft.com/bitfontcreatorpro.htm
the will to learn, should not be stopped by any price

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: KS0108 Component Symbols Question??

Post by JonnyW »

Hello. I will try to explain better.
You need to pad each line out to a byte boundary based on your 11x8 bitmap.
Th image is drawn as a series of horizontal lines. What I mean is that each line of pixels must be rounded to a whole number of bytes so if you have 11 pixels, one bit per pixel, this equals 11 bits. The next byte 'boundary' is 16 bits so each line of pixels is represented by 2 bytes.
I would advise storing the data as a byte array - null terminating strings do not behave well otherwise (i.e. adding a \x00 character to the string).
In my example I passed a string to the bitmap drawing macro. This is generally bad practice as a lot of 'empty' pixels may result in an empty byte '0x00' which in strings can be mistaken as the end of the string. If you tell the compiler you are using an array of bytes instead of a string it will not treat the data as text and make this assumption.

I do not know that font editor program but if it is capable of generating bitmap fonts it probably does all the byte-alignment you need itself. Personally I would get hold of a good hex editor and load the file into this (try HxD). View in bytes, or bits if you can and align to the number of bytes you expect per line. If it is the right amount then you will have the same number of lines as in your bitmap.

Also try simulating on a very simple program to get the logic of your bitmap drawer right. Don't add code you are unsure about to an already complex program - it is a recipe for disaster. You should be able to modify the example I posted to do what you want, then export the relevant macros into your main project.

Good luck,

Jonny

Post Reply