I am in a midst of a small project requiring sending 2 forms of data to graphical LCD. The first part which I have completed duly involves sending of textual data to the LCD via Wifly while the 2nd one deals with image files. I have set up a GUI for this purpose using Java.
Before getting myself involved in finding a way to read the image files, I tried to test whether it will be possible to send the image files (in form of an array of bytes) to the LCD. Luckily I was able to but the problem was that the image wasn't displayed correctly on the LCD. I tried type casting the spiSerial.read() but to no avail. Kindly advice on what could I be missing.
Here is the code:
- CODE: SELECT_ALL_CODE
/*
This program handles displaying of images received from the SpiUart terminal
@author: A.Q.H
@version 3.0 // modified for glcd 15.4.2012
*/
#include "WiFly.h" // We use this for the preinstantiated SpiSerial object.
#include "LCD4884.h"
#include "DFrobot_bmp.h" // contains the image to be displayed for comparison purpose
void setup() {
lcd.LCD_init();
lcd.LCD_clear();
SpiSerial.begin();
//Serial.begin(9600);
}
void loop() {
unsigned char image[256];
if (SpiSerial.available() > 0) {
lcd.LCD_clear();
}
// get the incoming bytes of data
while (SpiSerial.available() > 0)
{
for(int i=0; i<256; i++)
{
image[i]= SpiSerial.read();
}
}
// display the DFrobot_bmp received from Wifly shield
lcd.LCD_draw_bmp_pixel(0,0, image, 84,24);
// display same but hard coded image
lcd.LCD_draw_bmp_pixel(2,3, DFrobot_bmp, 84,24);
}
The image that was received on the LCD is shown in the attachment while the expected one (which was hard coded into the program) is displayed under it. Sorry about the low quality image.
Thanks.