0

Text on KS0108 bug?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Text on KS0108 bug?

by dcarmean on Mon Jan 04, 2010 3:27 am

photo.jpg
Sample output
photo.jpg (120.1 KiB) Viewed 2206 times
I purchased a couple of KS0108s (GLCDs) from Adafruit. I have one of them up and running perfectly with the example sketch from the Arduino playground web page. However, my project relies on a couple lines of text and is not working properly. The text is corrupted, appearing that the updates are or'ing the new text with the previous text. The weird thing is that the first line works properly, but subsequent lines are seeing the corruption problems. I've tried this with both fixed pitch fonts (system5x7) and variable width (Arial), and both show the same behavior.

I created a small sketch that reproduces the problem by writing a count to three sequential lines on the display. The attached a photo of the display shows line 1 looks fine, but lines 2 and 3 have the problem where the updates appear to be or'd with the previous text.

Has anyone seen this problem? Any ideas?

Here's the sketch:

#include <ks0108.h> // Graphics LCD header - GLCD
#include <Arial14.h> // font definition for 14 point Arial font.
#include "SystemFont5x7.h" // system font
#include "ArduinoIcon.h" // bitmap

unsigned long startMillis, iter=0;

void setup()
{

GLCD.Init(NON_INVERTED);
GLCD.ClearScreen();
GLCD.SelectFont(System5x7); // select fixed width system font
//GLCD.SelectFont(Arial_14);
}

void loop()
{
startMillis = millis();
if ((startMillis % 1000) == 0) {
GLCD.CursorTo(0, 0);
GLCD.Puts("Line 1: ");
GLCD.PrintNumber(iter);

GLCD.GotoXY(0, 15);
GLCD.Puts("Line 2: ");
GLCD.PrintNumber(iter);

GLCD.GotoXY(0, 30);
GLCD.Puts("Line 3: ");
GLCD.PrintNumber(iter);

iter++;
}
}
dcarmean
 
Posts: 5
Joined: Mon Jan 04, 2010 1:13 am

Re: Text on KS0108 bug?

by zener on Mon Jan 04, 2010 3:54 am

Have you seen the other threads about GLCD's showing wrong characters?

zener
 
Posts: 4558
Joined: Sat Feb 21, 2009 2:38 am

Re: Text on KS0108 bug?

by dcarmean on Mon Jan 04, 2010 11:57 am

No - it must be a competence issue on my part. Before posting, I searched the forums for both GLCD and KS0108 and only found threads on contrast issues and hookup questions. I just did that search again and didn't see anything.

Can you give me a pointer?
dcarmean
 
Posts: 5
Joined: Mon Jan 04, 2010 1:13 am

Re: Text on KS0108 bug?

by adafruit on Tue Jan 05, 2010 10:19 pm

you may need to clear part of the screen. the LCD looks like it works fine, but the library may be buggy :(

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: Text on KS0108 bug?

by zener on Wed Jan 06, 2010 1:34 am

Read this thread:

viewtopic.php?f=8&t=12627

zener
 
Posts: 4558
Joined: Sat Feb 21, 2009 2:38 am

Re: Text on KS0108 bug?

by civicbynature on Thu Feb 10, 2011 12:28 am

I tried your code on my arduino mega and ks0108. and in deed your correct. I'm deff no expert. After playing around with the code for a bit. may conclusion is it seems to be maybe a font issue. The spacing seems to be important.

By changing line 2 GLCD.GOTOXY (0, 15);
To GLCD.GOTOXY (0, 16);
This fixed line 2 so now line 1 and line 2 worked. But line three was still doing the same as before.

Since all I had to do was move line 2 One pixel down I tried that on line 3 but that did work it was still doing the same.

But changing line 3 from GLCD.GOTOXY (0, 30)
To GLCD.GOTOXY (0,32) fixes the problem. Ummmm.


Image


Here's the code with my edits.



----------------------------------------------------------------------------------------------------------

#include <ks0108.h> // Graphics LCD header - GLCD
#include <Arial14.h> // font definition for 14 point Arial font.
#include "SystemFont5x7.h" // system font
#include "ArduinoIcon.h" // bitmap

unsigned long startMillis, iter=0;

void setup()
{

GLCD.Init(NON_INVERTED);
GLCD.ClearScreen();
GLCD.SelectFont(System5x7); // select fixed width system font
//GLCD.SelectFont(Arial_14);
}

void loop()
{
startMillis = millis();
if ((startMillis % 1000) == 0) {
GLCD.CursorTo(0, 0);
GLCD.Puts("Line 1: ");
GLCD.PrintNumber(iter);

GLCD.GotoXY(0, 16); // changed this from (0, 15)
GLCD.Puts("Line 2: ");
GLCD.PrintNumber(iter);

GLCD.GotoXY(0, 32); //changed this from (0, 30)
GLCD.Puts("Line 3: ");
GLCD.PrintNumber(iter);

iter++;

}
}

-------------------------------------------------------------------------------------------------------


I can't claim I am sure why this fixes it but, perhaps it's a font spacing issue? Any thoughts?
civicbynature
 
Posts: 37
Joined: Wed Feb 09, 2011 11:58 pm

Please be positive and constructive with your questions and comments.