Draw bitmap on 5110 nokia lcd without library

Draw bitmap on 5110 nokia lcd without library?

Does anybody have some code to share or link?

i use this code to display simple text. but i need also bitmap.
Any hint will be good .

/*
Scrolling text example code
Modified from: http://www.arduino.cc/playground/Code/PCD8544
*/
#include <avr/pgmspace.h>

// The pins to use on the arduino
#define PIN_SCE 8
#define PIN_RESET 3
#define PIN_DC 5
#define PIN_SDIN 6
#define PIN_SCLK 7

// COnfiguration for the LCD
#define LCD_C LOW
#define LCD_D HIGH
#define LCD_CMD 0

// Size of the LCD
#define LCD_X 84
#define LCD_Y 48

int scrollPosition = -10;

static const byte PROGMEM ASCII[5] =
{
{0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x5f, 0x00, 0x00},
{0x00, 0x07, 0x00, 0x07, 0x00},
{0x14, 0x7f, 0x14, 0x7f, 0x14},
{0x24, 0x2a, 0x7f, 0x2a, 0x12},
{0x23, 0x13, 0x08, 0x64, 0x62},
{0x36, 0x49, 0x55, 0x22, 0x50},
{0x00, 0x05, 0x03, 0x00, 0x00},
{0x00, 0x1c, 0x22, 0x41, 0x00},
{0x00, 0x41, 0x22, 0x1c, 0x00},
{0x14, 0x08, 0x3e, 0x08, 0x14},
{0x08, 0x08, 0x3e, 0x08, 0x08},
{0x00, 0x50, 0x30, 0x00, 0x00},
{0x08, 0x08, 0x08, 0x08, 0x08},
{0x00, 0x60, 0x60, 0x00, 0x00},
{0x20, 0x10, 0x08, 0x04, 0x02},
{0x3e, 0x51, 0x49, 0x45, 0x3e},
{0x00, 0x42, 0x7f, 0x40, 0x00},
{0x42, 0x61, 0x51, 0x49, 0x46},
{0x21, 0x41, 0x45, 0x4b, 0x31},
{0x18, 0x14, 0x12, 0x7f, 0x10},
{0x27, 0x45, 0x45, 0x45, 0x39},
{0x3c, 0x4a, 0x49, 0x49, 0x30},
{0x01, 0x71, 0x09, 0x05, 0x03},
{0x36, 0x49, 0x49, 0x49, 0x36},
{0x06, 0x49, 0x49, 0x29, 0x1e},
{0x00, 0x36, 0x36, 0x00, 0x00},
{0x00, 0x56, 0x36, 0x00, 0x00},
{0x08, 0x14, 0x22, 0x41, 0x00},
{0x14, 0x14, 0x14, 0x14, 0x14},
{0x00, 0x41, 0x22, 0x14, 0x08},
{0x02, 0x01, 0x51, 0x09, 0x06},
{0x32, 0x49, 0x79, 0x41, 0x3e},
{0x7e, 0x11, 0x11, 0x11, 0x7e},
{0x7f, 0x49, 0x49, 0x49, 0x36},
{0x3e, 0x41, 0x41, 0x41, 0x22},
{0x7f, 0x41, 0x41, 0x22, 0x1c},
{0x7f, 0x49, 0x49, 0x49, 0x41},
{0x7f, 0x09, 0x09, 0x09, 0x01},
{0x3e, 0x41, 0x49, 0x49, 0x7a},
{0x7f, 0x08, 0x08, 0x08, 0x7f},
{0x00, 0x41, 0x7f, 0x41, 0x00},
{0x20, 0x40, 0x41, 0x3f, 0x01},
{0x7f, 0x08, 0x14, 0x22, 0x41},
{0x7f, 0x40, 0x40, 0x40, 0x40},
{0x7f, 0x02, 0x0c, 0x02, 0x7f},
{0x7f, 0x04, 0x08, 0x10, 0x7f},
{0x3e, 0x41, 0x41, 0x41, 0x3e},
{0x7f, 0x09, 0x09, 0x09, 0x06},
{0x3e, 0x41, 0x51, 0x21, 0x5e},
{0x7f, 0x09, 0x19, 0x29, 0x46},
{0x46, 0x49, 0x49, 0x49, 0x31},
{0x01, 0x01, 0x7f, 0x01, 0x01},
{0x3f, 0x40, 0x40, 0x40, 0x3f},
{0x1f, 0x20, 0x40, 0x20, 0x1f},
{0x3f, 0x40, 0x38, 0x40, 0x3f},
{0x63, 0x14, 0x08, 0x14, 0x63},
{0x07, 0x08, 0x70, 0x08, 0x07},
{0x61, 0x51, 0x49, 0x45, 0x43},
{0x00, 0x7f, 0x41, 0x41, 0x00},
{0x02, 0x04, 0x08, 0x10, 0x20},
{0x00, 0x41, 0x41, 0x7f, 0x00},
{0x04, 0x02, 0x01, 0x02, 0x04},
{0x40, 0x40, 0x40, 0x40, 0x40},
{0x00, 0x01, 0x02, 0x04, 0x00},
{0x20, 0x54, 0x54, 0x54, 0x78},
{0x7f, 0x48, 0x44, 0x44, 0x38},
{0x38, 0x44, 0x44, 0x44, 0x20},
{0x38, 0x44, 0x44, 0x48, 0x7f},
{0x38, 0x54, 0x54, 0x54, 0x18},
{0x08, 0x7e, 0x09, 0x01, 0x02},
{0x0c, 0x52, 0x52, 0x52, 0x3e},
{0x7f, 0x08, 0x04, 0x04, 0x78},
{0x00, 0x44, 0x7d, 0x40, 0x00},
{0x20, 0x40, 0x44, 0x3d, 0x00},
{0x7f, 0x10, 0x28, 0x44, 0x00},
{0x00, 0x41, 0x7f, 0x40, 0x00},
{0x7c, 0x04, 0x18, 0x04, 0x78},
{0x7c, 0x08, 0x04, 0x04, 0x78},
{0x38, 0x44, 0x44, 0x44, 0x38},
{0x7c, 0x14, 0x14, 0x14, 0x08},
{0x08, 0x14, 0x14, 0x18, 0x7c},
{0x7c, 0x08, 0x04, 0x04, 0x08},
{0x48, 0x54, 0x54, 0x54, 0x20},
{0x04, 0x3f, 0x44, 0x40, 0x20},
{0x3c, 0x40, 0x40, 0x20, 0x7c},
{0x1c, 0x20, 0x40, 0x20, 0x1c},
{0x3c, 0x40, 0x30, 0x40, 0x3c},
{0x44, 0x28, 0x10, 0x28, 0x44},
{0x0c, 0x50, 0x50, 0x50, 0x3c},
{0x44, 0x64, 0x54, 0x4c, 0x44},
{0x00, 0x08, 0x36, 0x41, 0x00},
{0x00, 0x00, 0x7f, 0x00, 0x00},
{0x00, 0x41, 0x36, 0x08, 0x00},
{0x10, 0x08, 0x08, 0x10, 0x08},
{0x00, 0x06, 0x09, 0x09, 0x06},
};

void LcdCharacter(char character)
{
LcdWrite(LCD_D, 0x00);
for (int index = 0; index < 5; index++)
{
LcdWrite(LCD_D, pgm_read_byte(&ASCII[character - 0x20][index]));
}
// LcdWrite(LCD_D, 0x00);
}

void LcdClear(void)
{
for (int index = 0; index < LCD_X * LCD_Y / 8; index++)
{
LcdWrite(LCD_D, 0x00);
}
}

void LcdInitialise(void)
{
pinMode(PIN_SCE, OUTPUT);
pinMode(PIN_RESET, OUTPUT);
pinMode(PIN_DC, OUTPUT);
pinMode(PIN_SDIN, OUTPUT);
pinMode(PIN_SCLK, OUTPUT);

digitalWrite(PIN_RESET, LOW);
digitalWrite(PIN_RESET, HIGH);

LcdWrite(LCD_CMD, 0x21); // LCD Extended Commands.
LcdWrite(LCD_CMD, 0xB1); // Set LCD Vop (Contrast). //B1
LcdWrite(LCD_CMD, 0x04); // Set Temp coefficent. //0x04
LcdWrite(LCD_CMD, 0x14); // LCD bias mode 1:48. //0x13
LcdWrite(LCD_CMD, 0x0C); // LCD in normal mode. 0x0d for inverse
LcdWrite(LCD_C, 0x20);
LcdWrite(LCD_C, 0x0C);
}

void LcdString(char *characters)
{
while (*characters)
{
LcdCharacter(*characters++);
}
}

void LcdWrite(byte dc, byte data)
{
digitalWrite(PIN_DC, dc);
digitalWrite(PIN_SCE, LOW);
shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data);
digitalWrite(PIN_SCE, HIGH);
}

/**

  • gotoXY routine to position cursor
  • x - range: 0 to 84
  • y - range: 0 to 5
    */
    void gotoXY(int x, int y)
    {
    LcdWrite( 0, 0x80 | x); // Column.
    LcdWrite( 0, 0x40 | y); // Row.
    }

void drawBox(void)
{
int j;
for(j = 0; j < 84; j++) // top
{
gotoXY(j, 0);
LcdWrite(1, 0x01);
}

for(j = 0; j < 84; j++) //Bottom
{
gotoXY(j, 5);
LcdWrite(1, 0x80);
}

for(j = 0; j < 6; j++) // Right
{
gotoXY(83, j);
LcdWrite(1, 0xff);
}

for(j = 0; j < 6; j++) // Left
{
gotoXY(0, j);
LcdWrite(1, 0xff);
}
}

void Scroll(String message)
{
for (int i = scrollPosition; i < scrollPosition + 11; i++)
{
if ((i >= message.length()) || (i < 0))
{
LcdCharacter(’ ');
}
else
{
LcdCharacter(message.charAt(i));
}
}
scrollPosition++;
if ((scrollPosition >= message.length()) && (scrollPosition > 0))
{
scrollPosition = -10;
}
}

void setup(void)
{
LcdInitialise();
LcdClear();
drawBox();

gotoXY(7,1);
LcdString(“Nokia 5110”);
gotoXY(4,2);
LcdString(“Scroll Demo”);
}

void loop(void)
{
gotoXY(4,4);
Scroll(“Scrolling Message from MindKits.co.nz / blog.stuartlewis.com”);
delay(200);
}

Draw bitmap on 5110 nokia lcd without library?

Why?

Does anybody have some code to share or link?

No.

Any hint will be good .

A bitmap is just a series of pixels with specific colors. Since the code you have can deal with a specific pixel, that part is easy. Getting the pixel the right color looks a bit more challenging.

Any hint will be good .

Save my poor scrolling finger - use CODE TAGS.

PaulS, I think the 5110 is a black-and-white display?

OP, the code you have posted already displays text characters as bitmaps. So just define another array with the desired bits set for your graphic, and then use LcdWrite() to display it. Something like this:

static const byte PROGMEM myGraphic[5] =
{
{B00100100}, 
{B00100100}, 
{B00000000}, 
{B10000001}, 
{B01111110}
}

I think the 5110 is a black-and-white display?

That will certainly make setting the pixel color more interesting.

void lbmp()
{
for (int index = 0; index < 504; index++)
{
LcdWrite(LCD_D, pgm_read_byte(&logo2[index]));
}
}

solved… just change 504 with sizeof and pass logo