GLCD X axis offset by 64

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
TonyR
Posts: 75
Joined: Fri Jan 14, 2011 11:49 pm
Location: Sydney
Contact:

GLCD X axis offset by 64

Post by TonyR » Tue Sep 23, 2014 9:25 pm

Sorry to bore anyone with this, but I'm an electronics engineer and software is frightening and not my strong point !

I think I simplified the bug to its smallest size.

Using GLCD library and KS0108 (actually its an S6B0108 newer version) the X axis is offset 64 pixels to the right.

The program below causes "hello" to be appear at x=64, not x=0 where it should do. (Something to do with the CS1 CS2 select?).

Help welcome.

Code: Select all

Device = 18F87J93                     
Clock = 12
Config OSC = HS
                          
// User options
#Option GLCD_MODEL = KS0108             
#option GLCD_SCREEN_WIDTH = 128       
#option GLCD_SCREEN_HEIGHT = 64       
#Option GLCD_DATA = PORTD            
#Option GLCD_RS  = PORTB.2           
#Option GLCD_RW  = PORTB.1           
#Option GLCD_EN  = PORTB.0           
#Option GLCD_CS1 = PORTB.4           
#Option GLCD_CS2 = PORTC.4           
#Option GLCD_RST = PORTE.3           
#Option GLCD_ASPECT_RATIO = 100       
#Option GLCD_INIT_DELAY = 50          
#Option GLCD_INVERT_CS = true        
 
Include "glcd.bas"            
Include "graphics.bas"        
Include "Bitmaps.bas"         
Include "Arial.bas"           
                             
TRISD = %00000000        ' data port          
TRISB = %11100000        ' handshake port               
TRISE = %11110111      ' reset pin       


GLCD.Cls                    

GLCD.SetFont(ArialBold)
GLCD.WriteAt(0,0,"hello")
     


While true 

Wend


Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: GLCD X axis offset by 64

Post by Jerry Messina » Tue Sep 23, 2014 11:54 pm

It seems there are a number of "KS0108" chips and modules out there. From what i can tell., yours seems to be a "three chip select" version.

Check out the wiki page at http://www.sfcompiler.co.uk/wiki/pmwiki ... .KS0108CS3

Maybe that will help. In any case, I think you'd want to remove the "#Option GLCD_INVERT_CS = true" so it defaults to false.

TonyR
Posts: 75
Joined: Fri Jan 14, 2011 11:49 pm
Location: Sydney
Contact:

Re: GLCD X axis offset by 64

Post by TonyR » Wed Sep 24, 2014 5:16 am

Thanks for reply. Its fixed. One of the #options was a total bungle. A #option was wrong (CS2 output on wrong CPU pin). Because it was declared on the wrong port the CS2 input on the LCD was floating and working sometimes other times not..... giving the appearance to me that changing the code was doing something. It was a tree that I couldn't see because of the forest.

Post Reply