128x64 GLCD (KS0108) Text Orientation

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everyone,

 

I am using Fabian Maximilian Thiele library and my GLCD is working very well. However I am having hard time to display text in portrait mode. Is there a way to display portrait text? Any input is highly appreciated.

 

Thanks,

Niral

Last Edited: Tue. Nov 7, 2017 - 05:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I guess this is probably obvious but I'll say it anyway. In this code:

 

        // last but not least, draw the character
	for(uint8_t i=0; i<bytes; i++) {
		uint8_t page = i*width;
		for(uint8_t j=0; j<width; j++) {
			uint8_t data = ks0108FontRead(ks0108Font+index+page+j);
			
			if(height < (i+1)*8) {
				data >>= (i+1)*8-height;
			}
			
			if(ks0108FontColor == BLACK) {
				ks0108WriteData(data);
			} else {
				ks0108WriteData(~data);
			}
		}
		// 1px gap between chars
		if(ks0108FontColor == BLACK) {
			ks0108WriteData(0x00);
		} else {
			ks0108WriteData(0xFF);
		}
		ks0108GotoXY(x, ks0108Coord.y+8);
	}

You need to switch the X and Y directions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

Till now I have used it in landscape mode. But now I have to use portrait mode. I have try to switch X and Y position but text is not rotating.

 

Thank you,

nIk

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Show what you changed.
.
At the end of the day a character is just a rectangle of dots. To drawy it you go up/down the Y and across the X. So to rotate you should use the same data but now draw by going across the X then up/down the Y within that instead.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

BTW In the above code both the data and the screen are being indexed by the same i/j. You will have to break that link obviously.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

I have changed position of X and Y but it places new character slightly lower than previous char for all. I want to rotate text.

 

// last but not least, draw the character
	for(uint8_t i=0; i<bytes; i++) {
		uint8_t page = i*width;
		for(uint8_t j=0; j<width; j++) {
			uint8_t data = ks0108FontRead(ks0108Font+index+page+j);
			
			if(height < (i+1)*8) {
				data >>= (i+1)*8-height;
			}
			
			if(ks0108FontColor == BLACK) {
				ks0108WriteData(data);
				} else {
				ks0108WriteData(~data);
			}
		}
		// 1px gap between chars
		if(ks0108FontColor == BLACK) {
			ks0108WriteData(0x00);
			} else {
			ks0108WriteData(0xFF);
		}
		ks0108GotoXY(y, ks0108Coord.x+8);
	}
	ks0108GotoXY(y+width+1, x);
	
	return 0;

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So perhaps an index is off by one?

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

note that you can also most likely rotate the display, it has an inverse X and inverse Y bit in a register by swapping these you can write test in any direction you want ans this will give the orientation of the display.

It has been a long time since I played with a 108 display and do not have the code at work, but it should be very obvious from the datasheet.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everyone,

 

I have switched to universal library for KS0108 and created customized fonts and that works..

 

Regards,

nIk

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For the benefit of future readers:

 

Initially, MeNik wrote:
 Fabian Maximilian Thiele library 

Would you care to give a link for that?

 

Finally, MeNik wrote:
I have switched to universal library for KS0108

And would you care to give a link for that?

 

and that works..

Excellent. Now please mark the thread as solved: http://www.avrfreaks.net/comment...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AFAIK Thiele's web site (http://www.apetech.de) is no more. His LCD library is floating around as copies here and there on the Web. E.g.: http://www.codeforge.com/article...

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
AFAIK Thiele's web site (http://www.apetech.de) is no more. His LCD library is floating around as copies

Indeed.

 

Which is why it would be particularly helpful for the OP to say specifically which copy (s)he used

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

KS0108 Library I used : http://en.radzio.dxp.pl/ks0108/

 

For Creation of 8x8 font : https://www.riyas.org/2013/12/on...

 

also you have to replace code of 'GLCD_WriteChar(char charToWrite)' with following..

 

    int i;
	charToWrite -= 32;
	for(i = 0; i<8; i++)
	GLCD_WriteData(GLCD_ReadByteFromROMMemory((char *)((int)font8x8 + (8 * charToWrite) + i)));
	GLCD_WriteData(0x00);

 

Regards,

nIk

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks - and mark the solution ... ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AFAIK Thiele's web site (http://www.apetech.de) is no more. His LCD library is floating around as copies here and there on the Web. E.g.: http://www.codeforge.com/article...

"We're goin' way back, WAY back.  'Cuz that's where the fun is... WAY BACK!"

https://web.archive.org/web/20070202061106/http://www.apetech.de:80/

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On that page:

Jippi, die neue Seite ist fertig! 

So, should we now say 

 

Verdamt, die alte Seite ist kaput! 

 

?

 

:-)

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]