Added SPI burst mode to spi 8 bit.

Dependents:   Bicycl_Computer_NUCLEO-F411RE Bicycl_Computer_NUCLEO-L476RG

Fork of UniGraphic by GraphicsDisplay

Added SPI burst mode to this graphics driver. If whoever wants this rolled in to repository let me know. I replaced _spi.write(); with fastWrite(); and clearRX();

SPI8.cpp

// need to re-create SPI firmware to access SPI handle
static SPI_HandleTypeDef SpiHandle;

void SPI8::fastWrite(int data) {
    
      SpiHandle.Instance = SPI1;
    // Check if data is transmitted
    while ((SpiHandle.Instance->SR & SPI_SR_TXE) == 0);
    SpiHandle.Instance->DR = data;
}
    
void SPI8::clearRX( void ) {
        SpiHandle.Instance = SPI1;
    //Check if the RX buffer is busy
    //While busy, keep checking
    while (SpiHandle.Instance->SR & SPI_SR_BSY){   
        // Check RX buffer readable
        while ((SpiHandle.Instance->SR & SPI_SR_RXNE) == 0);
        int dummy = SpiHandle.Instance->DR;
    }
}      
Revision:
16:244f9563ebc1
Parent:
8:26757296c79d
Child:
22:f9a37f22b9cb
Child:
35:782de649ef6f
Child:
36:0ced7cf0ec8c
--- a/Graphics/GraphicsDisplay.cpp	Mon Feb 23 16:05:16 2015 +0000
+++ b/Graphics/GraphicsDisplay.cpp	Mon Feb 23 23:36:22 2015 +0000
@@ -333,36 +333,30 @@
 }
 void GraphicsDisplay::Bitmap(int x, int y, int w, int h,unsigned char *bitmap)
 {
-    int  j,i;
-    int padd;
+    int  j;
+    unsigned char  padd;
     unsigned short *bitmap_ptr = (unsigned short *)bitmap;    
-//    unsigned short i;
-    
-    // the lines are padded to multiple of 4 bytes in a bitmap
-    padd = -1;
-    do {
-        padd ++;
-    } while (2*(w + padd)%4 != 0);
+
+    padd = w%2; // the lines are padded to multiple of 4 bytes in a bitmap
     if(x<0) x=0;
+    else if(x>=oriented_width) return;
     if(y<0) y=0;
+    else if(y>=oriented_height) return;
     int cropX = (x+w)-oriented_width;
     if(cropX<0) cropX=0;
-    window(x, y, w-cropX, h);
-    bitmap_ptr += ((h - 1)* (w + padd));
-//    wr_cmd(0x2C);  // send pixel
-    for (j = 0; j < h; j++) {         //Lines
-        if((h + y) >= oriented_height) break; // no need to crop Y
-        for (i = 0; i < w; i++) {     // one line
-                if((w + x) < oriented_width) window_pushpixel(*bitmap_ptr); //fixme, send chunk w-cropX lenght and incr bitmapptr if out of margin
-                bitmap_ptr++;
-        }
-        bitmap_ptr -= 2*w;
-        bitmap_ptr -= padd;
+    int cropY = (y+h)-oriented_height;
+    if(cropY<0) cropY=0;
+    window(x, y, w-cropX, h-cropY);
+    bitmap_ptr += ((h - 1)* (w + padd)); // begin of last line in array (first line of image)(standard bmp scan direction is left->right bottom->top)
+    for (j = 0; j < h-cropY; j++) {         //Lines
+        window_pushpixelbuf(bitmap_ptr, w-cropX);
+        bitmap_ptr -= w+padd;
     }
     if(auto_up) copy_to_lcd();
 }
+
 // local filesystem is not implemented in kinetis board , but you can add a SD card
-
+// fixme this whole functions needs testing and speedup
 int GraphicsDisplay::BMP_16(int x, int y, const char *Name_BMP)
 {