2222#include < Adafruit_GFX.h>
2323#include < Adafruit_ILI9341.h>
2424
25- // Uart over BLE with large buffer to hold image, image size is
26- // size = width x height x 3 + 6
27- //
25+ // Uart over BLE with large buffer to hold image data
2826BLEUart bleuart (1024 *10 );
2927
3028/* The Image Transfer module sends the image of your choice to Bluefruit LE over UART.
@@ -140,6 +138,7 @@ void loop()
140138 uint8_t crc = bleuart.read ();
141139 // do checksum later
142140
141+ tft.setCursor (0 , imageHeight+1 );
143142 print_speed (totalPixel*3 + 7 , rxLastTime-rxStartTime);
144143
145144 // reset and waiting for new image
@@ -149,8 +148,9 @@ void loop()
149148 // extract pixel data and display on TFT
150149 uint16_t pixelNum = bleuart.available () / 3 ;
151150
152- // Draw up to color_buf size (512 pixel)
153- // the rest will be drawn in the next invocation of loop()
151+ // Draw multiple lines of image each time i.e pixelNum = n*imageWidth
152+ // pixelNum is capped at color_buf size (512 pixel)
153+ // the rest will be drawn in the next invocation of loop().
154154 pixelNum = min (pixelNum, sizeof (color_buf)/2 );
155155
156156 // Chop pixel number to multiple of image width
@@ -191,20 +191,36 @@ void connect_callback(uint16_t conn_handle)
191191 conn->requestMtuExchange (247 );
192192 tft.println (" Exchanging MTU" );
193193
194- tft.println (" Ready to receive Image" );
194+ tft.setTextColor (ILI9341_GREEN);
195+ tft.println (" Ready to receive new image" );
196+ tft.setTextColor (ILI9341_WHITE);
195197}
196198
197199void print_speed (uint32_t count, uint32_t ms)
198200{
199- Serial.print (" Received " );
200- Serial.print (count);
201- Serial.print (" bytes in " );
202- Serial.print (ms / 1000 .0F , 2 );
203- Serial.println (" seconds." );
204-
205- Serial.print (" Speed : " );
206- Serial.print ( (count / 1000 .0F ) / (ms / 1000 .0F ), 2 );
207- Serial.println (" KB/s.\r\n " );
201+ tft.print (" Received " );
202+
203+ tft.setTextColor (ILI9341_YELLOW);
204+ tft.print (count);
205+ tft.setTextColor (ILI9341_WHITE);
206+
207+ tft.print (" bytes in " );
208+
209+ tft.setTextColor (ILI9341_YELLOW);
210+ tft.print (ms / 1000 .0F , 2 );
211+ tft.setTextColor (ILI9341_WHITE);
212+
213+ tft.println (" seconds" );
214+
215+ tft.print (" Speed: " );
216+ tft.setTextColor (ILI9341_YELLOW);
217+ tft.print ( (count / 1000 .0F ) / (ms / 1000 .0F ), 2 );
218+ tft.setTextColor (ILI9341_WHITE);
219+ tft.println (" KB/s" );
220+
221+ tft.setTextColor (ILI9341_GREEN);
222+ tft.println (" Ready to receive new image" );
223+ tft.setTextColor (ILI9341_WHITE);
208224}
209225
210226void bleuart_rx_callback (uint16_t conn_hdl)
0 commit comments