NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Everything Else » Is the LCD able to use as a graphics screen?

December 29, 2010
by TLR
TLR's Avatar

As every one know that each letter is 8x8 pixel, can this be alter as a bit mapping, like graphics? I'm looking to design a simple scope to show a PWM wave..

TLR....

December 29, 2010
by Hexorg
Hexorg's Avatar

TLR, trouble with NerdKit's screen is that it has white space between lines (and I think between letters too), so there might be some blank spaces in the image of your wave. However, I believe HD44780 standard supports custom caracters. It'll work something like this - based on your data you can calculate how a new character will look, e.g

    2nd char 1st char   
    00000    00000
    10000    00000
    01000    00000
    00100    00000
    00010    00100
    00001    01010
    00000    10001
    00000    00000

The ones is a filled region. it kinda looks like a wave. Then you can send that data to the display. You would have to use some commands from the datasheet. I don't have access to it right now, but i'll let you know if I find anything.

December 29, 2010
by TLR
TLR's Avatar

Yes, I can see it now. I just put together the first screen test, maybe this processor would work on a pixel screen better? What about using a Stamp2 to run this LCD screen instead? I would need to learn more about the power of this processor...

December 29, 2010
by Hexorg
Hexorg's Avatar

Seems like Stamp2 is less powerful then ATmega168(the one that comes with the NerdKit). But really it doesn't matter much which processor you choose, it's the screen that matters, so yes, a graphic screen (or a pixel screen as you call it) will work better. But it is possible to make this one display your wave too. For example like this:

Char text as graph

December 29, 2010
by TLR
TLR's Avatar

Ya, thanks. I'm having a hard time to open this processor for programming. I try all the step and it seem none have worked. Don't know if I would waste any more time, when Stamps2 works with no problem at all..

December 30, 2010
by Hexorg
Hexorg's Avatar

Actually I need to write custom graphics to the character screen now too. A little search gave me some neat pages: Graphics calculator allows you to set virtual pixels and tells you the binary digits that represent those chars. That page also has a link to a giant HT44780 explanation, which tells you how to write the data that you got from the first page. Page 28 of the HD44780 datasheet also tells you how to manipulate pins to write that data.

That's where I'm puzzled now and want to ask the rest of NerdKits community too - it seems you HAVE to use 8-bit interface of the protocol in order to write custom graphics to the screen, right? So lcd.c code that comes with nerdkit's becomes kinda obsolete too?

Also, do you guys think it's possible to use two SIPO shift registers to control LCD with just SPI?

December 30, 2010
by bretm
bretm's Avatar

You shouldn't need 8-bit interface to write custom graphics. The lcd.h that comes with NerdKits has functions for writing raw command bytes and data bytes and that's all you should need.

uint8_t pattern[7] = {0, 10, 17, 21, 17, 10, 0}; // character data
uint8_t charNum = 3; // custom character #3

lcd_set_type_command();
lcd_write_byte(0x80 | (charNum << 3));
lcd_set_type_data();

uint8_t i;

for (i=0; i<7; i++)
{
    lcd_write_byte(pattern[i]);
}

lcd_home();

I haven't tried it, but from the datasheet it looks like that's how it works.

December 30, 2010
by Hexorg
Hexorg's Avatar

bretm, you were almost correct, except for a 5x8 pattern you have to skip 8 bytes for every position, also command it not 0x80 but 0x40, so a working code (tested):

uint8_t pattern[7] = {0, 10, 17, 21, 17, 10, 0}; // character data
uint8_t charNum = 3; // custom character #3

lcd_set_type_command();
lcd_write_byte(charNum*8+0x40);
lcd_set_type_data();

uint8_t i;

for (i=0; i<7; i++)
{
    lcd_write_byte(pattern[i]);
}

lcd_home();
December 30, 2010
by Hexorg
Hexorg's Avatar

wait, that's a but messed up... the loop should be not i<7 but i<8, since we want to send 8 bytes total (8 rows)

December 31, 2010
by bretm
bretm's Avatar

I did 7 rows on purpose to leave room for the blinking underline cursor.

I already had the 8 in there. I had (charNum << 3) which is the same as charNum8. The shifting was more intuitive to me because the diagram in the datasheet shows the character number in bit columns shifted to the left of the row number.

Good catch on the 0x40 instead of 0x80.

December 31, 2010
by bretm
bretm's Avatar

Oops, didn't catch the italics instead of star in preview.

January 04, 2011
by Steven
Steven's Avatar

wait, that's a but messed up... the loop should be not i<7 but i<8, since we want to send 8 bytes total (8 rows)

0-indexing, good sir! You end up with 8 rows because you're starting your counter variable at 0:

0 - 1
1 - 2
2 - 3
3 - 4
4 - 5
5 - 6
6 - 7
7 - 8

Post a Reply

Please log in to post a reply.

Did you know that you can connect to certain car computers via the OBD-II port with a microcontroller? Learn more...