Drawing problems on a 128X64 KS0108

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

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

Drawing problems on a 128X64 KS0108

Post by CS » Tue Nov 28, 2006 8:26 pm

Hi I'm back again,

with new problems.

I've splitted the display with a grid in 3 lines and build the CSArial.bas based on Font Arial with Size 10.
When I now set PORTE.0 high then the display should show the time on the left side from line 2. The time is shown on the left side of line 2 but the time has overdrawn some pixel from my grid.

When I now set PORTE.1 high, then the date is shown in line 1 but the line from the grid is also lost. That is not enought the time from line 2 loses the first 2 rows of pixel.

I don't know if you understand my problem so I show you some code that hopefully makes it clear.

Code: Select all


Device = 18F452
Clock = 20

#option GLCD_RS = PORTB.2
#option GLCD_RST =PORTB.5
#option GLCD_EN = PORTB.4
#option GLCD_RW = PORTB.3
#option GLCD_CS1 = PORTB.1
#option GLCD_CS2 = PORTB.0
#option GLCD_RST = PORTB.5
#option GLCD_INVERT_CS  = true
#option GLCD_INIT_DELAY = 700

Include "GLCD.bas"
Include "CSArial.bas"

Private Sub DisplayDate()

    GLCD.WriteAt(12,3,"Di. 28.11.2006")
   
End Sub

Private Sub DisplayTime()

    GLCD.WriteAt(10,24,"18:32")
    
End Sub

Dim Ke As PORTE.0 
Dim Zu As PORTE.1 

ADCON1 = %0000111
TRISE = 1

GLCD.Cls

GLCD.SetFont(ArialBold)
GLCD.Rectangle(0,0,127,63)
GLCD.Circle(60, 52,7)
GLCD.Line(0,21,127,21)
GLCD.Line(0,42,127,42)

While true
    If Ke = 1 Then
        DisplayTime    
    End If
    
    If Zu = 1 Then
        DisplayDate
    End If

Wend
Best wishes

CS

P.S.: I use a EasyPic4 with a 18F452 at 20 MHz

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Tue Nov 28, 2006 11:25 pm

Hello,

If I understand the problem right, you need to add the line:

Font.Style = fsMerge

before the write statements. Font.Style can take four values for the KS0108. These are shown at the top of the Graphics library, which is included by the GLCD library - quote:

// font styles...
fsNormal = 0,
fsMerge = 1,
fsXOR = 2,
fsInvert = 3

The fsNormal option will write text on a white background - it is this white space around the letters that is over-writing your lines and existing text.

Regards,

Steven

P.S. Did you get chance to try the SED1520 display driver?

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

Post by CS » Wed Nov 29, 2006 11:00 am

Hi Steven

thanks again for the fast help (I have to use FontStyle=1 because Font.Style=fsMerge doesn't work). After your reply the code works very well.
The main problem for me is, where can I find all the things. When you type Font in the help, you'll find somewhere that you have the possibility to set the Font.Style, but without the information what happens.

For your understanding another example.

In your SED 1520 example you use 'TextAlign=taCenter'. Where from shall I know that this is possible. Only when I type 'TextAlign' in the editor and press F1 then I'll get some information. The information that the TextAlign only works with WriteStr I have to search on anohter place. Anyway after I want to use TextAlign I found another problem:

Code: Select all


Device = 18F452
Clock = 20

#option GLCD_RS = PORTB.2
#option GLCD_RST =PORTB.5
#option GLCD_EN = PORTB.4
#option GLCD_RW = PORTB.3
#option GLCD_CS1 = PORTB.1
#option GLCD_CS2 = PORTB.0
#option GLCD_RST = PORTB.5
#option GLCD_INVERT_CS  = true

Include "GLCD.bas"
Include "CSArial.bas"

Private Sub DisplayDate()

    Font.Style = 1
    GLCD.WriteAt(12,4,"Di. 28.11.2006")
 
End Sub

Private Sub DisplayTime()
    
    textalign=tacenter
    Font.Style = 1
    GLCD.writeStr(1,25,"18:32")
    'GLCD.WriteAt(10,25,"18:32")

End Sub

Dim Ke As PORTE.0
Dim Zu As PORTE.1

ADCON1 = %0000111
TRISE = 1

GLCD.Cls

GLCD.SetFont(ArialBold)
GLCD.Rectangle(0,0,127,63)
GLCD.Circle(60, 52,7)
GLCD.Line(0,21,127,21)
GLCD.Line(0,42,127,42)


While true
    If Ke = 1 Then
        DisplayTime    
    End If
    
    If Zu = 1 Then
        DisplayDate
    End If

Wend


   
In the Sub DisplayTime I useing only for tests the function TextAlign. When I call the function the whole diplay destroys (The grid and the text).

Please can you help again?

Thanks
CS

P.S.: The main prgramm from the SED 1520 works well, but I run into the demo limit. I don't know why, but I have to wait a long time to receive the full Swordfish Compiler :evil:

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Wed Nov 29, 2006 1:23 pm

CS,

I'll look at it tonight. As for finding info in the help files, my best advice until an expended user guide is written is too look at the libraries themselves. You can learn most of what you need to know by looking at the constants and the public subs/functions that are available (the public ones are indicated by the symbol with the yellow dot).

In order to be able to use Font.Style=fsMerge you need to also include the 'Graphics.bas' library in which the constants are defined.

Regards,

Steven

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Wed Nov 29, 2006 5:51 pm

CS,

It turns out to be an easy solution. You are trying to centre text at (1,25) where 1 is the x-position and 25 the y-position. It is impossible to centre your string here, because there is hardly any space to the left of this. The error in the resulting centre calculation corrupts the display. Try the following line instead:

Code: Select all

GLCD.writeStr(1,25,"18:32")
It is arguable that the GLCD library should check for this. However, careful programming will aviod this being a problem and it then only adds unneccessary code.

I hope that this helps. I'll check the SED1520 display also.

Regards,

Steven

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Wed Nov 29, 2006 6:06 pm

CS,

I've now also looked at the SED1520. A small sample program weighs in at 123 variables, so should be within the demo limit. Can you post the code that is pushing you over this limit? I'll see if the variable usage can be reduced, or compile it for you so you can see how it functions, then email you the hex file if it helps.

Regards,

Steven

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

Post by CS » Wed Nov 29, 2006 7:52 pm

Hi Steven,

thanks for trieing to help but the problem still exist. I've tried to use your code:

Code: Select all


GLCD.writeStr(1,25,"18:32")

I also try the following code:

Code: Select all


GLCD.writeStr(11,25,"18:32")

If I want to use the TextAlign function, my display will be shacked.
When I coment the line out the programm works.

Of course I understand the problem with the xPosition but here you can see that the manual is very important. How shall I use the xPosition with the TextAlignment ? Is X the Start position from where the center is calculatet (until the end of the display) or is it the endposition or is it the middle position???????

Questions over questions :?:

Can you help :?:

CS

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Wed Nov 29, 2006 8:07 pm

CS,

You will get away with

Code: Select all

GLCD.writeStr(12,25,"18:32")
but not with

Code: Select all

GLCD.writeStr(11,25,"18:32")
It's the same thing as before - there is not quite enough space to the left of xpos = 11 to fit the left of the string you are writing. For centering text, it is the middle position of the string that you give - it is centering it about this point. Have a look in the GLCD library - the code is quite easy to follow in many of the libraries (they are all written in Basic). For right-aligning, you give the position of the right-hand end of the text and vice versa for normal (or left-aligned) text.

I hope that this helps.

Steven

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

Post by CS » Wed Nov 29, 2006 10:22 pm

Steven,

thanks a lot, now it is clear and it works good.

For today its closing time.

CS

Post Reply