Basic library for SHARP LCD LS027B4DH01/LS027B7DH01
Dependents: AkiSpiLcd_demo AkiSpiLcd_demo2 LCDRAM AkiSpiLcd_example
Revision 3:f835b8daf9a0, committed 2014-08-28
- Comitter:
- k4zuki
- Date:
- Thu Aug 28 01:51:04 2014 +0000
- Parent:
- 2:01979b296ab5
- Child:
- 4:844693a617dc
- Commit message:
- changed function names
Changed in this revision
AkiSpiLcd.cpp | Show annotated file Show diff for this revision Revisions of this file |
AkiSpiLcd.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/AkiSpiLcd.cpp Tue May 06 17:25:03 2014 +0000 +++ b/AkiSpiLcd.cpp Thu Aug 28 01:51:04 2014 +0000 @@ -5,14 +5,14 @@ #include "mbed.h" #include "AkiSpiLcd.h" -AkiSpiLcd::AkiSpiLcd(PinName mosi,PinName sck, PinName cs, PinName disp) - :_spi(mosi,NC,sck), _cs(cs), _disp(disp) +AkiSpiLcd::AkiSpiLcd(PinName mosi,PinName sck, PinName csl, PinName csr) + :_spi(mosi,NC,sck), _csl(csl), _csr(csr) { - _cs=0; + _csl=0; _spi.format(8,0); _spi.frequency(2000000); comflag = modeflag = clearflag = 0; - _disp=1; + _csr=0; } void AkiSpiLcd::cls() @@ -20,14 +20,14 @@ modeflag=0; clearflag=1; - _cs=1; + _csl=1; wait_us(5); _spi.write( (modeflag << 7) | (comflag << 6) | (clearflag << 5) ); _spi.write(0x00); wait_us(5); - _cs=0; + _csl=0; if(comflag == 0) { comflag = 1; @@ -36,15 +36,16 @@ } } -void AkiSpiLcd::updateSingle(int line, uint8_t* data) +void AkiSpiLcd::directUpdateSingle(int line, uint8_t* data) { modeflag=1; clearflag=0; - _cs=1; + _csl=1; wait_us(5); _spi.write( (modeflag << 7) | (comflag << 6) | (clearflag << 5) ); + _spi.write( ( ( (line+1) & 0x01 ) << 7 )| ( ( (line+1) & 0x02 ) << 5 )| @@ -55,7 +56,6 @@ ( ( (line+1) & 0x40 ) >> 5 )| ( ( (line+1) & 0x80 ) >> 7 ) ); - for(int i=0; i<50; i++) { _spi.write( *(data+i) ); } @@ -63,7 +63,7 @@ _spi.write(0x00); wait_us(5); - _cs=0; + _csl=0; if(comflag == 0) { comflag = 1; @@ -72,13 +72,13 @@ } } -void AkiSpiLcd::updateMulti(int line, int length, uint8_t* data) +void AkiSpiLcd::directUpdateMulti(int line, int length, uint8_t* data) { modeflag=1; clearflag=0; if(length>0) { - _cs=1; + _csl=1; wait_us(5); for (int j=0; j<length; j++) { _spi.write( (modeflag << 7) | (comflag << 6) | (clearflag << 5) ); @@ -101,7 +101,7 @@ _spi.write(0x00); _spi.write(0x00); wait_us(5); - _cs=0; + _csl=0; } if(comflag == 0) { comflag = 1; @@ -115,24 +115,25 @@ modeflag=0; clearflag=0; - _cs=1; + _csl=1; _spi.write( (modeflag << 7) | (comflag << 6) | (clearflag << 5) ); _spi.write(0x00); wait_us(5); - _cs=0; + _csl=0; if(comflag == 0) { comflag = 1; } else { comflag = 0; } } - +/* void AkiSpiLcd::dispOn(bool disp) { if(disp) { - _disp=1; + _csr=1; } else { - _disp=0; + _csr=0; } } +*/
--- a/AkiSpiLcd.h Tue May 06 17:25:03 2014 +0000 +++ b/AkiSpiLcd.h Thu Aug 28 01:51:04 2014 +0000 @@ -41,7 +41,8 @@ * @param cs HIGH-active chip enable input * @param disp HIGH-active display enable input */ - AkiSpiLcd(PinName mosi,PinName sck, PinName cs, PinName disp); +// AkiSpiLcd(PinName mosi,PinName sck, PinName cs, PinName disp); + AkiSpiLcd(PinName mosi,PinName sck, PinName csl, PinName csr); /** Clear screen */ @@ -51,30 +52,34 @@ * @param line line number(1-240) * @param *data pointer to data */ - void updateSingle(int line, uint8_t* data); + void directUpdateSingle(int line, uint8_t* data); /** Writes multi lines(400 x N bits = 50 x N bytes) * @param line line number(1-240) * @param length number of line to write * @param *data pointer to data */ - void updateMulti(int line, int length, uint8_t* data); + void directUpdateMulti(int line, int length, uint8_t* data); /** Inverting internal COM signal */ void cominvert(); + + /** Writes single line (400 bits = 50 bytes) into VRAM + + */ - /** Enables/disables display. internal memory will not flushed - * @param disp true = display is on / false = display is off - */ - void dispOn(bool disp); +// /** Enables/disables display. internal memory will not flushed +// * @param disp true = display is on / false = display is off +// */ +// void dispOn(bool disp); private: int comflag; int modeflag; int clearflag; SPI _spi; - DigitalOut _cs; - DigitalOut _disp; + DigitalOut _csl; + DigitalOut _csr; }; #endif