JapanDisplayInc / MIP8F_SPI_Ver70
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MIP8F_SPI.cpp Source File

MIP8F_SPI.cpp

Go to the documentation of this file.
00001 /**
00002 * @file MIP8F_SPI.cpp
00003 * @brief ver5.0 Library source code file: Class for JDI MIP8 display
00004 * @details
00005 * Ver5.0 Addtional function is checking the refresh display speed between 4bit,3bit and 1bit transfer mode 
00006 * Ver4.0 Addtional function is Line buffer version
00007 * Ver3.0 Addtional function is font display
00008 * ver2.0 Addtional function is Monochome display by 1bit mode of SPI transfer.
00009 *
00010 * spi-transfer to Display has 3 mode. 
00011 * 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.
00012 * 3bit mode is color display, this bit arrange is  R,G,B.   R,G,B = R,G,B subpixel bit.  No bit is Dummy.
00013 * 1bit mode is monocrome display,high speed refresh mode. a only Green subpixel of bitmap data is transfered.
00014 *
00015 * <license>
00016 * Copyright 2018 Japan Display Inc.
00017 * Licensed under the Apache License, Version 2.0 (the "License");
00018 * you may not use this file except in compliance with the License.
00019 * You may obtain a copy of the License at
00020 *     http://www.apache.org/licenses/LICENSE-2.0
00021 * Unless required by applicable law or agreed to in writing, software
00022 * distributed under the License is distributed on an "AS IS" BASIS,
00023 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00024 * See the License for the specific language governing permissions and
00025 * limitations under the License.
00026 */
00027 
00028 #include "mbed.h"
00029 #include "MIP8F_SPI.h"
00030 
00031 // for debug
00032 Serial pc2(USBTX, USBRX); // tx, rx
00033 
00034 memLCD8::memLCD8(PinName mosi,PinName miso,PinName sclk,PinName cs,PinName disp,PinName power)
00035     : _spi(mosi, miso, sclk),_cs(cs),_disp(disp),_power(power)
00036 {
00037 
00038     _power= 0;
00039     _disp=  0;
00040     _cs  =  0;
00041     wait_us(100);
00042 
00043     _power= 1;
00044     _spi.format(8,0);                // 8bit mode3
00045     _spi.frequency(2000000);         // 2 Mhz SPI clock
00046     _spi.write(0x00);                // mbed dummy
00047 
00048     /*
00049         _cs  = 1;
00050         command(0x02);   // All crear mode
00051         _cs  = 0;
00052     */
00053     _FixedFontWidth=0;//setting:actual font width display  if _FixedFontWidth !=1: font fixed witdh
00054 #if MOVIEBUFF_MODE    
00055     //movie_height = 80;
00056     //movie_width = 80;
00057     _height = 240;
00058     _width = 400;
00059 #endif
00060 }
00061 
00062 /**
00063 * @brief  set font name
00064 */
00065 void memLCD8::set_font(unsigned char* f)
00066 {
00067     font = f;
00068 }
00069 
00070 /**
00071 * @brief  set allocation for font display
00072 */
00073 void memLCD8::locate(int x, int y)
00074 {
00075     char_x = x;
00076     char_y = y;
00077 }
00078 
00079 /**
00080 * @brief  setting fixed width between charactor and charctor  for font display
00081 */
00082 void memLCD8::set_FixedFontWidth( unsigned char width )
00083 {
00084     _FixedFontWidth = width;
00085 }
00086 /**
00087 * @brief  setting Actual width between charactor and charctor  for font display
00088 */
00089 void memLCD8::set_ActualFontWidth(void)
00090 {
00091     _FixedFontWidth = 0;
00092 }
00093 
00094 /**
00095 * @brief  set Configuration for transfer mode
00096 * @param[in] int transfermode : instruction the transfer data size ,4bit,3bit,1bit and some parameter
00097 */
00098 void memLCD8::SetTransfermode(int transfermode)
00099 {
00100     switch(transfermode)
00101     {
00102     case TrBIT4:
00103         TrModeCommand = 0x90;
00104         TrAdd = 1;
00105         TrValNum = 1;
00106         break;
00107     case TrBIT3:
00108         TrModeCommand = 0x80;
00109         TrAdd = 4;
00110         TrValNum = 3;
00111         break;
00112     case TrBIT1:
00113         TrModeCommand = 0x88;
00114         TrAdd = 4;
00115         TrValNum = 1;
00116         break;
00117     }
00118 }
00119 
00120 /**
00121 * @brief  set a display size ,width ,height
00122 */
00123 void memLCD8::setWH(int width, int height)
00124 {
00125     _width  = width;
00126     _height = height;
00127 }
00128 
00129 /**
00130 * @brief  set color data of foreground
00131 */
00132 void memLCD8::foreground(uint8_t colour)
00133 {
00134     _foreground = colour;
00135 }
00136 
00137 /**
00138 * @brief  set color data of background
00139 */
00140 void memLCD8::background(uint8_t colour)
00141 {
00142     _background = colour;
00143 }
00144 
00145 /**
00146 * @brief  set the Diaplay On/Off data
00147 */
00148 void memLCD8::SwDisp(bool ONorOFF)
00149 {
00150     _disp= ONorOFF;
00151 }
00152 
00153 /**
00154 * @brief  transfer a command code to the display by SPI
00155 */
00156 void memLCD8::command(char command)
00157 {
00158     wait_us(6);
00159     _cs  = 1;
00160     wait_us(6);
00161     _spi.write(command);//
00162     _spi.write(0x00);// dummy
00163     wait_us(6);
00164     _cs  = 0;
00165 }
00166 
00167 /**
00168 * @brief  putc
00169 */
00170 int memLCD8::_putc(int value)
00171 {
00172     if (value == '\n') {    // new line
00173         char_x = 0;
00174         char_y = char_y + font[3];
00175         if (char_y >= _height - font[3]) {
00176             char_y = 0;
00177         }
00178     }
00179 #if FRAMEBUFF_MODE
00180      else {
00181         character(char_x, char_y, value);
00182     }
00183 #endif
00184     return value;
00185 }
00186 
00187 /**
00188 * @brief  getc
00189 */
00190 int memLCD8::_getc()
00191 {
00192     return -1;
00193 }
00194 /**
00195 * @brief  get color data of background
00196 */
00197 unsigned char memLCD8::get_Background(void)
00198 {
00199     return _background;
00200 }
00201 /*
00202 void memLCD8::setmarge(bool ifMarge)
00203 {
00204     _ifMarge = ifMarge;
00205 }
00206 */
00207 //////////////////////////////////////////////////////////////////////////////
00208 // line buffer mode
00209 //////////////////////////////////////////////////////////////////////////////
00210 #if LINEBUFF_MODE
00211 /**
00212 * @brief  Transfer One Pixel Data with x,y allocation Line buffer mode
00213 * @param[in] int x : horizontal allocation left to right
00214 * @param[in] uint8_t color : the color data for Drawing  0x0X  x is color data(RGBC) C is not used
00215 */
00216 void memLCD8::pixel(int x, uint8_t color)
00217 {
00218     if(!(x % 2)) _dispLINEBUF[x/2] =  _dispLINEBUF[x/2]&0x0F  |  (color << 4)&0xF0 ;   //MASK 0000 1111
00219     else         _dispLINEBUF[x/2] =  _dispLINEBUF[x/2]&0xF0  |  (color     )&0x0F ;   //MASK 1111 0000
00220 }
00221 
00222 /**
00223 * @brief  Transfer Pixel Data from same Line buffer to Display
00224 */
00225 void memLCD8::writeDISPLinebuffer(void)    // refresh whole display
00226 {
00227 
00228     char pol = 0;
00229     char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW  A  1010
00230 
00231     // frame
00232     for (int i=0; i<_height; i++) {
00233         // line
00234         wait_us(6);
00235         _cs  = 1;
00236         wait_us(6);
00237         _spi.write(command | (pol << 6) | (i+1)>>8 ); // COMMAND
00238         _spi.write((i+1)& 0x00FF ); // V ADDR
00239         for(int j=0; j<_width/2; j++) _spi.write(_dispLINEBUF[j]);
00240         _spi.write(0x00); // DUMMY transfer
00241         _spi.write(0x00); // DUMMY transfer
00242         wait_us(6);
00243         _cs  = 0;
00244         if(pol) pol=0x00;
00245         else    pol=0x01;
00246     }
00247 }
00248 
00249 /**
00250 * @brief  Transfer Pixel Data from line buffer to Display
00251 * @param[in] int line : set line number for display.
00252 * @param[in] int transfermode : instruction the transfer data size ,4bit,3bit,1bit
00253 */
00254 void memLCD8::writeDISP(int line,int transfermode)    // refresh gate line display
00255 {
00256 
00257     char pol = 0;
00258     //char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW  A  1010
00259     SetTransfermode(transfermode);
00260     
00261     // frame
00262         // line
00263         wait_us(6);
00264         _cs  = 1;
00265         wait_us(6);
00266         _spi.write(TrModeCommand | (pol << 6) | (line+1)>>8 ); // COMMAND
00267         //pc2.printf("com 0x%x\n",TrModeCommand | (pol << 6) | (i+1)>>8);
00268         
00269         _spi.write((line+1)& 0x00FF ); // V ADDR
00270         //pc2.printf("v adr 0x%x\n",(i+1)& 0x00FF);
00271         
00272         for(int j=0; j<_width; j+=TrAdd)
00273         {
00274             GetPixelValueFromLineBuffer(j,_dispLINEBUF);
00275             //pc2.printf("data=[%d]{%d][%d]/[%d]\n",j*TrAdd,i,TrValue[0],TrAdd);
00276             for(int k=0;k<TrValNum;k++)
00277                 _spi.write(TrValue[k]);
00278         }
00279         _spi.write(0x00); // DUMMY transfer
00280         _spi.write(0x00); // DUMMY transfer
00281 //        wait_ms(1);      //1.8Hz simulation
00282 //        wait_ms(2);      //1.35Hz simulation
00283         wait_us(6);
00284         _cs  = 0;
00285         if(pol) pol=0x00;
00286         else    pol=0x01;
00287 
00288 }
00289 
00290 /**
00291 * @brief  Get Edited data for SPI transfer from line buffer
00292 * @param[in] int x : horizontal allocation left to right
00293 * @param[in] uint8_t* buff : buffer data for Display
00294 */
00295 int* memLCD8::GetPixelValueFromLineBuffer(int _x,uint8_t* buff)
00296 {
00297     //bitmap data = 4bit data => modify transfer data bit size;
00298     switch(TrModeCommand)
00299     {
00300     case 0x90: //TrBIT4:
00301         // buffer 2pixel/1byte => 2pixel/1byte  buffe 2byte毎進める。
00302         TrValue[0] = _dispLINEBUF[_x];
00303         break;
00304     case 0x80://TrBIT3:
00305         // buffer 2pixel/1byte => 3pixel-1subpixel/1bye (24 pixel/3byte) buffer 3byte毎進める。
00306         for(int j=0;j<3;j++) TrValue[j] = 0;
00307         //for( int i = 0 ; i<12 ; i--)
00308         {
00309             //4 bit RGBN(Nは予備) => 3bit RGB
00310             if( _width/2 > _x )
00311             {
00312                 TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_x    ]&0xE0) ) );
00313                 TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_x    ]&0x0E) ) << 1);
00314             }
00315             if( _width/2 > _x + 1 )
00316             {
00317                 TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_x + 1]&0xC0) ) >> 6);
00318 
00319                 TrValue[1] = TrValue[1] | ( ( (_dispLINEBUF[_x + 1]&0x20) ) << 2);
00320                 TrValue[1] = TrValue[1] | ( ( (_dispLINEBUF[_x + 1]&0x0E) ) << 3);
00321             }
00322             if( _width/2 > _x + 2 )
00323             {
00324                 TrValue[1] = TrValue[1] | ( ( (_dispLINEBUF[ _x + 2]&0xE0) ) >> 4);
00325                 TrValue[1] = TrValue[1] | ( ( (_dispLINEBUF[ _x + 2]&0x08) ) >> 3);
00326 
00327                 TrValue[2] = TrValue[2] | ( ( (_dispLINEBUF[_x + 2]&0x06) ) << 5);
00328             }
00329             if( _width/2 > _x + 3 )
00330             {
00331                 TrValue[2] = TrValue[2] | ( ( (_dispLINEBUF[ _x + 3]&0xE0) ) >> 2);
00332                 TrValue[2] = TrValue[2] | ( ( (_dispLINEBUF[_x + 3]&0x0E) ) >> 1);
00333             }    
00334         }
00335         break;
00336     case 0x88://TrBIT1:
00337         // buffer 2pixel/1byte => 8 pixel/1byte  buffe 4byte毎進める。
00338         for(int j=0;j<3;j++) TrValue[j] = 0;
00339         for(int i = 0 ; i<4 ; i++)
00340         {
00341             //Green bit => monochrome bit
00342             if( _width/2 > _x + i )
00343             {
00344                 TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_x + i]&0x40) == 0 ? 0 : 1 ) << (7-i*2)   );
00345                 TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_x + i]&0x04) == 0 ? 0 : 1 ) << (7-i*2)-1 );
00346                 //pc2.printf("[%d+%d][%d]<0x%x>\n",_x,i,_y,_dispBUF[_y* _width/2 + _x + i]);
00347             }
00348         }
00349         break;
00350     }
00351     return TrValue;   
00352 }
00353 
00354 /**
00355 * @brief  clear line buffer data by background color data
00356 */
00357 void memLCD8::clsLINEBUF(void)
00358 {
00359 
00360     for (int j=0; j<_width; j++) {
00361         pixel(j,_background);
00362     }
00363 }
00364 #endif
00365 //////////////////////////////////////////////////////////////////////////////
00366 // Frame buffer mode
00367 //////////////////////////////////////////////////////////////////////////////
00368 #if FRAMEBUFF_MODE
00369 
00370 /**
00371 * @brief  display the text.
00372 * @param[in] int x : horizontal allocation , up-left of text
00373 * @param[in] int y : vertical allocation , bottom-right of text
00374 * @param[in] char* text : strings
00375 */
00376 int memLCD8::textout(int x,int y,char* text)
00377 {
00378     int i=0;
00379     char_x = x;
00380     char_y = y;
00381 
00382     while(text[i] != 0x00 )
00383     {
00384        character(char_x, char_y, text[i]);
00385        i++;
00386     }
00387     return text[i];
00388 }
00389 
00390 /**
00391 * @brief  display the oblique text.
00392 * @param[in] int x : horizontal allocation , up-left of text
00393 * @param[in] int y : vertical allocation , bottom-right of text
00394 * @param[in] char* text : strings
00395 */
00396 int memLCD8::obliqueout(int x,int y,char* text)
00397 {
00398     int i=0;
00399     char_x = x;
00400     char_y = y;
00401 
00402     while(text[i] != 0x00 )
00403     {
00404        oblique(char_x, char_y, text[i]);
00405        i++;
00406     }
00407     return text[i];
00408 }
00409 
00410 /**
00411 * @brief  display the oblique text.
00412 * @param[in] int x : horizontal allocation , up-left of text
00413 * @param[in] int y : vertical allocation , bottom-right of text
00414 * @param[in] char* text : strings
00415 * @param[in] int rx : a horizontal multiple numbler
00416 * @param[in] int ry : a vertical multiple numbler
00417 */
00418 int memLCD8::obliqueout_multi(int x,int y,char* text,int rx,int ry)
00419 {
00420     int i=0;
00421     char_x = x;
00422     char_y = y;
00423 
00424     while(text[i] != 0x00 )
00425     {
00426        oblique_multi(char_x, char_y, text[i],rx,ry);
00427        i++;
00428     }
00429     return text[i];
00430 }
00431 
00432 
00433 /**
00434 * @brief  dispay a character by bog font. big font is that "char data" byte size is over 0xff.
00435 * @param[in] int x : horizontal allocation , up-left of text
00436 * @param[in] int y : vertical allocation , bottom-right of text
00437 * @param[in] char c : a charactor.
00438 * 
00439 */
00440 void memLCD8::character(int x, int y, int c)
00441 {
00442     unsigned int hor,vert,offset0,offset1,bpl,j,i,b; // T.Okamoto modified, for big font
00443     unsigned int headroffset;// 2018-10-26 added by Y.Saruhashi
00444     unsigned char* zeichen;
00445     unsigned char z,w;
00446 
00447     if ((c < 32) || (c > 127)) return;   // test char range
00448 
00449     //for big font
00450     offset0 = font[0];  // bytes / char uppser adress
00451     offset1 = font[1];  // bytes / char lower adress
00452     hor = font[2];      // get hor size of font
00453     vert = font[3];     // get vert size of font
00454     bpl = font[4];      // bytes per line
00455     headroffset = 5;
00456 
00457     if (char_x + hor > _width) {
00458         char_x = 0;
00459         char_y = char_y + vert;
00460         if (char_y >= _height - vert) char_y = 0; // original =  font[2]  T.Okamoto modified, for big font
00461     }
00462 
00463     zeichen = &font[(c -32) * (offset0 *256 + offset1) + headroffset]; // start of char bitmap // original =  +4  T.Okamoto modified, for big font
00464     
00465     if( _FixedFontWidth == 0 ) w = zeichen[0];                          // width of actual char
00466     else                       w = _FixedFontWidth;                     // fixed width of char
00467 
00468     for (j=0; j<vert; j++) {  //  vert line
00469         for (i=0; i<hor; i++) {   //  horz line
00470             z =  zeichen[bpl * i + ((j & 0xF8) >> 3)+1];
00471             b = 1 << (j & 0x07);
00472             if (( z & b ) != 0x00)  pixel(x+i,y+j,_foreground);
00473             else if (_ifMarge == 0) pixel(x+i,y+j,_background);//  _background  -> _LayerBUF[index];
00474 
00475         }
00476     }
00477     if ((w + 2) < hor) char_x += w + 2;                  // x offset to next char
00478     else               char_x += hor;
00479 }
00480 
00481 /**
00482 * @brief  dispay a oblique typte character by big font. 
00483 * @param[in] int x : horizontal allocation , up-left of text
00484 * @param[in] int y : vertical allocation , bottom-right of text
00485 * @param[in] char c : a charactor.
00486 */
00487 void memLCD8::oblique(int x, int y, int c)
00488 {
00489     unsigned int hor,vert,offset0,offset1,bpl,j,i,b; // T.Okamoto modified, for big font
00490     unsigned int headroffset;// 2018-10-26 added by Y.Saruhashi
00491     unsigned char* zeichen;
00492     unsigned char z,w;
00493     if ((c < 32) || (c > 127)) return;   // test char range
00494 
00495     //for big font
00496     offset0 = font[0];  // bytes / char uppser adress
00497     offset1 = font[1];  // bytes / char lower adress
00498     hor = font[2];      // get hor size of font
00499     vert = font[3];     // get vert size of font
00500     bpl = font[4];      // bytes per line
00501     headroffset = 5;
00502 
00503     int oblique_raio=3;    // 3 = 30(%percentage) /  10
00504     int shift_x = (hor*oblique_raio)/10; //oblique pixel x size, top of char;
00505     int shift_y = vert / shift_x;        //oblique ratio for vertical.  
00506 
00507     if (char_x + hor > _width) {
00508         char_x = 0;
00509         char_y = char_y + vert;
00510         if (char_y >= _height - vert) char_y = 0;
00511     }
00512     
00513     zeichen = &font[(c -32) * (offset0 *256 + offset1) + headroffset];
00514     if( _FixedFontWidth == 0 ) w = zeichen[0];                          // actual width of char
00515     else                       w = _FixedFontWidth;                     // fixed width of char
00516 
00517     for (j=0; j<vert; j++) {  //  vert line
00518         for (i=0; i<hor; i++) {   //  horz line
00519             z =  zeichen[bpl * i + ((j & 0xF8) >> 3)+1];
00520             b = 1 << (j & 0x07);
00521             if (( z & b ) != 0x00)  pixel(x+i+shift_x-(j/shift_y),y+j,_foreground);
00522             else if (_ifMarge == 0) pixel(x+i+shift_x-(j/shift_y),y+j,_background);//  _background  -> _LayerBUF[index];
00523 
00524         }
00525     }
00526     if ((w + 2) < hor) char_x += w + 2;                  // x offset to next char
00527     else               char_x += hor;
00528 }
00529 /**
00530 * @brief  dispay a oblique typte character by big font. 
00531 * @param[in] int x : horizontal allocation , up-left of text
00532 * @param[in] int y : vertical allocation , bottom-right of text
00533 * @param[in] char c : a charactor.
00534 * @param[in] int rx : a horizontal multiple numbler
00535 * @param[in] int ry : a vertical multiple numbler
00536 */
00537 void memLCD8::oblique_multi(int x, int y, int c,int rx,int ry)
00538 {
00539     unsigned int hor,vert,offset0,offset1,bpl,j,i,b; // T.Okamoto modified, for big font
00540     unsigned int headroffset;// 2018-10-26 added by Y.Saruhashi
00541     unsigned char* zeichen;
00542     unsigned char z,w;
00543     int k,l;
00544     
00545     if ((c < 32) || (c > 127)) return;   // test char range
00546 
00547     //for big font
00548     offset0 = font[0];  // bytes / char uppser adress
00549     offset1 = font[1];  // bytes / char lower adress
00550     hor = font[2]-30;      // get hor size of font
00551     vert = font[3];     // get vert size of font
00552     bpl = font[4];      // bytes per line
00553     headroffset = 5;
00554 
00555     int oblique_raio=3;    // 3 = 30(%percentage) /  10
00556     int shift_x = (hor*oblique_raio)/10; //oblique pixel x size, top of char;
00557     int shift_y = vert / shift_x;        //oblique ratio for vertical.  
00558 
00559     if (char_x + hor > _width) {
00560         char_x = 0;
00561         char_y = char_y + vert;
00562         if (char_y >= _height - vert) char_y = 0;
00563     }
00564     
00565     zeichen = &font[(c -32) * (offset0 *256 + offset1) + headroffset];
00566     if( _FixedFontWidth == 0 ) w = zeichen[0];                          // actual width of char
00567     else                       w = _FixedFontWidth;                     // fixed width of char
00568 
00569     for (j=0; j<vert; j++) {  //  vert line
00570         for (i=0; i<hor; i++) {   //  horz line
00571             z =  zeichen[bpl * i + ((j & 0xF8) >> 3)+1];
00572             b = 1 << (j & 0x07);
00573             if (( z & b ) != 0x00){
00574                   //pixel(x+i*rx+shift_x-(j*ry/shift_y)  ,y+j*ry  ,_foreground);
00575                   //pixel(x+i*rx+shift_x-(j*ry/shift_y)+1,y+j*ry  ,_foreground);
00576                   //pixel(x+i*rx+shift_x-(j*ry/shift_y)  ,y+j*ry+1,_foreground);
00577                   //pixel(x+i*rx+shift_x-(j*ry/shift_y)+1,y+j*ry+1,_foreground);
00578                   for(l=0;l<ry;l++)
00579                   {
00580                     for(k=0;k<rx;k++)
00581                     {
00582                       pixel(x+i*rx+shift_x-(j*ry/shift_y)+k  ,y+j*ry+l  ,_foreground);
00583                     }
00584                 }
00585                   
00586             }
00587             else if (_ifMarge == 0){
00588                   pixel(x+i*rx+shift_x-(j*ry/shift_y)  ,y+j*ry  ,_background);
00589                   pixel(x+i*rx+shift_x-(j*ry/shift_y)+1,y+j*ry  ,_background);
00590                   pixel(x+i*rx+shift_x-(j*ry/shift_y)  ,y+j*ry+1,_background);
00591                   pixel(x+i*rx+shift_x-(j*ry/shift_y)+1,y+j*ry+1,_background);
00592             }
00593 
00594         }
00595     }
00596     if ((w + 2) < hor) char_x += w*rx + 2;                  // x offset to next char
00597     else               char_x += hor*rx;
00598 }
00599 
00600 /**
00601 * @brief  dispay the image from symbol data
00602 */
00603 void memLCD8::Symbol(unsigned int x, unsigned int y, unsigned char *symbol)
00604 {
00605     unsigned int hor,vert,bpl,j,i,b;
00606     unsigned char* zeichen;
00607     unsigned char z,w;
00608     hor = symbol[0];                       // get hor size of font
00609     vert = symbol[1];                      // get vert size of font
00610     bpl = symbol[2];                       // bytes per line
00611 
00612     if (char_x + hor > _width) {
00613         char_x = 0;
00614         char_y = char_y + vert;
00615         if (char_y >= _height - symbol[1]) char_y = 0;
00616     }
00617 
00618     zeichen = &symbol[3];
00619     w = zeichen[0];                          // actual width of char
00620     for (j=0; j<vert; j++) {  //  vert line
00621         for (i=0; i<hor; i++) {   //  horz line
00622             z =  zeichen[bpl * i + ((j & 0xF8) >> 3)+1];
00623             b = 1 << (j & 0x07);
00624             if (( z & b ) != 0x00)  pixel(x+i,y+j,_foreground);
00625             else if (_ifMarge == 0) pixel(x+i,y+j,_background);//  _background  -> _LayerBUF[index];
00626         }
00627     }
00628     if ((w + 2) < hor) char_x += w + 2;                  // x offset to next char
00629     else               char_x += hor;
00630 }
00631 
00632 /**
00633 * @brief  dispay a circle line by color data
00634 */
00635 void memLCD8::circle(int x0, int y0, int r, uint8_t color)
00636 {
00637     int x = -r, y = 0, err = 2-2*r, e2;
00638     do {
00639         pixel(x0-x, y0+y,color);
00640         pixel(x0+x, y0+y,color);
00641         pixel(x0+x, y0-y,color);
00642         pixel(x0-x, y0-y,color);
00643         e2 = err;
00644         if (e2 <= y) {
00645             err += ++y*2+1;
00646             if (-x == y && e2 <= x) e2 = 0;
00647         }
00648         if (e2 > x) err += ++x*2+1;
00649     } while (x <= 0);
00650 
00651 }
00652 
00653 /**
00654 * @brief  dispay a filled circle by color data
00655 */
00656 void memLCD8::fillcircle(int x0, int y0, int r, uint8_t color)
00657 {
00658     int x = -r, y = 0, err = 2-2*r, e2;
00659     do {
00660         vline(x0-x, y0-y, y0+y, color);
00661         vline(x0+x, y0-y, y0+y, color);
00662         e2 = err;
00663         if (e2 <= y) {
00664             err += ++y*2+1;
00665             if (-x == y && e2 <= x) e2 = 0;
00666         }
00667         if (e2 > x) err += ++x*2+1;
00668     } while (x <= 0);
00669 }
00670 
00671 /**
00672 * @brief  dispay a horizontal line by color data
00673 */
00674 void memLCD8::hline(int x0, int x1, int y, uint8_t color)
00675 {
00676     int w;
00677     w = x1 - x0 + 1;
00678     for (int j=0; j<w; j++) pixel(x0+j, y,color);
00679 }
00680 /**
00681 * @brief  dispay a vertical line by color data
00682 */
00683 void memLCD8::vline(int x, int y0, int y1, uint8_t color)
00684 {
00685     int h;
00686     h = y1 - y0 + 1;
00687     for (int j=0; j<h; j++) pixel(x, y0+j,color);
00688 }
00689 
00690 /**
00691 * @brief  dispay a line by color data
00692 */
00693 void memLCD8::line(int x0, int y0, int x1, int y1, uint8_t color)
00694 {
00695     int   dx = 0, dy = 0;
00696     int   dx_sym = 0, dy_sym = 0;
00697     int   dx_x2 = 0, dy_x2 = 0;
00698     int   di = 0;
00699 
00700     dx = x1-x0;
00701     dy = y1-y0;
00702 
00703     if (dx == 0) {        // vertical line
00704         if (y1 > y0) vline(x0,y0,y1,color);
00705         else vline(x0,y1,y0,color);
00706         return;
00707     }
00708 
00709     if (dx > 0) {
00710         dx_sym = 1;
00711     } else {
00712         dx_sym = -1;
00713     }
00714     if (dy == 0) {        // horizontal line
00715         if (x1 > x0) hline(x0,x1,y0,color);
00716         else  hline(x1,x0,y0,color);
00717         return;
00718     }
00719 
00720     if (dy > 0) {
00721         dy_sym = 1;
00722     } else {
00723         dy_sym = -1;
00724     }
00725 
00726     dx = dx_sym*dx;
00727     dy = dy_sym*dy;
00728 
00729     dx_x2 = dx*2;
00730     dy_x2 = dy*2;
00731 
00732     if (dx >= dy) {
00733         di = dy_x2 - dx;
00734         while (x0 != x1) {
00735 
00736             pixel(x0, y0, color);
00737             x0 += dx_sym;
00738             if (di<0) {
00739                 di += dy_x2;
00740             } else {
00741                 di += dy_x2 - dx_x2;
00742                 y0 += dy_sym;
00743             }
00744         }
00745         pixel(x0, y0, color);
00746     } else {
00747         di = dx_x2 - dy;
00748         while (y0 != y1) {
00749             pixel(x0, y0, color);
00750             y0 += dy_sym;
00751             if (di < 0) {
00752                 di += dx_x2;
00753             } else {
00754                 di += dx_x2 - dy_x2;
00755                 x0 += dx_sym;
00756             }
00757         }
00758         pixel(x0, y0, color);
00759     }
00760     return;
00761 }
00762 /**
00763 * @brief  dispay a rectangle line by color data
00764 */
00765 void memLCD8::rect(int x0, int y0, int x1, int y1, uint8_t color)
00766 {
00767 
00768     if (x1 > x0) hline(x0,x1,y0,color);
00769     else  hline(x1,x0,y0,color);
00770 
00771     if (y1 > y0) vline(x0,y0,y1,color);
00772     else vline(x0,y1,y0,color);
00773 
00774     if (x1 > x0) hline(x0,x1,y1,color);
00775     else  hline(x1,x0,y1,color);
00776 
00777     if (y1 > y0) vline(x1,y0,y1,color);
00778     else vline(x1,y1,y0,color);
00779 
00780     return;
00781 }
00782 /**
00783 * @brief  dispay a filled rectangle by color data
00784 */
00785 void memLCD8::fillrect(int x0, int y0, int x1, int y1, uint8_t color)
00786 {
00787     int h = y1 - y0 + 1;
00788     for (int i=0; i<h; i++) hline(x0, x1, y0+i, color);
00789 }
00790 /**
00791 * @brief  Transfer One Pixel Data with x,y allocation
00792 * @param[in] int x : horizontal allocation left to right
00793 * @param[in] int y : vertival allocation top to bottom
00794 * @param[in] uint8_t color : the color data for Drawing  0x0X  x is color data(RGBC) C is not used
00795 */
00796 void memLCD8::pixel(int x, int y, uint8_t color)
00797 {
00798     if(!(x % 2)) _dispBUF[y*_width/2+x/2] =  _dispBUF[y*_width/2+x/2]&0x0F  |  (color << 4)&0xF0 ;   //MASK 0000 1111
00799     else         _dispBUF[y*_width/2+x/2] =  _dispBUF[y*_width/2+x/2]&0xF0  |  (color     )&0x0F ;   //MASK 1111 0000
00800 }
00801 
00802 /**
00803 * @brief  Get Edited data for SPI transfer
00804 * @param[in] int x : horizontal allocation left to right
00805 * @param[in] int y : vertival allocation top to bottom
00806 * @param[in] uint8_t* buff : buffer data for Display
00807 */
00808 int* memLCD8::GetPixelValue(int _x, int _y ,uint8_t* buff)
00809 {
00810     //bitmap data = 4bit data => modify transfer data bit size;
00811     switch(TrModeCommand)
00812     {
00813     case 0x90: //TrBIT4:
00814         // buffer 2pixel/1byte => 2pixel/1byte  buffe 2byte毎進める。
00815         TrValue[0] = buff[_y* _width/2 + _x];
00816         break;
00817     case 0x80://TrBIT3:
00818         // buffer 2pixel/1byte => 3pixel-1subpixel/1bye (24 pixel/3byte) buffer 3byte毎進める。
00819         for(int j=0;j<3;j++) TrValue[j] = 0;
00820         //for( int i = 0 ; i<12 ; i--)
00821         {
00822             //4 bit RGBN(Nは予備) => 3bit RGB
00823             if( _width/2 > _x )
00824             {
00825                 TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x    ]&0xE0) ) );
00826                 TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x    ]&0x0E) ) << 1);
00827             }
00828             if( _width/2 > _x + 1 )
00829             {
00830                 TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x + 1]&0xC0) ) >> 6);
00831 
00832                 TrValue[1] = TrValue[1] | ( ( (buff[_y* _width/2 + _x + 1]&0x20) ) << 2);
00833                 TrValue[1] = TrValue[1] | ( ( (buff[_y* _width/2 + _x + 1]&0x0E) ) << 3);
00834             }
00835             if( _width/2 > _x + 2 )
00836             {
00837                 TrValue[1] = TrValue[1] | ( ( (buff[_y* _width/2 + _x + 2]&0xE0) ) >> 4);
00838                 TrValue[1] = TrValue[1] | ( ( (buff[_y* _width/2 + _x + 2]&0x08) ) >> 3);
00839 
00840                 TrValue[2] = TrValue[2] | ( ( (buff[_y* _width/2 + _x + 2]&0x06) ) << 5);
00841             }
00842             if( _width/2 > _x + 3 )
00843             {
00844                 TrValue[2] = TrValue[2] | ( ( (buff[_y* _width/2 + _x + 3]&0xE0) ) >> 2);
00845                 TrValue[2] = TrValue[2] | ( ( (buff[_y* _width/2 + _x + 3]&0x0E) ) >> 1);
00846             }    
00847         }
00848         break;
00849     case 0x88://TrBIT1:
00850         // buffer 2pixel/1byte => 8 pixel/1byte  buffe 4byte毎進める。
00851         for(int j=0;j<3;j++) TrValue[j] = 0;
00852         for(int i = 0 ; i<4 ; i++)
00853         {
00854             //Green bit => monochrome bit
00855             if( _width/2 > _x + i )
00856             {
00857                 TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x + i]&0x40) == 0 ? 0 : 1 ) << (7-i*2)   );
00858                 TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x + i]&0x04) == 0 ? 0 : 1 ) << (7-i*2)-1 );
00859                 //pc2.printf("[%d+%d][%d]<0x%x>\n",_x,i,_y,_dispBUF[_y* _width/2 + _x + i]);
00860             }
00861         }
00862         break;
00863     }
00864     return TrValue;   
00865 }
00866 
00867 /**
00868 * @brief  Transfer Pixel Data from buffer to Display
00869 * @param[in] int transfermode : instruction the transfer data size ,4bit,3bit,1bit
00870 */
00871 void memLCD8::writeDISP(int transfermode)    // refresh whole display
00872 {
00873     char pol = 0;
00874     //char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW  A  1010
00875     SetTransfermode(transfermode);
00876     
00877     // frame
00878     for (int i=0; i<_height; i++) {
00879         // line
00880         wait_us(6);
00881         _cs  = 1;
00882         wait_us(6);
00883         _spi.write(TrModeCommand | (pol << 6) | (i+1)>>8 ); // COMMAND
00884         //pc2.printf("com 0x%x\n",TrModeCommand | (pol << 6) | (i+1)>>8);
00885         
00886         _spi.write((i+1)& 0x00FF ); // V ADDR
00887         //pc2.printf("v adr 0x%x\n",(i+1)& 0x00FF);
00888         
00889         for(int j=0; j<_width; j+=TrAdd)
00890         {
00891             GetPixelValue(j,i,_dispBUF);
00892             //pc2.printf("data=[%d]{%d][%d]/[%d]\n",j*TrAdd,i,TrValue[0],TrAdd);
00893             for(int k=0;k<TrValNum;k++)
00894                 _spi.write(TrValue[k]);
00895         }
00896         _spi.write(0x00); // DUMMY transfer
00897         _spi.write(0x00); // DUMMY transfer
00898 //        wait_ms(1);      //1.8Hz simulation
00899 //        wait_ms(2);      //1.35Hz simulation
00900         wait_us(6);
00901         _cs  = 0;
00902         if(pol) pol=0x00;
00903         else    pol=0x01;
00904     }
00905 }
00906 
00907 /**
00908 * @brief  Transfer Pixel Data  : from Start line number to Display of frame buffer
00909 * @param[in] int startline : Start line number to Display
00910 * @param[in] int endline : end line number to Display
00911 * @param[in] int transfermode : instruction the transfer data size ,4bit,3bit,1bit
00912 */
00913 void memLCD8::writeDISP(int startline , int endline , int transfermode)    // refresh display selected line
00914 {
00915     char pol = 0;
00916     //char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW  A  1010
00917     SetTransfermode(transfermode);
00918     
00919     // frame
00920     for (int i=startline; i<=endline; i++) {
00921         if( i >= _height ) continue;
00922         if( i <0   ) continue;
00923         
00924         // line
00925         wait_us(6);
00926         _cs  = 1;
00927         wait_us(6);
00928         _spi.write(TrModeCommand | (pol << 6) | (i+1)>>8 ); // COMMAND
00929         //pc2.printf("com 0x%x\n",TrModeCommand | (pol << 6) | (i+1)>>8);
00930         
00931         _spi.write((i+1)& 0x00FF ); // V ADDR
00932         //pc2.printf("v adr 0x%x\n",(i+1)& 0x00FF);
00933         
00934         for(int j=0; j<_width; j+=TrAdd)
00935         //for(int j=0; j<100; j+=TrAdd)
00936         {
00937             GetPixelValue(j,i,_dispBUF);
00938             //pc2.printf("data=[%d]{%d][%d]/[%d]\n",j*TrAdd,i,TrValue[0],TrAdd);
00939             for(int k=0;k<TrValNum;k++)
00940                 _spi.write(TrValue[k]);
00941         }
00942         _spi.write(0x00); // DUMMY transfer
00943         _spi.write(0x00); // DUMMY transfer
00944 //        wait_ms(1);      //1.8Hz simulation
00945 //        wait_ms(2);      //1.35Hz simulation
00946         wait_us(6);
00947         _cs  = 0;
00948         if(pol) pol=0x00;
00949         else    pol=0x01;
00950     }
00951 }
00952 
00953 /**
00954 * @brief  Transfer Pixel Data from frame buffer to Display
00955 */
00956 void memLCD8::writeDISP(void)    // refresh whole display
00957 {
00958 
00959     char pol = 0;
00960     char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW  A  1010
00961 
00962     // frame
00963     for (int i=0; i<_height; i++) {
00964         // line
00965         wait_us(6);
00966         _cs  = 1;
00967         wait_us(6);
00968         _spi.write(command | (pol << 6) | (i+1)>>8 ); // COMMAND
00969         _spi.write((i+1)& 0x00FF ); // V ADDR
00970         for(int j=0; j<_width/2; j++) _spi.write(_dispBUF[i*_width/2 + j]);
00971         _spi.write(0x00); // DUMMY transfer
00972         _spi.write(0x00); // DUMMY transfer
00973         wait_us(6);
00974         _cs  = 0;
00975         if(pol) pol=0x00;
00976         else    pol=0x01;
00977     }
00978 }
00979 
00980 /**
00981 * @brief  clear buffer data by background color data
00982 */
00983 void memLCD8::clsBUF(void)
00984 {
00985 
00986     for (int i=0; i<_height; i++) {
00987         for (int j=0; j<_width; j++) {
00988             pixel(j,i,_background);
00989         }
00990     }
00991 }
00992 #if MOVIEBUFF_MODE
00993 /**
00994 * @brief  Transfer One Pixel Data with x,y allocation to Animation buffer
00995 * @param[in] int x : horizontal allocation left to right
00996 * @param[in] int y : vertival allocation top to bottom
00997 * @param[in] uint8_t color : the color data for Drawing  0x0X  x is color data(RGBC) C is not used
00998 * @param[in] int memnu : animation buffer number.
00999 */
01000 void memLCD8::movie_pixel(int x, int y, uint8_t color,int memnum)
01001 {
01002     //pc2.printf("movie_pixel[%d][%d]col[%d]\n",x,y,color);
01003     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
01004     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
01005 }
01006 
01007 /**
01008 * @brief  Transfer Pixel Data of Animation buffer with x,y allocation to frame buffer.
01009 * @param[in] int sx : horizontal start allocation left to right
01010 * @param[in] int sy : vertival start allocation top to bottom
01011 * @param[in] int memnu : animation buffer number.
01012 */
01013 void memLCD8::makeMovieFrame(int sx , int sy, int memnum)
01014 {
01015     int x,y;
01016     //pc2.printf("1<%d,%d>\n",_width,_height);
01017     for(y = 0; y < MOVIE_VERT_SIZE;y++)
01018     {
01019         for(x = 0; x < MOVIE_HORI_SIZE ;x+=2)
01020         {
01021                 if( (sx + x) >= _width ) continue;
01022                 if( (sx + x) < 0 ) continue;
01023                 if( (sy + y) >= _height ) continue;
01024                 if( (sy + y) < 0 ) continue;
01025                 
01026                 _dispBACKUPBUF[y*MOVIE_HORI_SIZE/2+x/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2];
01027 
01028                 if( (_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]&0xF0) != 0 )
01029                     _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
01030 
01031                 if( (_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]&0x0F) != 0 )
01032                     _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
01033         
01034             //pc2.printf("dispMOVIEBUF[%d][%d] = %d\n",x,y,_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]);
01035            //_dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2];
01036         }
01037     }
01038     //pc2.printf("memnum=%d,x=%d,y=%d>sx=%d,sy=%d\n",memnum,sx,sy,(sx+x)-1,(sy+y)-1);
01039 
01040 }
01041 /**
01042 * @brief  Transfer Pixel Data of Animation buffer with x,y allocation to frame buffer.  animation data read right to left.
01043 * @param[in] int sx : horizontal start allocation left to right
01044 * @param[in] int sy : vertival start allocation top to bottom
01045 * @param[in] int memnu : animation buffer number.
01046 */
01047 void memLCD8::makeMovieFrame_Reverse(int sx , int sy, int memnum)
01048 {
01049     int x,y;
01050     //pc2.printf("1<%d,%d>\n",_width,_height);
01051     for(y = 0; y < MOVIE_VERT_SIZE ;y++)
01052     {
01053         for(x = 0; x < MOVIE_HORI_SIZE  ;x+=2)
01054         {
01055                 if( (sx + x) >= _width ) continue;
01056                 if( (sx + x) < 0 ) continue;
01057                 if( (sy + y) >= _height ) continue;
01058                 if( (sy + y) < 0 ) continue;
01059                 
01060                 _dispBACKUPBUF[y*MOVIE_HORI_SIZE/2+x/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2];
01061 
01062                 if( (_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+(MOVIE_HORI_SIZE-2-x)/2]&0xF0) != 0 )
01063                     _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
01064 
01065                 if( (_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+(MOVIE_HORI_SIZE-2-x)/2]&0x0F) != 0 )
01066                     _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
01067         
01068             //pc2.printf("dispMOVIEBUF[%d][%d] = %d\n",x,y,_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]);
01069            //_dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2];
01070         }
01071     }
01072     //pc2.printf("memnum=%d,x=%d,y=%d>sx=%d,sy=%d\n",memnum,sx,sy,(sx+x)-1,(sy+y)-1);
01073 
01074 }
01075 /**
01076 * @brief  Transfer Pixel Data of Animation buffer with x,y allocation to frame buffer.  animation data bottom to top.
01077 * @param[in] int sx : horizontal start allocation left to right
01078 * @param[in] int sy : vertival start allocation top to bottom
01079 * @param[in] int memnu : animation buffer number.
01080 */
01081 void memLCD8::makeMovieFrame_Updown(int sx , int sy, int memnum)
01082 {
01083     int x,y;
01084     //pc2.printf("1<%d,%d>\n",_width,_height);
01085     for(y = 0; y < MOVIE_VERT_SIZE ;y++)
01086     {
01087         for(x = 0; x < MOVIE_HORI_SIZE  ;x+=2)
01088         {
01089                 if( (sx + x) >= _width ) continue;
01090                 if( (sx + x) < 0 ) continue;
01091                 if( (sy + y) >= _height ) continue;
01092                 if( (sy + y) < 0 ) continue;
01093                 
01094                 _dispBACKUPBUF[y*MOVIE_HORI_SIZE/2+x/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2];
01095 
01096                 if( (_dispMOVIEBUF[memnum][(MOVIE_VERT_SIZE-1-y)*MOVIE_HORI_SIZE/2+x/2]&0xF0) != 0 )
01097                     _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
01098 
01099                 if( (_dispMOVIEBUF[memnum][(MOVIE_VERT_SIZE-1-y)*MOVIE_HORI_SIZE/2+x/2]&0x0F) != 0 )
01100                     _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
01101         
01102             //pc2.printf("dispMOVIEBUF[%d][%d] = %d\n",x,y,_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]);
01103            //_dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2];
01104         }
01105     }
01106     //pc2.printf("memnum=%d,x=%d,y=%d>sx=%d,sy=%d\n",memnum,sx,sy,(sx+x)-1,(sy+y)-1);
01107 
01108 }
01109 /**
01110 * @brief  Transfer  Pixel Data of backuped original frame buffer with x,y allocation to frame buffer.
01111 * @param[in] int sx : horizontal start allocation left to right
01112 * @param[in] int sy : vertival start allocation top to bottom
01113 * @param[in] int memnu : animation buffer number.
01114 */
01115 void memLCD8::RestoreMovieFrame(int sx , int sy, int memnum)
01116 {
01117     int x,y;
01118     //pc2.printf("1<%d,%d>\n",_width,_height);
01119     for(y = 0; y < MOVIE_VERT_SIZE;y++)
01120     {
01121         for(x = 0; x < MOVIE_HORI_SIZE ;x++)
01122         {
01123            if( (sx + x) >= _width ) continue;
01124            if( (sx + x) < 0 ) continue;
01125            if( (sy + y) >= _height ) continue;
01126            if( (sy + y) < 0 ) continue;
01127            _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]=_dispBACKUPBUF[y*MOVIE_HORI_SIZE/2+x/2];
01128         }
01129     }
01130     //pc2.printf("memnum=%d,x=%d,y=%d>sx=%d,sy=%d\n",memnum,sx,sy,(sx+x)-1,(sy+y)-1);
01131 
01132 }
01133 //end MOVIEBUFF_MODE
01134 #endif
01135 //end FRAMEBUFF_MODE
01136 #endif
01137