Tomorrow, I’ll show how WiringPi can make GPIO pins change in under 100 nanoseconds. That’s at least 4.6 million GPIO pin settings in half a second! Note that this sends out all the data pixel by pixel to the display, and that each pixel takes the bit-banging of 2 bytes (the interface to the LCD is 8-bit wide), so each pixel takes at least 20 calls to digitalWrite(): 8 to set the data bits, and 2 two to toggle a clock pin – times two for the 2 bytes per pixel. uint32_t) array, although the image really only needs an uint16_t. Which is why rgbOut15 is declared as “unsigned” (int, i.e. All Im trying to do is display an image using Pillow on Raspberry Pi 3. Total waste of space, and probably the result of a rushed port from the UTFT code (written to assume 16-bit ints) to the RPi. The other gotcha was that the bitmap to be supplied to the LCD library on top of WiringPi was expected to store each pixel in a 32-bit int. This isn’t some tiny embedded 8-bit ♜ with a few kilobytes – it’s a full-blown O/S running on a 32-bit CPU with virtual memory! Note that this is a C program compiled and running under Linux on the RPi, and that it can therefore easily allocate some huge arrays. I didn’t see a quick way to convert the format to the desired 5-6-5-bit coding needed for the LCD, and since the code to write to the LCD is written in C anyway (to link to WiringPi), I ended up doing it all in a straightforward loop: As expected, the resulting image file is 320 x 240 x 3 = 230,400 bytes. If you have a PNG format image that you want to convert to JPEG this can be achieved from the command line: convert file.png file.jpeg. This handles both the rescaling and the transformation to a file with (R,G,B) types, each colour is one byte. To install ImageMagick on the Raspberry Pi sudo apt-get update sudo apt-get install imagemagick. Then we can run “convert” from the command-line (long live the Unix toolkit approach!): convert snap.jpg -geometry 320x240 -normalize snap.rgb ![]() The “convert” command makes things very easy, but first I had to install ImageMagick: sudo apt-get install ImageMagick but the result has 24-bit colour depth, whereas the LCD wants 16-bit (5-6-5).this is easy to fix using the ImageMagick “convert” command.the WiringPi library has code to put a bitmap on the screen, but not JPEGs.the image I wanted to use was 640×480, but the LCD is only 320×240 pixels.As shown yesterday, it’s relatively easy to get a bitmap onto an LCD screen connected to a few I/O pins of the Raspberry Pi.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |