JapanDisplayInc / MIP8F_SPI_Ver40

Dependents:   MIP8f_FRDM_LineBuffer_sample

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MIP8F_SPI.h Source File

MIP8F_SPI.h

Go to the documentation of this file.
00001 /**
00002 * @file MIP8F_SPI.h
00003 * @brief ver4.0 Library header file: Class for JDI MIP8 display
00004 * @details  
00005 * Ver4.0 Addtional function is Line buffer version
00006 * Ver3.0 Addtional function is font display
00007 * ver2.0 Addtional function is Monochome display by 1bit mode of SPI transfer.
00008 *
00009 * <license>
00010 * Copyright 2018 Japan Display Inc.
00011 * Licensed under the Apache License, Version 2.0 (the "License");
00012 * you may not use this file except in compliance with the License.
00013 * You may obtain a copy of the License at
00014 *     http://www.apache.org/licenses/LICENSE-2.0
00015 * Unless required by applicable law or agreed to in writing, software
00016 * distributed under the License is distributed on an "AS IS" BASIS,
00017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00018 * See the License for the specific language governing permissions and
00019 * limitations under the License.
00020 */
00021 
00022 #include "mbed.h"
00023 /*****************************************
00024 * Select compile option
00025 ******************************************/
00026 /**
00027 * @def LINEBUFF_MODE 0
00028 * @brief If you will use a Line Buffer mode,you must define LINEBUFF_MODE 1
00029 */
00030 #define LINEBUFF_MODE 1
00031 /**
00032 * @def FRAMEBUFF_MODE 1
00033 * @brief If you will use a Frame Buffer mode,you must define LINEBUFF_MODE 1
00034 */
00035 #define FRAMEBUFF_MODE 0
00036 /*****************************************
00037 ******************************************/
00038 #if LINEBUFF_MODE
00039     //  1dot = 4bit
00040     #define LINE_SIZE  320  // 640 / 2
00041 #endif
00042 #if FRAMEBUFF_MODE
00043     //#define FRAME_SIZE 9328  //1flame = 212dot X 88dot  1dot = 4bit
00044     #define FRAME_SIZE  153600  //  153600 640 x 480        103600  400dot x 200dot    1dot = 4bit
00045 #endif
00046 
00047 // RGB color definitions       /*  R, G, B  */
00048 #define Black           0x00    /*  0  0  0  */
00049 #define Blue            0x02    /*  0  0  1  */
00050 #define Green           0x04    /*  0  1  0  */
00051 #define Cyan            0x06    /*  0  1  1  */
00052 #define Red             0x08    /*  1  0  0  */
00053 #define Magenta         0x0a    /*  1  0  1  */ 
00054 #define Yellow          0x0c    /*  1  1  0  */
00055 #define White           0x0e    /*  1  1  1  */
00056 
00057 //transfer mode
00058 #define TrBIT4    0x00
00059 #define TrBIT3    0x01
00060 #define TrBIT1    0x02
00061     
00062 #define RGB8(r,g,b)   (((r & 0x80) >>4) | ((g & 0x80)>>5) | ((b & 0x80)>>6) ) & 0x0E  //24bit->4bit ??6bit(8bit)?? MIP  MASK 0000 1110??
00063 
00064 /**
00065 * @brief display class for JDI MIP8(memory in pixel 8 color display)
00066 * @details spi-transfer has 3 mode. 
00067 * 4bit mode is color display, this bit arrange is  R,G,B,x.   R,G,B = R,G,B subpixel bit.  a x bit is Dummy.
00068 * No ues(3bit mode is color display, this bit arrange is  R,G,B.   R,G,B = R,G,B subpixel bit.  No bit is Dummy.)
00069 * 1bit mode is monocrome display,high speed refresh mode. a only Green subpixel of bitmap data is transfered.
00070 */ 
00071 class memLCD8 : public Stream {
00072 public:
00073 
00074     unsigned char* font;
00075 
00076     /**
00077     * @brief Constructor : Set MPU pin names
00078     */
00079     memLCD8(PinName mosi,PinName miso,PinName sclk,PinName cs,PinName disp,PinName power); 
00080     void  locate(int x, int y);
00081     void set_font(unsigned char* f);
00082     void setWH(int width, int height);
00083     void SwDisp(bool ONorOFF);
00084     void foreground(uint8_t colour);
00085     void background(uint8_t colour);
00086     void command(char command);
00087     //ver2.0
00088     void SetTransfermode(int transfermode);
00089   
00090     //ver3.0
00091     void set_FixedFontWidth( unsigned char width );
00092     void set_ActualFontWidth(void);
00093     unsigned char get_Background(void);
00094 
00095 #if LINEBUFF_MODE
00096     //ver3.0
00097     void  pixel(int x, uint8_t color);
00098     void  clsLINEBUF(void);
00099     int*  GetPixelValueFromLineBuffer(int _x,uint8_t* buff);
00100     void  writeDISPLinebuffer(void);
00101     void  writeDISP(int line,int transfermode);
00102 #endif
00103 
00104 #if FRAMEBUFF_MODE
00105     void  pixel(int x, int y, uint8_t color);
00106     void  writeDISP(void);
00107     void  writeDISP(int transfermode);// transfermode : 4bit,3bit,1bit
00108     void  writeDISP(int startline , int endline , int transfermode);// refresh display selected line
00109     void  clsBUF(void);
00110     void setmarge(bool ifMarge);
00111     void character(int x, int y, int c);
00112     void circle(int x0, int y0, int r, uint8_t color);
00113     void fillcircle(int x0, int y0, int r, uint8_t color);
00114     void hline(int x0, int x1, int y, uint8_t color);
00115     void vline(int x, int y0, int y1, uint8_t color);
00116     void line(int x0, int y0, int x1, int y1, uint8_t color);
00117     void rect(int x0, int y0, int x1, int y1, uint8_t color);
00118     void fillrect(int x0, int y0, int x1, int y1, uint8_t color);
00119     void Symbol(unsigned int x, unsigned int y, unsigned char *symbol);
00120     //ver2.0
00121     int* GetPixelValue(int x , int y , uint8_t* buff);
00122     //ver3.0
00123     int  textout(int x,int y,char* text);
00124     void oblique(int x, int y, int c);
00125     int  obliqueout(int x,int y,char* text);
00126 #endif
00127 
00128 protected:
00129     virtual int _putc(int value);
00130     virtual int _getc();
00131 
00132     //! SPI class
00133     SPI _spi;
00134     //! pin class , SPI line 
00135     DigitalOut _cs;
00136     //! display on/off
00137     DigitalOut _disp;
00138     //! diplay power on/off
00139     DigitalOut _power;
00140         
00141     //! foreground color of display
00142     char _foreground;
00143     //! background color of display
00144     char _background;
00145     bool _ifMarge;
00146     char _if16;
00147 
00148     //ver3.0
00149     //! Fixed Font width size  if _FixedFontWidth==0, use actual Font width size.
00150     unsigned char _FixedFontWidth;
00151     
00152 #if FRAMEBUFF_MODE
00153     //! frame buffer for display
00154     uint8_t _dispBUF[FRAME_SIZE];
00155     //uint8_t _LayerBUF[FRAME_SIZE];
00156 #endif
00157 #if LINEBUFF_MODE
00158     //uint8_t *_pLineBuf;
00159     //! line buffer for display
00160     uint8_t _dispLINEBUF[LINE_SIZE];
00161 #endif
00162 
00163     //! height,diplay pixel size 
00164     int _height;
00165     //! width,diplay pixel size 
00166     int _width;
00167     unsigned int char_x;
00168     unsigned int char_y;
00169     
00170     //ver2.0
00171     //! SPI transfer mode command to MIP8 diplay
00172     char TrModeCommand;
00173     int TrAdd;
00174     int TrValue[3];
00175     int TrValNum;
00176 };