1

How to draw 2D-array directly on LCD 5110 (PCD8544)?

I have tried libraries like AdaFruit and several others.

But I need draw there via pixel 2D-array, something like this:

bool picture[48][84] = {
 {0,1,0,0, ... to 84 elements},
 {1,0,1,0,0, ...},
 ... to 48 elements
};

I haven't used charset table or geometry figures drawing library functions. Simplest and smallest drawing by pixel - 0 - not draw, 1 - draw pixel.

The "picture bitmap" will generate on the mini-pc board via Python and send to Arduino, which will draw it as "video card".

What is the simplest way to draw pixel in any site of the display without using powerful libraries?

Something about this:

// Send boolean bitmap 48x84 to LCD 5110
// Rows
for (int i=0; i<48; i++) {
 // Columns
 for (int j=0; j<84; j++) {
  // PIN 5 is Din on the 5110 module
  digitalWrite(5, picture[i][j]);
 }
}
3

2 Answers 2

1

For a start the Arduino Uno is incapable of storing that array in RAM. You're using twice as much memory for that array as the Arduino has in total. You will have to place it in PROGMEM and use the right functions to access it.

Secondly, you have to use a special library to control the display properly. That library will contain functions to draw on the screen. So your function to draw it would look something (though not exactly) like this:

const bool picture[] PROGMEM = {
    1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 
    ... etc ... ... 4032 numbers in total ...
};

for (int i=0; i<48; i++) {
    for (int j=0; j<84; j++) {
        lcd.setPixel(j, i, pgm_read_byte_near(picture + (i * 84 + j));
    }
}

Refer to the manual for the library for the actual function to run and how to configure and set up the LCD screen.

1
  • 1
    bool seems like a waste of memory. And the device has byte level transfer to the display memory. The memory requirements for an off-screen bitmap is only 48*84/8 = 504 bytes. Jan 2, 2017 at 13:12
0
// PIN 5 is Din on the 5110 module 
digitalWrite(5, picture[i][j]);

with that kind of code, I would suggest that you spend a little bit more time on understanding the libraries you are trying to use, or the datasheet if you aren't using any libraries and ask more directed questions.

embedded engineering is one that ties software with hardware and it is not possible for you to understand software without understanding, very well, the hardware first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.