for CountupNumber_sample3
MIP8F_SPI_Ver7.0
Ver7.0 Addtional function is SpeedMeter Sample for 4.4" MIP8F Display (Japan Display Inc)
Revision 3:c67b96404016, committed 2018-11-06
- Comitter:
- JDI_Mbed_Team
- Date:
- Tue Nov 06 02:16:10 2018 +0000
- Parent:
- 2:944f2968c19f
- Child:
- 4:c41da26fe04a
- Commit message:
- Ver40 Line buffer mode
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 |
--- a/MIP8F_SPI.cpp Wed Oct 31 02:05:47 2018 +0000
+++ b/MIP8F_SPI.cpp Tue Nov 06 02:16:10 2018 +0000
@@ -1,7 +1,12 @@
/**
* @file MIP8F_SPI.cpp
-* @brief ver3.0 Library source code file: Class for JDI MIP8 display
+* @brief ver4.0 Library source code file: Class for JDI MIP8 display
* @details
+* Ver4.0 Addtional function is Line buffer version
+* Ver3.0 Addtional function is font display
+* ver2.0 Addtional function is Monochome display by 1bit mode of SPI transfer.
+*
+* <license>
* Copyright 2018 Japan Display Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,64 +44,10 @@
command(0x02); // All crear mode
_cs = 0;
*/
-
_FixedFontWidth=0;//setting:actual font width display if _FixedFontWidth !=1: font fixed witdh
}
/**
-* @brief putc
-*/
-int memLCD8::_putc(int value)
-{
- if (value == '\n') { // new line
- char_x = 0;
- char_y = char_y + font[3];
- if (char_y >= _height - font[3]) {
- char_y = 0;
- }
- } else {
- character(char_x, char_y, value);
- }
- return value;
-}
-
-int memLCD8::textout(int x,int y,char* text)
-{
- int i=0;
- char_x = x;
- char_y = y;
-
- while(text[i] != 0x00 )
- {
- character(char_x, char_y, text[i]);
- i++;
- }
- return text[i];
-}
-
-int memLCD8::obliqueout(int x,int y,char* text)
-{
- int i=0;
- char_x = x;
- char_y = y;
-
- while(text[i] != 0x00 )
- {
- oblique(char_x, char_y, text[i]);
- i++;
- }
- return text[i];
-}
-
-/**
-* @brief getc
-*/
-int memLCD8::_getc()
-{
- return -1;
-}
-
-/**
* @brief set font name
*/
void memLCD8::set_font(unsigned char* f)
@@ -114,19 +65,341 @@
}
/**
-* @brief fixed width between charactor and charctor for font display
+* @brief setting fixed width between charactor and charctor for font display
*/
void memLCD8::set_FixedFontWidth( unsigned char width )
{
_FixedFontWidth = width;
}
+/**
+* @brief setting Actual width between charactor and charctor for font display
+*/
void memLCD8::set_ActualFontWidth(void)
{
_FixedFontWidth = 0;
}
+
/**
-* @brief dispay character by bog font.
-* big font is that "char data" byte size is over 0xff.
+* @brief set Configuration for transfer mode
+* @param[in] int transfermode : instruction the transfer data size ,4bit,3bit,1bit and some parameter
+*/
+void memLCD8::SetTransfermode(int transfermode)
+{
+ switch(transfermode)
+ {
+ case TrBIT4:
+ TrModeCommand = 0x90;
+ TrAdd = 1;
+ TrValNum = 1;
+ break;
+ case TrBIT3:
+ TrModeCommand = 0x80;
+ TrAdd = 4;
+ TrValNum = 3;
+ break;
+ case TrBIT1:
+ TrModeCommand = 0x88;
+ TrAdd = 4;
+ TrValNum = 1;
+ break;
+ }
+}
+
+/**
+* @brief set a display size ,width ,height
+*/
+void memLCD8::setWH(int width, int height)
+{
+ _width = width;
+ _height = height;
+}
+
+/**
+* @brief set color data of foreground
+*/
+void memLCD8::foreground(uint8_t colour)
+{
+ _foreground = colour;
+}
+
+/**
+* @brief set color data of background
+*/
+void memLCD8::background(uint8_t colour)
+{
+ _background = colour;
+}
+
+/**
+* @brief set the Diaplay On/Off data
+*/
+void memLCD8::SwDisp(bool ONorOFF)
+{
+ _disp= ONorOFF;
+}
+
+/**
+* @brief transfer a command code to the display by SPI
+*/
+void memLCD8::command(char command)
+{
+ wait_us(6);
+ _cs = 1;
+ wait_us(6);
+ _spi.write(command);//
+ _spi.write(0x00);// dummy
+ wait_us(6);
+ _cs = 0;
+}
+
+/**
+* @brief putc
+*/
+int memLCD8::_putc(int value)
+{
+ if (value == '\n') { // new line
+ char_x = 0;
+ char_y = char_y + font[3];
+ if (char_y >= _height - font[3]) {
+ char_y = 0;
+ }
+ }
+#if FRAMEBUFF_MODE
+ else {
+ character(char_x, char_y, value);
+ }
+#endif
+ return value;
+}
+
+/**
+* @brief getc
+*/
+int memLCD8::_getc()
+{
+ return -1;
+}
+/**
+* @brief get color data of background
+*/
+unsigned char memLCD8::get_Background(void)
+{
+ return _background;
+}
+/*
+void memLCD8::setmarge(bool ifMarge)
+{
+ _ifMarge = ifMarge;
+}
+*/
+//////////////////////////////////////////////////////////////////////////////
+// line buffer mode
+//////////////////////////////////////////////////////////////////////////////
+#if LINEBUFF_MODE
+/**
+* @brief Transfer One Pixel Data with x,y allocation Line buffer mode
+* @param[in] int x : horizontal allocation left to right
+* @param[in] uint8_t color : the color data for Drawing 0x0X x is color data(RGBC) C is not used
+*/
+void memLCD8::pixel(int x, uint8_t color)
+{
+ if(!(x % 2)) _dispLINEBUF[x/2] = _dispLINEBUF[x/2]&0x0F | (color << 4)&0xF0 ; //MASK 0000 1111
+ else _dispLINEBUF[x/2] = _dispLINEBUF[x/2]&0xF0 | (color )&0x0F ; //MASK 1111 0000
+}
+
+/**
+* @brief Transfer Pixel Data from same Line buffer to Display
+*/
+void memLCD8::writeDISPLinebuffer(void) // refresh whole display
+{
+
+ char pol = 0;
+ char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW A 1010
+
+ // frame
+ for (int i=0; i<_height; i++) {
+ // line
+ wait_us(6);
+ _cs = 1;
+ wait_us(6);
+ _spi.write(command | (pol << 6) | (i+1)>>8 ); // COMMAND
+ _spi.write((i+1)& 0x00FF ); // V ADDR
+ for(int j=0; j<_width/2; j++) _spi.write(_dispLINEBUF[j]);
+ _spi.write(0x00); // DUMMY transfer
+ _spi.write(0x00); // DUMMY transfer
+ wait_us(6);
+ _cs = 0;
+ if(pol) pol=0x00;
+ else pol=0x01;
+ }
+}
+
+/**
+* @brief Transfer Pixel Data from line buffer to Display
+* @param[in] int line : set line number for display.
+* @param[in] int transfermode : instruction the transfer data size ,4bit,3bit,1bit
+*/
+void memLCD8::writeDISP(int line,int transfermode) // refresh gate line display
+{
+
+ char pol = 0;
+ //char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW A 1010
+ SetTransfermode(transfermode);
+
+ // frame
+ // line
+ wait_us(6);
+ _cs = 1;
+ wait_us(6);
+ _spi.write(TrModeCommand | (pol << 6) | (line+1)>>8 ); // COMMAND
+ //pc2.printf("com 0x%x\n",TrModeCommand | (pol << 6) | (i+1)>>8);
+
+ _spi.write((line+1)& 0x00FF ); // V ADDR
+ //pc2.printf("v adr 0x%x\n",(i+1)& 0x00FF);
+
+ for(int j=0; j<_width; j+=TrAdd)
+ {
+ GetPixelValueFromLineBuffer(j,_dispLINEBUF);
+ //pc2.printf("data=[%d]{%d][%d]/[%d]\n",j*TrAdd,i,TrValue[0],TrAdd);
+ for(int k=0;k<TrValNum;k++)
+ _spi.write(TrValue[k]);
+ }
+ _spi.write(0x00); // DUMMY transfer
+ _spi.write(0x00); // DUMMY transfer
+// wait_ms(1); //1.8Hz simulation
+// wait_ms(2); //1.35Hz simulation
+ wait_us(6);
+ _cs = 0;
+ if(pol) pol=0x00;
+ else pol=0x01;
+
+}
+
+/**
+* @brief Get Edited data for SPI transfer from line buffer
+* @param[in] int x : horizontal allocation left to right
+* @param[in] uint8_t* buff : buffer data for Display
+*/
+int* memLCD8::GetPixelValueFromLineBuffer(int _x,uint8_t* buff)
+{
+ //bitmap data = 4bit data => modify transfer data bit size;
+ switch(TrModeCommand)
+ {
+ case 0x90: //TrBIT4:
+ // buffer 2pixel/1byte => 2pixel/1byte buffe 2byte毎進める。
+ TrValue[0] = _dispLINEBUF[_x];
+ break;
+ case 0x80://TrBIT3:
+ // buffer 2pixel/1byte => 3pixel-1subpixel/1bye (24 pixel/3byte) buffer 3byte毎進める。
+ for(int j=0;j<3;j++) TrValue[j] = 0;
+ //for( int i = 0 ; i<12 ; i--)
+ {
+ //4 bit RGBN(Nは予備) => 3bit RGB
+ if( _width/2 > _x )
+ {
+ TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_x ]&0xE0) ) );
+ TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_x ]&0x0E) ) << 1);
+ }
+ if( _width/2 > _x + 1 )
+ {
+ TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_x + 1]&0xC0) ) >> 6);
+
+ TrValue[1] = TrValue[1] | ( ( (_dispLINEBUF[_x + 1]&0x20) ) << 2);
+ TrValue[1] = TrValue[1] | ( ( (_dispLINEBUF[_x + 1]&0x0E) ) << 3);
+ }
+ if( _width/2 > _x + 2 )
+ {
+ TrValue[1] = TrValue[1] | ( ( (_dispLINEBUF[ _x + 2]&0xE0) ) >> 4);
+ TrValue[1] = TrValue[1] | ( ( (_dispLINEBUF[ _x + 2]&0x08) ) >> 3);
+
+ TrValue[2] = TrValue[2] | ( ( (_dispLINEBUF[_x + 2]&0x06) ) << 5);
+ }
+ if( _width/2 > _x + 3 )
+ {
+ TrValue[2] = TrValue[2] | ( ( (_dispLINEBUF[ _x + 3]&0xE0) ) >> 2);
+ TrValue[2] = TrValue[2] | ( ( (_dispLINEBUF[_x + 3]&0x0E) ) >> 1);
+ }
+ }
+ break;
+ case 0x88://TrBIT1:
+ // buffer 2pixel/1byte => 8 pixel/1byte buffe 4byte毎進める。
+ for(int j=0;j<3;j++) TrValue[j] = 0;
+ for(int i = 0 ; i<4 ; i++)
+ {
+ //Green bit => monochrome bit
+ if( _width/2 > _x + i )
+ {
+ TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_x + i]&0x40) == 0 ? 0 : 1 ) << (7-i*2) );
+ TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_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]);
+ }
+ }
+ break;
+ }
+ return TrValue;
+}
+
+/**
+* @brief clear line buffer data by background color data
+*/
+void memLCD8::clsLINEBUF(void)
+{
+
+ for (int j=0; j<_width; j++) {
+ pixel(j,_background);
+ }
+}
+#endif
+//////////////////////////////////////////////////////////////////////////////
+// Frame buffer mode
+//////////////////////////////////////////////////////////////////////////////
+#if FRAMEBUFF_MODE
+
+/**
+* @brief display the text.
+* @param[in] int x : horizontal allocation , up-left of text
+* @param[in] int y : vertical allocation , bottom-right of text
+* @param[in] char* text : strings
+*/
+int memLCD8::textout(int x,int y,char* text)
+{
+ int i=0;
+ char_x = x;
+ char_y = y;
+
+ while(text[i] != 0x00 )
+ {
+ character(char_x, char_y, text[i]);
+ i++;
+ }
+ return text[i];
+}
+
+/**
+* @brief display the oblique text.
+* @param[in] int x : horizontal allocation , up-left of text
+* @param[in] int y : vertical allocation , bottom-right of text
+* @param[in] char* text : strings
+*/
+int memLCD8::obliqueout(int x,int y,char* text)
+{
+ int i=0;
+ char_x = x;
+ char_y = y;
+
+ while(text[i] != 0x00 )
+ {
+ oblique(char_x, char_y, text[i]);
+ i++;
+ }
+ return text[i];
+}
+
+/**
+* @brief dispay a character by bog font. big font is that "char data" byte size is over 0xff.
+* @param[in] int x : horizontal allocation , up-left of text
+* @param[in] int y : vertical allocation , bottom-right of text
+* @param[in] char c : a charactor.
*
*/
void memLCD8::character(int x, int y, int c)
@@ -136,7 +409,7 @@
unsigned char* zeichen;
unsigned char z,w;
- if ((c < 32/*31*/) || (c > 127)) return; // test char range
+ if ((c < 32) || (c > 127)) return; // test char range
//for big font
offset0 = font[0]; // bytes / char uppser adress
@@ -171,8 +444,10 @@
}
/**
-* @brief dispay oblique typte big font.
-*
+* @brief dispay a oblique typte character by big font.
+* @param[in] int x : horizontal allocation , up-left of text
+* @param[in] int y : vertical allocation , bottom-right of text
+* @param[in] char c : a charactor.
*/
void memLCD8::oblique(int x, int y, int c)
{
@@ -180,7 +455,7 @@
unsigned int headroffset;// 2018-10-26 added by Y.Saruhashi
unsigned char* zeichen;
unsigned char z,w;
- if ((c < 32/*31*/) || (c > 127)) return; // test char range
+ if ((c < 32) || (c > 127)) return; // test char range
//for big font
offset0 = font[0]; // bytes / char uppser adress
@@ -217,7 +492,6 @@
else char_x += hor;
}
-
/**
* @brief dispay the image from symbol data
*/
@@ -250,14 +524,6 @@
else char_x += hor;
}
-/*
-void memLCD8::LayerCopy(void)
-{
- for(int i=0; i<FRAME_SIZE; i++) _LayerBUF[i] = _dispBUF[i];
-
-}
-*/
-
/**
* @brief dispay a circle line by color data
*/
@@ -278,6 +544,7 @@
} while (x <= 0);
}
+
/**
* @brief dispay a filled circle by color data
*/
@@ -305,7 +572,6 @@
w = x1 - x0 + 1;
for (int j=0; j<w; j++) pixel(x0+j, y,color);
}
-
/**
* @brief dispay a vertical line by color data
*/
@@ -315,6 +581,7 @@
h = y1 - y0 + 1;
for (int j=0; j<h; j++) pixel(x, y0+j,color);
}
+
/**
* @brief dispay a line by color data
*/
@@ -328,7 +595,7 @@
dx = x1-x0;
dy = y1-y0;
- if (dx == 0) { /* vertical line */
+ if (dx == 0) { // vertical line
if (y1 > y0) vline(x0,y0,y1,color);
else vline(x0,y1,y0,color);
return;
@@ -339,7 +606,7 @@
} else {
dx_sym = -1;
}
- if (dy == 0) { /* horizontal line */
+ if (dy == 0) { // horizontal line
if (x1 > x0) hline(x0,x1,y0,color);
else hline(x1,x0,y0,color);
return;
@@ -387,7 +654,6 @@
}
return;
}
-
/**
* @brief dispay a rectangle line by color data
*/
@@ -408,7 +674,6 @@
return;
}
-
/**
* @brief dispay a filled rectangle by color data
*/
@@ -417,40 +682,6 @@
int h = y1 - y0 + 1;
for (int i=0; i<h; i++) hline(x0, x1, y0+i, color);
}
-
-#ifdef LINEBUFF_MODE
-void memLCD8::pixel(int x, uint8_t color)
-{
- if(!(x % 2)) _dispBUF[x/2] = _dispBUF[x/2]&0x0F | (color << 4)&0xF0 ; //MASK 0000 1111
- else _dispBUF[x/2] = _dispBUF[x/2]&0xF0 | (color )&0x0F ; //MASK 1111 0000
-}
-//void memLCD8::writeLine(int line) // refresh gate line display
-void memLCD8::writeDISP(int line,int transfermode) // refresh gate line display
-{
-
- char pol = 0;
- SetTransfermode(transfermode);
-
-
- // line
- wait_us(6);
- _cs = 1;
- wait_us(6);
- _spi.write(TrModeCommand | (pol << 6) | (line+1)>>8 ); // COMMAND
- _spi.write((line+1)& 0x00FF ); // V ADDR
- for(int j=0; j<_width/2; j++) _spi.write(_dispBUF[j]);
- _spi.write(0x00); // DUMMY transfer
- _spi.write(0x00); // DUMMY transfer
-// wait_ms(1); //1.8Hz simulation
-// wait_ms(2); //1.35Hz simulation
- wait_us(6);
- _cs = 0;
- if(pol) pol=0x00;
- else pol=0x01;
-}
-#endif
-
-#ifndef LINEBUFF_MODE
/**
* @brief Transfer One Pixel Data with x,y allocation
* @param[in] int x : horizontal allocation left to right
@@ -464,113 +695,10 @@
}
/**
-* @brief Transfer Pixel Data from buffer to Display
-* @param[in] int transfermode : instruction the transfer data size ,4bit,3bit,1bit
-*/
-void memLCD8::writeDISP(int transfermode) // refresh whole display
-{
- char pol = 0;
- //char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW A 1010
- SetTransfermode(transfermode);
-
- // frame
- for (int i=0; i<_height; i++) {
- // line
- wait_us(6);
- _cs = 1;
- wait_us(6);
- _spi.write(TrModeCommand | (pol << 6) | (i+1)>>8 ); // COMMAND
- //pc2.printf("com 0x%x\n",TrModeCommand | (pol << 6) | (i+1)>>8);
-
- _spi.write((i+1)& 0x00FF ); // V ADDR
- //pc2.printf("v adr 0x%x\n",(i+1)& 0x00FF);
-
- for(int j=0; j<_width; j+=TrAdd)
- {
- GetPixelValue(j,i,_dispBUF);
- //pc2.printf("data=[%d]{%d][%d]/[%d]\n",j*TrAdd,i,TrValue[0],TrAdd);
- for(int k=0;k<TrValNum;k++)
- _spi.write(TrValue[k]);
- }
- _spi.write(0x00); // DUMMY transfer
- _spi.write(0x00); // DUMMY transfer
-// wait_ms(1); //1.8Hz simulation
-// wait_ms(2); //1.35Hz simulation
- wait_us(6);
- _cs = 0;
- if(pol) pol=0x00;
- else pol=0x01;
- }
-}
-void memLCD8::writeDISP(int startline , int endline , int transfermode) // refresh display selected line
-{
- char pol = 0;
- //char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW A 1010
- SetTransfermode(transfermode);
-
- // frame
- for (int i=startline; i<=endline; i++) {
- // line
- wait_us(6);
- _cs = 1;
- wait_us(6);
- _spi.write(TrModeCommand | (pol << 6) | (i+1)>>8 ); // COMMAND
- //pc2.printf("com 0x%x\n",TrModeCommand | (pol << 6) | (i+1)>>8);
-
- _spi.write((i+1)& 0x00FF ); // V ADDR
- //pc2.printf("v adr 0x%x\n",(i+1)& 0x00FF);
-
- for(int j=0; j<_width; j+=TrAdd)
- //for(int j=0; j<100; j+=TrAdd)
- {
- GetPixelValue(j,i,_dispBUF);
- //pc2.printf("data=[%d]{%d][%d]/[%d]\n",j*TrAdd,i,TrValue[0],TrAdd);
- for(int k=0;k<TrValNum;k++)
- _spi.write(TrValue[k]);
- }
- _spi.write(0x00); // DUMMY transfer
- _spi.write(0x00); // DUMMY transfer
-// wait_ms(1); //1.8Hz simulation
-// wait_ms(2); //1.35Hz simulation
- wait_us(6);
- _cs = 0;
- if(pol) pol=0x00;
- else pol=0x01;
- }
-}
-//old function
-void memLCD8::writeDISP(void) // refresh whole display
-{
-
- char pol = 0;
- char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW A 1010
-
- // frame
- for (int i=0; i<_height; i++) {
- // line
- wait_us(6);
- _cs = 1;
- wait_us(6);
- _spi.write(command | (pol << 6) | (i+1)>>8 ); // COMMAND
- _spi.write((i+1)& 0x00FF ); // V ADDR
- for(int j=0; j<_width/2; j++) _spi.write(_dispBUF[i*_width/2 + j]);
- _spi.write(0x00); // DUMMY transfer
- _spi.write(0x00); // DUMMY transfer
-// wait_ms(1); //1.8Hz simulation
-// wait_ms(2); //1.35Hz simulation
- wait_us(6);
- _cs = 0;
- if(pol) pol=0x00;
- else pol=0x01;
- }
-}
-#endif
-
-/**
* @brief Get Edited data for SPI transfer
-* @param[in] int x:horizontal allocation left to right
-* @param[in] int y:vertival allocation top to bottom
-* @param[in] uint8_t* buff:buffer data for Display
+* @param[in] int x : horizontal allocation left to right
+* @param[in] int y : vertival allocation top to bottom
+* @param[in] uint8_t* buff : buffer data for Display
*/
int* memLCD8::GetPixelValue(int _x, int _y ,uint8_t* buff)
{
@@ -632,28 +760,112 @@
}
/**
-* @brief set Configuration for transfer mode
-* @param[in] int transfermode : instruction the transfer data size ,4bit,3bit,1bit and some parameter
+* @brief Transfer Pixel Data from buffer to Display
+* @param[in] int transfermode : instruction the transfer data size ,4bit,3bit,1bit
*/
-void memLCD8::SetTransfermode(int transfermode)
+void memLCD8::writeDISP(int transfermode) // refresh whole display
+{
+ char pol = 0;
+ //char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW A 1010
+ SetTransfermode(transfermode);
+
+ // frame
+ for (int i=0; i<_height; i++) {
+ // line
+ wait_us(6);
+ _cs = 1;
+ wait_us(6);
+ _spi.write(TrModeCommand | (pol << 6) | (i+1)>>8 ); // COMMAND
+ //pc2.printf("com 0x%x\n",TrModeCommand | (pol << 6) | (i+1)>>8);
+
+ _spi.write((i+1)& 0x00FF ); // V ADDR
+ //pc2.printf("v adr 0x%x\n",(i+1)& 0x00FF);
+
+ for(int j=0; j<_width; j+=TrAdd)
+ {
+ GetPixelValue(j,i,_dispBUF);
+ //pc2.printf("data=[%d]{%d][%d]/[%d]\n",j*TrAdd,i,TrValue[0],TrAdd);
+ for(int k=0;k<TrValNum;k++)
+ _spi.write(TrValue[k]);
+ }
+ _spi.write(0x00); // DUMMY transfer
+ _spi.write(0x00); // DUMMY transfer
+// wait_ms(1); //1.8Hz simulation
+// wait_ms(2); //1.35Hz simulation
+ wait_us(6);
+ _cs = 0;
+ if(pol) pol=0x00;
+ else pol=0x01;
+ }
+}
+
+/**
+* @brief Transfer Pixel Data : from Start line number to Display of frame buffer
+* @param[in] int startline : Start line number to Display
+* @param[in] int endline : end line number to Display
+* @param[in] int transfermode : instruction the transfer data size ,4bit,3bit,1bit
+*/
+void memLCD8::writeDISP(int startline , int endline , int transfermode) // refresh display selected line
{
- switch(transfermode)
- {
- case TrBIT4:
- TrModeCommand = 0x90;
- TrAdd = 1;
- TrValNum = 1;
- break;
- case TrBIT3:
- TrModeCommand = 0x80;
- TrAdd = 4;
- TrValNum = 3;
- break;
- case TrBIT1:
- TrModeCommand = 0x88;
- TrAdd = 4;
- TrValNum = 1;
- break;
+ char pol = 0;
+ //char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW A 1010
+ SetTransfermode(transfermode);
+
+ // frame
+ for (int i=startline; i<=endline; i++) {
+ // line
+ wait_us(6);
+ _cs = 1;
+ wait_us(6);
+ _spi.write(TrModeCommand | (pol << 6) | (i+1)>>8 ); // COMMAND
+ //pc2.printf("com 0x%x\n",TrModeCommand | (pol << 6) | (i+1)>>8);
+
+ _spi.write((i+1)& 0x00FF ); // V ADDR
+ //pc2.printf("v adr 0x%x\n",(i+1)& 0x00FF);
+
+ for(int j=0; j<_width; j+=TrAdd)
+ //for(int j=0; j<100; j+=TrAdd)
+ {
+ GetPixelValue(j,i,_dispBUF);
+ //pc2.printf("data=[%d]{%d][%d]/[%d]\n",j*TrAdd,i,TrValue[0],TrAdd);
+ for(int k=0;k<TrValNum;k++)
+ _spi.write(TrValue[k]);
+ }
+ _spi.write(0x00); // DUMMY transfer
+ _spi.write(0x00); // DUMMY transfer
+// wait_ms(1); //1.8Hz simulation
+// wait_ms(2); //1.35Hz simulation
+ wait_us(6);
+ _cs = 0;
+ if(pol) pol=0x00;
+ else pol=0x01;
+ }
+}
+
+/**
+* @brief Transfer Pixel Data from frame buffer to Display
+*/
+void memLCD8::writeDISP(void) // refresh whole display
+{
+
+ char pol = 0;
+ char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW A 1010
+
+ // frame
+ for (int i=0; i<_height; i++) {
+ // line
+ wait_us(6);
+ _cs = 1;
+ wait_us(6);
+ _spi.write(command | (pol << 6) | (i+1)>>8 ); // COMMAND
+ _spi.write((i+1)& 0x00FF ); // V ADDR
+ for(int j=0; j<_width/2; j++) _spi.write(_dispBUF[i*_width/2 + j]);
+ _spi.write(0x00); // DUMMY transfer
+ _spi.write(0x00); // DUMMY transfer
+ wait_us(6);
+ _cs = 0;
+ if(pol) pol=0x00;
+ else pol=0x01;
}
}
@@ -669,66 +881,5 @@
}
}
}
-
-/**
-* @brief set color data of foreground
-*/
-void memLCD8::foreground(uint8_t colour)
-{
- _foreground = colour;
-}
-
-/**
-* @brief set color data of background
-*/
-void memLCD8::background(uint8_t colour)
-{
- _background = colour;
-}
-
-/**
-* @brief get color data of background
-*/
-
-unsigned char memLCD8::get_Background(void)
-{
- return _background;
-}
+#endif
-/*
-void memLCD8::setmarge(bool ifMarge)
-{
- _ifMarge = ifMarge;
-}
-*/
-
-/**
-* @brief set a display size ,width ,height
-*/
-void memLCD8::setWH(int width, int height)
-{
- _width = width;
- _height = height;
-}
-
-/**
-* @brief transfer a command code to the display by SPI
-*/
-void memLCD8::command(char command)
-{
- wait_us(6);
- _cs = 1;
- wait_us(6);
- _spi.write(command);//
- _spi.write(0x00);// dummy
- wait_us(6);
- _cs = 0;
-}
-/**
-* @brief set the Diaplay On/Off data
-*/
-void memLCD8::SwDisp(bool ONorOFF)
-{
- _disp= ONorOFF;
-}
-
--- a/MIP8F_SPI.h Wed Oct 31 02:05:47 2018 +0000
+++ b/MIP8F_SPI.h Tue Nov 06 02:16:10 2018 +0000
@@ -1,7 +1,11 @@
/**
* @file MIP8F_SPI.h
-* @brief ver3.0 Library header file: Class for JDI MIP8 display
+* @brief ver4.0 Library header file: Class for JDI MIP8 display
* @details
+* Ver4.0 Addtional function is Line buffer version
+* Ver3.0 Addtional function is font display
+* ver2.0 Addtional function is Monochome display by 1bit mode of SPI transfer.
+*
* <license>
* Copyright 2018 Japan Display Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,16 +24,22 @@
* Select compile option
******************************************/
/**
-* @def LINEBUFF_MODE
-* @ brief If you will use a Line Buffer mode,you must define LINEBUFF_MODE
+* @def LINEBUFF_MODE 0
+* @brief If you will use a Line Buffer mode,you must define LINEBUFF_MODE 1
*/
-//#define LINEBUFF_MODE
+#define LINEBUFF_MODE 1
+/**
+* @def FRAMEBUFF_MODE 1
+* @brief If you will use a Frame Buffer mode,you must define LINEBUFF_MODE 1
+*/
+#define FRAMEBUFF_MODE 0
/*****************************************
******************************************/
-#ifdef LINEBUFF_MODE
+#if LINEBUFF_MODE
// 1dot = 4bit
#define LINE_SIZE 320 // 640 / 2
-#else
+#endif
+#if FRAMEBUFF_MODE
//#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
@@ -61,29 +71,44 @@
class memLCD8 : public Stream {
public:
-/**
-* @brief Constructor : Set MPU pin names
-*/
+ unsigned char* font;
+
+ /**
+ * @brief Constructor : Set MPU pin names
+ */
memLCD8(PinName mosi,PinName miso,PinName sclk,PinName cs,PinName disp,PinName power);
-#ifndef LINEBUFF_MODE
- void writeDISP(void);
- void writeDISP(int transfermode); // transfermode : 4bit,3bit,1bit
- void writeDISP(int startline , int endline , int transfermode); // refresh display selected line
- void pixel(int x, int y, uint8_t color); //for framebuffer
-#else
- void writeDISP(int line,int transfermode);// for linebuffer
- void pixel(int x, uint8_t color); // for linebuffer
-#endif
- void clsBUF(void);
void locate(int x, int y);
+ void set_font(unsigned char* f);
+ void setWH(int width, int height);
+ void SwDisp(bool ONorOFF);
void foreground(uint8_t colour);
void background(uint8_t colour);
void command(char command);
+ //ver2.0
+ void SetTransfermode(int transfermode);
+
+ //ver3.0
+ void set_FixedFontWidth( unsigned char width );
+ void set_ActualFontWidth(void);
+ unsigned char get_Background(void);
+
+#if LINEBUFF_MODE
+ //ver3.0
+ void pixel(int x, uint8_t color);
+ void clsLINEBUF(void);
+ int* GetPixelValueFromLineBuffer(int _x,uint8_t* buff);
+ void writeDISPLinebuffer(void);
+ void writeDISP(int line,int transfermode);
+#endif
+
+#if FRAMEBUFF_MODE
+ void pixel(int x, int y, uint8_t color);
+ void writeDISP(void);
+ void writeDISP(int transfermode);// transfermode : 4bit,3bit,1bit
+ void writeDISP(int startline , int endline , int transfermode);// refresh display selected line
+ void clsBUF(void);
void setmarge(bool ifMarge);
- void setWH(int width, int height);
- void SwDisp(bool ONorOFF);
void character(int x, int y, int c);
-// void LayerCopy(void);
void circle(int x0, int y0, int r, uint8_t color);
void fillcircle(int x0, int y0, int r, uint8_t color);
void hline(int x0, int x1, int y, uint8_t color);
@@ -92,20 +117,13 @@
void rect(int x0, int y0, int x1, int y1, uint8_t color);
void fillrect(int x0, int y0, int x1, int y1, uint8_t color);
void Symbol(unsigned int x, unsigned int y, unsigned char *symbol);
- void set_font(unsigned char* f);
-
- unsigned char* font;
-
//ver2.0
- void SetTransfermode(int transfermode);
int* GetPixelValue(int x , int y , uint8_t* buff);
//ver3.0
- void set_FixedFontWidth( unsigned char width );
- void set_ActualFontWidth(void);
- unsigned char get_Background(void);
int textout(int x,int y,char* text);
void oblique(int x, int y, int c);
int obliqueout(int x,int y,char* text);
+#endif
protected:
virtual int _putc(int value);
@@ -131,14 +149,15 @@
//! Fixed Font width size if _FixedFontWidth==0, use actual Font width size.
unsigned char _FixedFontWidth;
-#ifndef LINEBUFF_MODE
+#if FRAMEBUFF_MODE
//! frame buffer for display
uint8_t _dispBUF[FRAME_SIZE];
//uint8_t _LayerBUF[FRAME_SIZE];
-#else
+#endif
+#if LINEBUFF_MODE
//uint8_t *_pLineBuf;
//! line buffer for display
- uint8_t _dispBUF[LINE_SIZE];
+ uint8_t _dispLINEBUF[LINE_SIZE];
#endif
//! height,diplay pixel size