Version 5.0. 4bit,3bit,1bit transfermode

Dependents:   MIP8f_FRDM_TransferMode_sample MIP8f_FRDM_CountUpNumber_sample2

MIP8F_SPI_Ver5.0

Ver5.0 Addtional function is checking the refresh display speed between 4bit,3bit and 1bit transfer mode

  • spi-transfer to Display has 3 mode. 4bit mode is color display, this bit arrange is R,G,B,x. R,G,B = R,G,B subpixel bit. x bit is Dummy. 3bit mode is color display, this bit arrange is R,G,B. R,G,B = R,G,B subpixel bit. No bit is Dummy. 1bit mode is monocrome display,high speed refresh mode. a only Green subpixel of bitmap data is transfered.

Files at this revision

API Documentation at this revision

Comitter:
JDI_Mbed_Team
Date:
Wed Nov 21 07:28:10 2018 +0000
Parent:
5:8cc8e00fed46
Commit message:
MIP8F_SPI_Ver60

Changed in this revision

MIP8F_SPI.cpp Show annotated file Show diff for this revision Revisions of this file
MIP8F_SPI.h Show annotated file Show diff for this revision Revisions of this file
diff -r 8cc8e00fed46 -r 4bfbc7e50577 MIP8F_SPI.cpp
--- a/MIP8F_SPI.cpp	Mon Nov 12 05:08:34 2018 +0000
+++ b/MIP8F_SPI.cpp	Wed Nov 21 07:28:10 2018 +0000
@@ -29,7 +29,7 @@
 #include "MIP8F_SPI.h"
 
 // for debug
-//Serial pc2(USBTX, USBRX); // tx, rx
+Serial pc2(USBTX, USBRX); // tx, rx
 
 memLCD8::memLCD8(PinName mosi,PinName miso,PinName sclk,PinName cs,PinName disp,PinName power)
     : _spi(mosi, miso, sclk),_cs(cs),_disp(disp),_power(power)
@@ -51,6 +51,12 @@
         _cs  = 0;
     */
     _FixedFontWidth=0;//setting:actual font width display  if _FixedFontWidth !=1: font fixed witdh
+#if MOVIEBUFF_MODE    
+    //movie_height = 80;
+    //movie_width = 80;
+    _height = 240;
+    _width = 400;
+#endif
 }
 
 /**
@@ -713,7 +719,7 @@
     {
     case 0x90: //TrBIT4:
         // buffer 2pixel/1byte => 2pixel/1byte  buffe 2byte毎進める。
-        TrValue[0] = _dispBUF[_y* _width/2 + _x];
+        TrValue[0] = buff[_y* _width/2 + _x];
         break;
     case 0x80://TrBIT3:
         // buffer 2pixel/1byte => 3pixel-1subpixel/1bye (24 pixel/3byte) buffer 3byte毎進める。
@@ -723,27 +729,27 @@
             //4 bit RGBN(Nは予備) => 3bit RGB
             if( _width/2 > _x )
             {
-                TrValue[0] = TrValue[0] | ( ( (_dispBUF[_y* _width/2 + _x    ]&0xE0) ) );
-                TrValue[0] = TrValue[0] | ( ( (_dispBUF[_y* _width/2 + _x    ]&0x0E) ) << 1);
+                TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x    ]&0xE0) ) );
+                TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x    ]&0x0E) ) << 1);
             }
             if( _width/2 > _x + 1 )
             {
-                TrValue[0] = TrValue[0] | ( ( (_dispBUF[_y* _width/2 + _x + 1]&0xC0) ) >> 6);
+                TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x + 1]&0xC0) ) >> 6);
 
-                TrValue[1] = TrValue[1] | ( ( (_dispBUF[_y* _width/2 + _x + 1]&0x20) ) << 2);
-                TrValue[1] = TrValue[1] | ( ( (_dispBUF[_y* _width/2 + _x + 1]&0x0E) ) << 3);
+                TrValue[1] = TrValue[1] | ( ( (buff[_y* _width/2 + _x + 1]&0x20) ) << 2);
+                TrValue[1] = TrValue[1] | ( ( (buff[_y* _width/2 + _x + 1]&0x0E) ) << 3);
             }
             if( _width/2 > _x + 2 )
             {
-                TrValue[1] = TrValue[1] | ( ( (_dispBUF[_y* _width/2 + _x + 2]&0xE0) ) >> 4);
-                TrValue[1] = TrValue[1] | ( ( (_dispBUF[_y* _width/2 + _x + 2]&0x08) ) >> 3);
+                TrValue[1] = TrValue[1] | ( ( (buff[_y* _width/2 + _x + 2]&0xE0) ) >> 4);
+                TrValue[1] = TrValue[1] | ( ( (buff[_y* _width/2 + _x + 2]&0x08) ) >> 3);
 
-                TrValue[2] = TrValue[2] | ( ( (_dispBUF[_y* _width/2 + _x + 2]&0x06) ) << 5);
+                TrValue[2] = TrValue[2] | ( ( (buff[_y* _width/2 + _x + 2]&0x06) ) << 5);
             }
             if( _width/2 > _x + 3 )
             {
-                TrValue[2] = TrValue[2] | ( ( (_dispBUF[_y* _width/2 + _x + 3]&0xE0) ) >> 2);
-                TrValue[2] = TrValue[2] | ( ( (_dispBUF[_y* _width/2 + _x + 3]&0x0E) ) >> 1);
+                TrValue[2] = TrValue[2] | ( ( (buff[_y* _width/2 + _x + 3]&0xE0) ) >> 2);
+                TrValue[2] = TrValue[2] | ( ( (buff[_y* _width/2 + _x + 3]&0x0E) ) >> 1);
             }    
         }
         break;
@@ -755,8 +761,8 @@
             //Green bit => monochrome bit
             if( _width/2 > _x + i )
             {
-                TrValue[0] = TrValue[0] | ( ( (_dispBUF[_y* _width/2 + _x + i]&0x40) == 0 ? 0 : 1 ) << (7-i*2)   );
-                TrValue[0] = TrValue[0] | ( ( (_dispBUF[_y* _width/2 + _x + i]&0x04) == 0 ? 0 : 1 ) << (7-i*2)-1 );
+                TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x + i]&0x40) == 0 ? 0 : 1 ) << (7-i*2)   );
+                TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x + i]&0x04) == 0 ? 0 : 1 ) << (7-i*2)-1 );
                 //pc2.printf("[%d+%d][%d]<0x%x>\n",_x,i,_y,_dispBUF[_y* _width/2 + _x + i]);
             }
         }
@@ -819,6 +825,9 @@
     
     // frame
     for (int i=startline; i<=endline; i++) {
+        if( i >= _height ) continue;
+        if( i <0   ) continue;
+        
         // line
         wait_us(6);
         _cs  = 1;
@@ -887,5 +896,149 @@
         }
     }
 }
+#if MOVIEBUFF_MODE
+/**
+* @brief  Transfer One Pixel Data with x,y allocation to Animation buffer
+* @param[in] int x : horizontal allocation left to right
+* @param[in] int y : vertival allocation top to bottom
+* @param[in] uint8_t color : the color data for Drawing  0x0X  x is color data(RGBC) C is not used
+* @param[in] int memnu : animation buffer number.
+*/
+void memLCD8::movie_pixel(int x, int y, uint8_t color,int memnum)
+{
+    //pc2.printf("movie_pixel[%d][%d]col[%d]\n",x,y,color);
+    if(!(x % 2)) _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2] =  _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]&0x0F  |  (color << 4)&0xF0 ;   //MASK 0000 1111
+    else         _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2] =  _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]&0xF0  |  (color     )&0x0F ;   //MASK 1111 0000
+}
+
+/**
+* @brief  Transfer Pixel Data of Animation buffer with x,y allocation to frame buffer.
+* @param[in] int sx : horizontal start allocation left to right
+* @param[in] int sy : vertival start allocation top to bottom
+* @param[in] int memnu : animation buffer number.
+*/
+void memLCD8::makeMovieFrame(int sx , int sy, int memnum)
+{
+    int x,y;
+    //pc2.printf("1<%d,%d>\n",_width,_height);
+    for(y = 0; y < MOVIE_VERT_SIZE;y++)
+    {
+        for(x = 0; x < MOVIE_HORI_SIZE ;x+=2)
+        {
+                if( (sx + x) >= _width ) continue;
+                if( (sx + x) < 0 ) continue;
+                if( (sy + y) >= _height ) continue;
+                if( (sy + y) < 0 ) continue;
+                
+                _dispBACKUPBUF[y*MOVIE_HORI_SIZE/2+x/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2];
+
+                if( (_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]&0xF0) != 0 )
+                    _dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]&0x0F | _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]&0xF0;   //MASK 0000 1111
+
+                if( (_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]&0x0F) != 0 )
+                    _dispBUF[(sy+y)*(_width)/2+(sx+x)/2] =  _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]&0xF0 | _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]&0x0F;   //MASK 0000 1111
+        
+            //pc2.printf("dispMOVIEBUF[%d][%d] = %d\n",x,y,_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]);
+           //_dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2];
+        }
+    }
+    //pc2.printf("memnum=%d,x=%d,y=%d>sx=%d,sy=%d\n",memnum,sx,sy,(sx+x)-1,(sy+y)-1);
+
+}
+/**
+* @brief  Transfer Pixel Data of Animation buffer with x,y allocation to frame buffer.  animation data read right to left.
+* @param[in] int sx : horizontal start allocation left to right
+* @param[in] int sy : vertival start allocation top to bottom
+* @param[in] int memnu : animation buffer number.
+*/
+void memLCD8::makeMovieFrame_Reverse(int sx , int sy, int memnum)
+{
+    int x,y;
+    //pc2.printf("1<%d,%d>\n",_width,_height);
+    for(y = 0; y < MOVIE_VERT_SIZE ;y++)
+    {
+        for(x = 0; x < MOVIE_HORI_SIZE  ;x+=2)
+        {
+                if( (sx + x) >= _width ) continue;
+                if( (sx + x) < 0 ) continue;
+                if( (sy + y) >= _height ) continue;
+                if( (sy + y) < 0 ) continue;
+                
+                _dispBACKUPBUF[y*MOVIE_HORI_SIZE/2+x/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2];
+
+                if( (_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+(MOVIE_HORI_SIZE-2-x)/2]&0xF0) != 0 )
+                    _dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]&0x0F | _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+(MOVIE_HORI_SIZE-2-x)/2]&0xF0;   //MASK 0000 1111
+
+                if( (_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+(MOVIE_HORI_SIZE-2-x)/2]&0x0F) != 0 )
+                    _dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]&0xF0 | _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+(MOVIE_HORI_SIZE-2-x)/2]&0x0F;   //MASK 0000 1111
+        
+            //pc2.printf("dispMOVIEBUF[%d][%d] = %d\n",x,y,_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]);
+           //_dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2];
+        }
+    }
+    //pc2.printf("memnum=%d,x=%d,y=%d>sx=%d,sy=%d\n",memnum,sx,sy,(sx+x)-1,(sy+y)-1);
+
+}
+/**
+* @brief  Transfer Pixel Data of Animation buffer with x,y allocation to frame buffer.  animation data bottom to top.
+* @param[in] int sx : horizontal start allocation left to right
+* @param[in] int sy : vertival start allocation top to bottom
+* @param[in] int memnu : animation buffer number.
+*/
+void memLCD8::makeMovieFrame_Updown(int sx , int sy, int memnum)
+{
+    int x,y;
+    //pc2.printf("1<%d,%d>\n",_width,_height);
+    for(y = 0; y < MOVIE_VERT_SIZE ;y++)
+    {
+        for(x = 0; x < MOVIE_HORI_SIZE  ;x+=2)
+        {
+                if( (sx + x) >= _width ) continue;
+                if( (sx + x) < 0 ) continue;
+                if( (sy + y) >= _height ) continue;
+                if( (sy + y) < 0 ) continue;
+                
+                _dispBACKUPBUF[y*MOVIE_HORI_SIZE/2+x/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2];
+
+                if( (_dispMOVIEBUF[memnum][(MOVIE_VERT_SIZE-1-y)*MOVIE_HORI_SIZE/2+x/2]&0xF0) != 0 )
+                    _dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]&0x0F | _dispMOVIEBUF[memnum][(MOVIE_VERT_SIZE-1-y)*MOVIE_HORI_SIZE/2+x/2]&0xF0;   //MASK 0000 1111
+
+                if( (_dispMOVIEBUF[memnum][(MOVIE_VERT_SIZE-1-y)*MOVIE_HORI_SIZE/2+x/2]&0x0F) != 0 )
+                    _dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]&0xF0 | _dispMOVIEBUF[memnum][(MOVIE_VERT_SIZE-1-y)*MOVIE_HORI_SIZE/2+x/2]&0x0F;   //MASK 0000 1111
+        
+            //pc2.printf("dispMOVIEBUF[%d][%d] = %d\n",x,y,_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]);
+           //_dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2];
+        }
+    }
+    //pc2.printf("memnum=%d,x=%d,y=%d>sx=%d,sy=%d\n",memnum,sx,sy,(sx+x)-1,(sy+y)-1);
+
+}
+/**
+* @brief  Transfer  Pixel Data of backuped original frame buffer with x,y allocation to frame buffer.
+* @param[in] int sx : horizontal start allocation left to right
+* @param[in] int sy : vertival start allocation top to bottom
+* @param[in] int memnu : animation buffer number.
+*/
+void memLCD8::RestoreMovieFrame(int sx , int sy, int memnum)
+{
+    int x,y;
+    //pc2.printf("1<%d,%d>\n",_width,_height);
+    for(y = 0; y < MOVIE_VERT_SIZE;y++)
+    {
+        for(x = 0; x < MOVIE_HORI_SIZE ;x++)
+        {
+           if( (sx + x) >= _width ) continue;
+           if( (sx + x) < 0 ) continue;
+           if( (sy + y) >= _height ) continue;
+           if( (sy + y) < 0 ) continue;
+           _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]=_dispBACKUPBUF[y*MOVIE_HORI_SIZE/2+x/2];
+        }
+    }
+    //pc2.printf("memnum=%d,x=%d,y=%d>sx=%d,sy=%d\n",memnum,sx,sy,(sx+x)-1,(sy+y)-1);
+
+}
+//end MOVIEBUFF_MODE
+#endif
+//end FRAMEBUFF_MODE
 #endif
 
diff -r 8cc8e00fed46 -r 4bfbc7e50577 MIP8F_SPI.h
--- a/MIP8F_SPI.h	Mon Nov 12 05:08:34 2018 +0000
+++ b/MIP8F_SPI.h	Wed Nov 21 07:28:10 2018 +0000
@@ -33,6 +33,8 @@
 * @brief If you will use a Frame Buffer mode,you must define LINEBUFF_MODE 1
 */
 #define FRAMEBUFF_MODE 1
+
+#define MOVIEBUFF_MODE 1
 /*****************************************
 ******************************************/
 #if LINEBUFF_MODE
@@ -43,6 +45,12 @@
     //#define FRAME_SIZE 9328  //1flame = 212dot X 88dot  1dot = 4bit
     #define FRAME_SIZE  153600  //  153600 640 x 480        103600  400dot x 200dot    1dot = 4bit
 #endif
+#if MOVIEBUFF_MODE
+    #define MOVIE_SIZE  3200  //  80x80/2
+    #define MOVIE_NUM   10
+    #define MOVIE_VERT_SIZE 80
+    #define MOVIE_HORI_SIZE 80
+#endif
 
 // RGB color definitions       /*  R, G, B  */
 #define Black           0x00    /*  0  0  0  */
@@ -124,7 +132,13 @@
     void oblique(int x, int y, int c);
     int  obliqueout(int x,int y,char* text);
 #endif
-
+#if MOVIEBUFF_MODE
+    void movie_pixel(int x, int y, uint8_t color,int memnum);
+    void makeMovieFrame(int sx , int sy, int memnum);
+    void makeMovieFrame_Reverse(int sx , int sy, int memnum);
+    void makeMovieFrame_Updown(int sx , int sy, int memnum);
+    void RestoreMovieFrame(int sx , int sy, int memnum);
+#endif
 protected:
     virtual int _putc(int value);
     virtual int _getc();
@@ -159,13 +173,19 @@
     //! line buffer for display
     uint8_t _dispLINEBUF[LINE_SIZE];
 #endif
-
     //! height,diplay pixel size 
     int _height;
     //! width,diplay pixel size 
     int _width;
     unsigned int char_x;
     unsigned int char_y;
+
+#if MOVIEBUFF_MODE
+    uint8_t _dispMOVIEBUF[MOVIE_NUM][MOVIE_SIZE];
+    //int movie_height;
+    //int movie_width;
+    uint8_t _dispBACKUPBUF[MOVIE_SIZE];
+#endif
     
     //ver2.0
     //! SPI transfer mode command to MIP8 diplay