Help drawing a bitmap Nokia LCD

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Help drawing a bitmap Nokia LCD

Postby nyukin » Fri Aug 05, 2011 3:22 am

Hi,

I couldn't find my question when quickly searching through the forums. I have an 84x48px bitmap (just a bunch of hex separated by commas right?) that I made, and I just want to display the bitmap on my Nokia 3310/5110 display.

I have the display wired up right, I can run the example sketch, a few months ago I edited the example sketch to loop a few pages of text, but I don't understand how to just display my bitmap. I'm sure it's simple, but I just don't have a lot of experience writing a sketch.

I stared at the loop in the example, tried copy/pasting a few things, and at this point I'll keep tinkering or getting a better understanding of how a sketch works. Thanks for any help!
nyukin
 
Posts: 6
Joined: Tue Jan 25, 2011 4:25 am

Re: Help drawing a bitmap Nokia LCD

Postby adafruit_support_bill » Fri Aug 05, 2011 4:56 am

Post your code. Maybe we can see what is wrong with it.
User avatar
adafruit_support_bill
 
Posts: 15918
Joined: Sat Feb 07, 2009 9:11 am

Re: Help drawing a bitmap Nokia LCD

Postby nyukin » Fri Aug 05, 2011 10:55 am

It's just an adaptation of the example, but I'll post it on my lunch break. Thanks for the early response!
nyukin
 
Posts: 6
Joined: Tue Jan 25, 2011 4:25 am

Re: Help drawing a bitmap Nokia LCD

Postby nyukin » Fri Aug 05, 2011 3:23 pm

Hello again,

At the beginning of my sketch, I tried to follow what the GLCD 16x16px image input looks like, so here's the code of the bitmap I made:

Code: Select all
// a bitmap of nyancat
const unsigned char nyancat_bmp [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x02, 0xF1, 0x09, 0x15, 0x05, 0x05, 0x05, 0x45, 0x05,
0x05, 0x05, 0x15, 0xC5, 0x25, 0x25, 0x45, 0xA5, 0x09, 0xF1, 0x02, 0xFC, 0x80, 0x40, 0x20, 0x20,
0xC0, 0x00, 0x06, 0x09, 0x11, 0x16, 0x24, 0x24, 0xFF, 0x00, 0x3F, 0x60, 0x81, 0x80, 0x90, 0x82,
0x80, 0xC0, 0x80, 0x88, 0xFC, 0x83, 0x00, 0x00, 0x10, 0xD8, 0x81, 0x81, 0xC1, 0x91, 0x80, 0xD0,
0x18, 0x00, 0x83, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x09, 0x09, 0x0D, 0x06, 0x02, 0x0E, 0x0A,
0x0A, 0x06, 0x02, 0x02, 0x02,
};
#define NYANCAT_HEIGHT 20
#define NYANCAT_WIDTH 34


Then in the loop sketch, I adjusted the test patterns that float on the screen so the code reflects my bitmap:

Code: Select all
// draw each icon
    for (uint8_t f=0; f< NUMFLAKES; f++) {
      nokia.drawbitmap(icons[f][XPOS], icons[f][YPOS], nyancat_bmp, w, h, BLACK);
    }
    nokia.display();
    delay(200);

Code: Select all
// then erase it + move it
    for (uint8_t f=0; f< NUMFLAKES; f++) {
      nokia.drawbitmap(icons[f][XPOS], icons[f][YPOS],  nyancat_bmp, w, h, 0);


What I hoped to see was a 34 by 20 px of everyone's favorite pastry feline, nyancat.
Instead, the adafruit logo that floats on by is replaced by random letters.

All I really want is to display my bitmap. It doesn't have to have a specific location on the screen or scroll, I just figure there's an equivalent to "nokia.drawstring" that instead would be "nokia.drawbitmap" after which I'd write (nyancat_bmp); as I declared in the beginning of the sketch.

But again I'm not really sure of what I'm doing and don't know the appropriate function/command. Thanks, hope this helps you help me!
nyukin
 
Posts: 6
Joined: Tue Jan 25, 2011 4:25 am

Re: Help drawing a bitmap Nokia LCD

Postby nyukin » Fri Aug 05, 2011 3:57 pm

I think I'm getting the hang of it!
I got my nyancat to display where in place of the adafruit logo when scrolling by making a 40x40 px version (multiples of 8, as I read might be important from another thread regarding your TFT display) so now I just need to tweak the sketch tonight when I'm home to figure out how to make the kitty display without moving and stuff.

I don't require any other follow up at this point, unless you have any tips. I will publish my end code in this thread in case anyone has trouble like I did in the future. :)
nyukin
 
Posts: 6
Joined: Tue Jan 25, 2011 4:25 am

Re: Help drawing a bitmap Nokia LCD

Postby nyukin » Tue Sep 06, 2011 2:58 am

I came back to this after about a month, finally achieveing what I originally set out to. (In the last month I've begun learning Eagle and have placed my first board order; I have no regrets!) Here is a sketch that will write 3 84 by 48 pixel bitmaps to the Nokia 5110, and loop.

Code: Select all
/*
September 5th, 2011
Wade Smith
Based on code by Nathan Seidle

This code is free and open, like NyanCat
Written for the Nokia 5110 84x48 graphic LCD:
http://www.sparkfun.com/products/10168
http://www.adafruit.com/products/338
*/

#define PIN_SCE   7 //Pin 3 on LCD
#define PIN_RESET 6 //Pin 4 on LCD
#define PIN_DC    5 //Pin 5 on LCD
#define PIN_SDIN  4 //Pin 6 on LCD
#define PIN_SCLK  3 //Pin 7 on LCD

//The DC pin tells the LCD if we are sending a command or data
#define LCD_COMMAND 0
#define LCD_DATA  1

//You may find a different size screen, but this one is 84 by 48 pixels
#define LCD_X     84
#define LCD_Y     48

//This is the first frame of NyanCat
char frame1[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x20, 0x40, 0xF0, 0x00, 0xE0, 0xA0,

0xE0, 0x00, 0xE0, 0x40, 0xC0, 0x00, 0x40, 0x40, 0x00, 0xB0, 0xD0, 0x00, 0x40, 0xE0, 0x40, 0x00,

0xE0, 0xA0, 0xE0, 0x00, 0xE0, 0x50, 0x60, 0x00, 0x00, 0xF0, 0x20, 0x40, 0xF0, 0x00, 0x60, 0xC0,

0x60, 0x00, 0xC0, 0xA0, 0xE0, 0x80, 0x00, 0xE0, 0x40, 0xC0, 0x00, 0x00, 0x60, 0x90, 0x90, 0x00,

0xC0, 0xA0, 0xE0, 0x80, 0x00, 0x40, 0xE0, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x80, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,

0x40, 0x40, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40,

0x40, 0x80, 0x00, 0x00, 0xFF, 0x00, 0xFC, 0x02, 0x45, 0x01, 0x01, 0x81, 0x11, 0x01, 0x01, 0x01,

0x05, 0xF1, 0x09, 0x09, 0x11, 0x29, 0x42, 0x7C, 0x40, 0x7F, 0x20, 0x10, 0x08, 0x08, 0xF0, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,

0x00, 0x00, 0x01, 0x02, 0x04, 0x05, 0x89, 0x49, 0x7F, 0x40, 0x8F, 0x98, 0xA0, 0xA0, 0xA4, 0xA0,

0xA0, 0xB0, 0xA0, 0xA2, 0xBF, 0xA0, 0xC0, 0x80, 0x84, 0xB6, 0xA0, 0xA0, 0xB0, 0xA4, 0xA0, 0xB4,

0x86, 0x40, 0x20, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x03, 0x01, 0x00,

0x03, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x03, 0x00,

0x01, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

//NyanCat frame two
char frame2 [] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x20, 0x40, 0xF0, 0x00, 0xE0, 0xA0,

0xE0, 0x00, 0xE0, 0x40, 0xC0, 0x00, 0x40, 0x40, 0x00, 0xB0, 0xD0, 0x00, 0x40, 0xE0, 0x40, 0x00,

0xE0, 0xA0, 0xE0, 0x00, 0xE0, 0x50, 0x60, 0x00, 0x00, 0xF0, 0x20, 0x40, 0xF0, 0x00, 0x60, 0xC0,

0x60, 0x00, 0xC0, 0xA0, 0xE0, 0x80, 0x00, 0xE0, 0x40, 0xC0, 0x00, 0x00, 0x60, 0x90, 0x90, 0x00,

0xC0, 0xA0, 0xE0, 0x80, 0x00, 0x40, 0xE0, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,

0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0x40, 0xA0, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x80, 0x40, 0x40, 0x80, 0x00, 0x00, 0xFF, 0x00, 0xFC, 0x02, 0x45, 0x01, 0x01, 0x81, 0x11, 0x01,

0x01, 0x01, 0x05, 0xF1, 0x09, 0x09, 0x11, 0x29, 0x42, 0x7C, 0x40, 0x7F, 0x20, 0x10, 0x08, 0x08,

0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x08, 0x14, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x05, 0x89, 0x49, 0x7F, 0x40, 0x8F, 0x98, 0xA0, 0xA0,

0xA4, 0xA0, 0xA0, 0xB0, 0xA0, 0xA2, 0xBF, 0xA0, 0xC0, 0x80, 0x84, 0xB6, 0xA0, 0xA0, 0xB0, 0xA4,

0xA0, 0xB4, 0x86, 0x40, 0x20, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x03,

0x01, 0x00, 0x03, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02,

0x03, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x02, 0x05, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

//NyanCat frame 3
char frame3[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x20, 0x40, 0xF0, 0x00, 0xE0, 0xA0,

0xE0, 0x00, 0xE0, 0x40, 0xC0, 0x00, 0x40, 0x40, 0x00, 0xB0, 0xD0, 0x00, 0x40, 0xE0, 0x40, 0x00,

0xE0, 0xA0, 0xE0, 0x00, 0xE0, 0x50, 0x60, 0x00, 0x00, 0xF0, 0x20, 0x40, 0xF0, 0x00, 0x60, 0xC0,

0x60, 0x00, 0xC0, 0xA0, 0xE0, 0x80, 0x00, 0xE0, 0x40, 0xC0, 0x00, 0x00, 0x60, 0x90, 0x90, 0x00,

0xC0, 0xA0, 0xE0, 0x80, 0x00, 0x40, 0xE0, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x80, 0x40, 0x20, 0x20, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0,

0xA0, 0xA0, 0xA0, 0x20, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0,

0x20, 0x20, 0xC0, 0x80, 0x80, 0xFF, 0x00, 0xFE, 0x01, 0x22, 0x00, 0x00, 0x40, 0x08, 0x00, 0x00,

0x00, 0x82, 0x78, 0x04, 0x04, 0x08, 0x14, 0x21, 0x3E, 0x20, 0x3F, 0x10, 0x08, 0x04, 0x04, 0x78,

0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,

0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0xC4, 0x24, 0x3F, 0xA0, 0xC7, 0x4C, 0xD0, 0x50, 0x52,

0xD0, 0x50, 0x58, 0x50, 0x51, 0x5F, 0x50, 0x60, 0xC0, 0x42, 0x5B, 0xD0, 0x50, 0xD8, 0x52, 0x50,

0xDA, 0x43, 0x20, 0x10, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00,

0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,

0x00, 0x00, 0x01, 0x81, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

void setup(void) {
  LCDInit(); //Init the LCD
}

void loop(void) {
  LCDClear();
  LCDBitmap(frame1);
  delay(200);

  LCDClear();
  LCDBitmap(frame2);
  delay(200);

  LCDClear();
  LCDBitmap(frame3);
  delay(200);

}

void gotoXY(int x, int y) {
  LCDWrite(0, 0x80 | x);  // Column.
  LCDWrite(0, 0x40 | y);  // Row.  ?
}

//This takes a large array of bits and sends them to the LCD
void LCDBitmap(char my_array[]){
  for (int index = 0 ; index < (LCD_X * LCD_Y / 8) ; index++)
    LCDWrite(LCD_DATA, my_array[index]);
}

//This function takes in a character, looks it up in the font table/array
//And writes it to the screen
//Each character is 8 bits tall and 5 bits wide. We pad one blank column of
//pixels on each side of the character for readability.
void LCDCharacter(char character) {
  LCDWrite(LCD_DATA, 0x00); //Blank vertical line padding


  LCDWrite(LCD_DATA, 0x00); //Blank vertical line padding
}

//Given a string of characters, one by one is passed to the LCD
void LCDString(char *characters) {
  while (*characters)
    LCDCharacter(*characters++);
}

//Clears the LCD by writing zeros to the entire screen
void LCDClear(void) {
  for (int index = 0 ; index < (LCD_X * LCD_Y / 8) ; index++)
    LCDWrite(LCD_DATA, 0x00);
   
  gotoXY(0, 0); //After we clear the display, return to the home position
}

//This sends the magical commands to the PCD8544
void LCDInit(void) {

  //Configure control pins
  pinMode(PIN_SCE, OUTPUT);
  pinMode(PIN_RESET, OUTPUT);
  pinMode(PIN_DC, OUTPUT);
  pinMode(PIN_SDIN, OUTPUT);
  pinMode(PIN_SCLK, OUTPUT);

  //Reset the LCD to a known state
  digitalWrite(PIN_RESET, LOW);
  digitalWrite(PIN_RESET, HIGH);

  LCDWrite(LCD_COMMAND, 0x21); //Tell LCD that extended commands follow
  LCDWrite(LCD_COMMAND, 0xB0); //Set LCD Vop (Contrast): Try 0xB1(good @ 3.3V) or 0xBF if your display is too dark
  LCDWrite(LCD_COMMAND, 0x04); //Set Temp coefficent
  LCDWrite(LCD_COMMAND, 0x14); //LCD bias mode 1:48: Try 0x13 or 0x14

  LCDWrite(LCD_COMMAND, 0x20); //We must send 0x20 before modifying the display control mode
  LCDWrite(LCD_COMMAND, 0x0C); //Set display control, normal mode. 0x0D for inverse
}

//There are two memory banks in the LCD, data/RAM and commands. This
//function sets the DC pin high or low depending, and then sends
//the data byte
void LCDWrite(byte data_or_command, byte data) {
  digitalWrite(PIN_DC, data_or_command); //Tell the LCD that we are writing either to data or a command

  //Send the data
  digitalWrite(PIN_SCE, LOW);
  shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data);
  digitalWrite(PIN_SCE, HIGH);
}
nyukin
 
Posts: 6
Joined: Tue Jan 25, 2011 4:25 am

Re: Help drawing a bitmap Nokia LCD

Postby plural » Sat Sep 17, 2011 7:54 pm

hi all.

what is the format of the bitmap values for the 5110? I wrote a little perl app to convert the numbers to binary strings and print them out to the terminal thinking that would show me the image used, but all i get is gobbledygook.

are the images drawn from top left to bottom right? for instance, does 192 decimal turn into 11000000 or 00000011 on the screen?

any help sorting this out would be swell.

-jason
plural
 
Posts: 2
Joined: Sat Sep 17, 2011 7:51 pm

Re: Help drawing a bitmap Nokia LCD

Postby plural » Sun Sep 18, 2011 10:33 am

Aha!

After some more searching, i found the GLCD library at http://www.arduino.cc/playground/Code/GLCDks0108 .

They have a processing sketch that will convert an image file to a .h file for use in your arduino project. Basically, the layout of the bitmap data is vertical. For an 84x48 image, the first 8 bits are pixels (0, 0), (0, 1) .. (0, 7), not (0, 0) ... (7, 0).
plural
 
Posts: 2
Joined: Sat Sep 17, 2011 7:51 pm


Return to Glowy things (LCD, LED, TFT, EL) purchased at Adafruit

Who is online

Users browsing this forum: No registered users and 2 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [102]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]