Clearing some areas from the GLCD

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Clearing some areas from the GLCD

Post by CS » Tue Dec 05, 2006 8:20 pm

Hi all I'm back again with another problem.

I read some DS18S20 from the OW-Bus and display it on the GLCD with the KS0108 controller.

When I call the following code (We assume that oldDisplay = 1):

Code: Select all


Private Sub DisplayATemp()
    
    RomID = TempSensorA
    DS18S20.Convert
    
    Font.Style = 1
    
    Select oldDisplay
           Case 1
                TextAlign = taCenter
                GLCD.WriteStr(64,45, GetTempAsStr + "C")
           Case 2
                GLCD.WriteAt(60,25,GetTempAsStr, $BA, "C")
    End Select
End Sub

The programm writes every time on the same place and when it has written 3 or 4 times you can't read anything.

Therefor I wrote a little loop to clear the area before write the new temperature.

Code: Select all


Private Sub ClearArea()
       Dim y As Integer
       GLCD.Pen.Color = 0
                   
       For y = 44 To 64
           GLCD.Line(1,y,128,y)
       Next
End Sub

This loop clears the area with drawing a lot of lines with the pencolor 0. The problem is that this clearing methode is flicker.

Is there a better way, that I haven't found? I only found the GLCD.Cls command.
Please help again.

Thanks

CS

P.S.: An interessting thing is that I'm not able to display the little circle after the temperature outside the Serial Communicator!? Wich Fonttype are you using in the Serial Communicator? The "$BA" doesn't work.

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Tue Dec 05, 2006 8:40 pm

As you using Font.Style = 1 you will see that effect. You need to swap Font.Style = 0 before the print then put it back afterwards.

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Tue Dec 05, 2006 9:39 pm

Hi TimB,

when I'm using Font.Style = 0 then the grid will destroy and not only the grid also the next row loses 2 rows of pixel.

See the following thread:

http://www.sfcompiler.co.uk/forum/viewtopic.php?t=42

Do you have another solution?

Thanks

CS

P.S.: I have tested some other FontStyles and FontSizes. I can set the top position directly on the gridline but the bottom needs more space and that is the reason for the overdrawing. In other words: When I use the standard Font Arial the letter is shown in 8 X 5. The programm draws an area of 16X5 new. The result is that I lost my grid and also 2 rows of pixel from the next line. Hopefully you understand what I mean.

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Tue Dec 05, 2006 10:25 pm

I'm again,

when I use the SwordFish Fontgenerator and want to generate Arial Size 8 then the Generator says the maximum size is 10 X 10. But as I said before the programm draws 16X8

CS

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Wed Dec 06, 2006 12:28 am

I have to admit not have used the SF large font print routine but I wrote one for another compiler so I know they way it should work.

First thing to understand is that the screen data on a KS0108 Glcd is made up of bytes in a vertical orientation. There for the natural inclination will to have 1 byte high characters that fall on these boundary's. When you start laying down more than 1 byte or have that byte overlays 2 bytes on the screen then it gets more complex.

For starters you have to read the screen before hand rotate your data into place mask that data onto the read screen data and then write is all back. The print routine should produce a mask that is the max hight of the character so any data either side is safe no mater what. The Style etc that is applied to font should only effect the area inside the font hight its self.

I will have a chat with Dave tomorrow on how he implemented the mask but in the mean time can tell me if the data your getting over written is with in the char area.

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Wed Dec 06, 2006 8:59 am

TimB,

thanks for the explanation, but at the end I don't understand everything. It seems that the thing is to abstract for me. (Maybe the language makes it more difficult as it is)! :cry:

I thing that the last paragrah is the most importand for me at this time, but I also don't understand it.
... tell me if the data your getting over written is with in the char area.
What does it mean :?:

Is the char area the letter wich is written? When it is so, then no. The things that are over written are over written with blanks. Hopefully you understand.

Thanks

CS

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Thu Dec 07, 2006 7:25 pm

Sorry for the delay getting back on this.

I spoke with Dave and talked about the masking system. Basically its works the way it was designed to work, however we have come to the conclusion that it needs improving.

This will be done in due time but it will not 100% solve the problem as it will introduce some more issue.

An example

variable size fonts are variable in width, lets say you printed 8.000 then over wrote it with 1.111. As 8 and 0 are wider than 1 you will not over write all of the previous text and you will have to have extra spaces at the end of your text to over write any possible text underneath.


Back to your problem now. The solution is to over write using the xor modifier with the same data. This will remove only your text.

However for speed I would recommend you think about making a bit map of the area and surrounding data then use SetImage to write this to the screen. It will be quicker than using XOR. But I have to admit its more complex.

If you go for the XOR route I would make your data into an array and print that rather than one long command. Then make a copy and print that to erase the first as you could be spending a long time doing duplicate maths etc.

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Thu Dec 07, 2006 8:30 pm

Hallo TimB,

on an other Forum I found a verry good explanation on the problem to draw chars on the lcd (I thing it was from XOR). Now something is clearer. When I understand everything then it is difficult to draw letters that are higher than 8 pixel. The width is not so difficult to draw.

So when I use a Font with the maximum high of 8 pixel I should solve my problems with the overdrawing. But it isn't so :roll:

When I use a Font with 6X8 I have also the problem. The letter is exact 8 pixel high and 6 pixel width but it overdraws my grid (For the high the letter needs 16 pixel).

Will it be solved, then I use a GLCD with the T6963C controller?

At this moment I redraw the 2 horizontal divider lines from the grid after every measurement, but now I have a little flickering under all the letters wich normaly overdraw the grid lines. I have to admit, that it not looks very nice but at this time it seems that I have to live with it!? Hopefully the flickering will not be more when I add the other measurement parts.

Please let me know if there is a better solution.

Thanks

CS

P.S.: Please can you tell me how I can write the little circle behind the temperature? With the serial comunicator from SF it works fine, but I'm not able to display this little circle after the temperature on the GLCD or on the Hyperterminal from WindowsXP.

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Fri Dec 08, 2006 12:03 am

Fonts can be variable in size both in width and hight. As you pointed out width does not pose a problem. When you build a font with font converter you have specify the a hight that prevents the font extending over 1 byte high. This is not always as straight forward as you would think as PC fonts are taller by a big amount than you would think.

Any way the solution is to use a fixed font. Its called SystemFont, However you have to do another thing and that is ensure you print on byte boundary's that's keeping your Y to these numbers

0,8,16,24,32,40,48,56

If not I think SF will print across 2 bytes and your back to square 1.

This might be of interest to you as it explains some of the issues
http://www.protongeeks.com/index.php?op ... &Itemid=29

As I said Dave is to sort this out in the not to distant future.

If you want to add the deg char you can make it and add it to the userdef section from 0 to 32

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Fri Dec 08, 2006 9:04 pm

TimB,

thanks for your effort. Now I'm at the same problem then I had with my other basic other compiler :(

I have splitted the display in three areas so I'm not able to print on the byte boundary's. The result is, like you pointed out that SF will print on 2 bytes. As I said, with the redrawing of the gridline I solved one of the problems.

The problem with the width of the text (the leftovers) would hopefully solved by David.

The last problem with the deg char I can't solve myself because I don't understand the structure of the generated file from the fontgenerator. How can I design my own char?

Thanks

CS

Am I right, that the proton basic is able to display big letters without overdrawing some ohter things?

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Fri Dec 08, 2006 9:38 pm

Here's a good link to making chars for the glcd but its only 1 byte high

http://www.geocities.com/dinceraydin/lcd/gfxcalc.htm

As an example I made a little deg symbol. To use it load in the fixedfont font from the glcd\fonts folder. Then click on the pad lock symbol on the top of the text window so you can edit it. Then change the line

$00,$00,$00,$00,$00,$00, // User defined character 31 to

2,5,2,0,0,0 // User defined character Deg symbol

Now you can use it like this

GLCD.WriteStr(64,45, GetTempAsStr, 31,"C")

Really the masking was an over site and is being fixed. The wonderfully thing about SF is the modules are so flexible it will be an easy fix.


Btw yes Proton will mask correctly the data around the character. But don't ask me to alter it. its would be one massive pain in the &**&t.

Now in SF it would be soooo easy

Can I suggest that you work on byte boundary's in future, The speed will be much improved.

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Fri Dec 08, 2006 10:51 pm

TimB,

thanks again for the explanation. Now I have the deg symbol behind the temp and it looks good. Also I understand the standard font thing a little bit more. But how it works with the other fonts? The generated one from the font converter? How can I there build my own letter?
Really the masking was an over site and is being fixed. The ...
That sounds very good! when will we get the fixe?

Next problem:

Your code
GLCD.WriteStr(64,45, GetTempAsStr, 31,"C")
returns a compiler error: "Too many parameters"

Last but not least I will follow your suggestion but for the current project it is important, to have bigger letters.

Thanks

CS

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Fri Dec 08, 2006 11:27 pm

Sorry my mistake

should have been
GLCD.WriteStr(64,45, GetTempAsStr)
GLCD.Write(31,"C")

To make a char depends on the font size your using. Lets say its 2 bytes high.
First thing is to look to replace a char in the font table. But there is an issue as the font offsets are worked out by fontconverter so if you alter the size of the data in the table it will print wrong images. However there is a way round this. You use the last char in the font.
// Code for char (Square)

If you look at the char data you will see the first byte indicates the width in pixels. As our char is only really small we will keep it to 4 pixels wide.

So we replace the last line with

4,2,0,5,0,2,0,0,0, // User defined character Deg symbol

Now you can use GLCD.write(127) // or 96 which ever works right

HTH

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Fri Dec 08, 2006 11:46 pm

TimB,

you don't have to say sorry. I ask sometimes the stupid questions so I have to say sorry.

Among other things the very fast support was the reason, why I bought the SF-Compiler.

So tonight I go to bed and hopefully tomorrow I see the SF-Basic clearer.

By then thanks again.

Good night

CS

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Sat Dec 09, 2006 8:32 am

> The problem with the width of the text (the leftovers) would
> hopefully solved by David.

Yes, I will look into this and make some changes. I will let you know when it is done...

Post Reply