@@ -27,12 +27,12 @@ BLEUart bleuart(1024*10);
2727
2828/* The Image Transfer module sends the image of your choice to Bluefruit LE over UART.
2929 * Each image sent begins with
30- * - A single byte char '!' (0x21)
30+ * - A single byte char '!' (0x21) followed by 'I' helper for image
3131 * - Image width (uint16 little endian, 2 bytes)
3232 * - Image height (uint16 little endian, 2 bytes)
3333 * - Pixel data encoded as RGB 24-bit and suffixed by a single byte CRC.
3434 *
35- * Format: [ '!' ] [ uint16 width ] [ uint16 height ] [ r g b ] [ r g b ] [ r g b ] … [ CRC ]
35+ * Format: [ '!' ] [ 'I' ] [ uint16 width ] [ uint16 height ] [ r g b ] [ r g b ] [ r g b ] … [ CRC ]
3636 */
3737
3838uint16_t imageWidth = 0 ;
@@ -42,7 +42,9 @@ uint16_t imageY = 0;
4242
4343uint32_t totalPixel = 0 ; // received pixel
4444
45- uint16_t color_buf[512 ];
45+ // color buf must be large enough to consume incoming data fast enough
46+ // otherwise bleuart fifo could be overflow and start dropping data
47+ uint16_t color_buf[2048 ];
4648
4749// Statistics for speed testing
4850uint32_t rxStartTime = 0 ;
@@ -81,7 +83,7 @@ void setup()
8183 Bluefruit.configPrphBandwidth (BANDWIDTH_MAX);
8284
8385 Bluefruit.begin ();
84- Bluefruit.setTxPower (4 ); // Check bluefruit.h for supported values
86+ Bluefruit.setTxPower (8 ); // Check bluefruit.h for supported values
8587 Bluefruit.setName (" Bluefruit52" );
8688 Bluefruit.Periph .setConnectCallback (connect_callback);
8789 Bluefruit.Periph .setDisconnectCallback (disconnect_callback);
@@ -235,11 +237,11 @@ void bleuart_rx_callback(uint16_t conn_hdl)
235237 {
236238 rxStartTime = millis ();
237239
238- // Skip all data until '!' is found
240+ // Skip all data until '!I ' is found
239241 while ( bleuart.available () && bleuart.read () != ' !' ) { }
240- if ( ! bleuart.available () ) return ;
242+ if (bleuart.read () != ' I ' ) return ;
241243
242- bleuart.read (); // skip unicode extra byte following '!'
244+ if ( ! bleuart.available () ) return ;
243245
244246 imageWidth = bleuart.read16 ();
245247 imageHeight = bleuart.read16 ();
0 commit comments