scrolling example code for SHARP LCD LS027B4DH01/LS027B7DH01, using AkiSpiLcd library
This is very basic library example to access a graphic LCD LS027B4DH01 or LS027B7DH01
Import libraryAkiSpiLcd
Basic library for SHARP LCD LS027B4DH01/LS027B7DH01
- schematic example1:
- schematic example2:
- example1 photo:
- example2 photo:
- example2 movie (mpeg4 movie):
Revision 4:37321a3e4ed8, committed 2014-05-06
- Comitter:
- k4zuki
- Date:
- Tue May 06 14:57:37 2014 +0000
- Parent:
- 3:8dbf3336dc66
- Child:
- 5:8883e74c0f11
- Commit message:
- added dispOn(bool) function
Changed in this revision
--- a/AkiSpiLcd.cpp Tue May 06 13:01:55 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -/* -this is for SHARP LCD LS027B4DH01 -by Kazuki Yamamoto, or _K4ZUKI_ -*/ -#include "AkiSpiLcd.h" - -AkiSpiLcd::AkiSpiLcd(PinName mosi,PinName sck, PinName cs, PinName disp) - :_spi(mosi,NC,sck), _cs(cs), _disp(disp) -{ - _cs=0; - _spi.format(8,0); - _spi.frequency(2000000); - comflag = modeflag = clearflag = 0; - _disp=1; -} - -void AkiSpiLcd::cls() -{ - modeflag=0; - clearflag=1; - - _cs=1; - wait_us(5); - - _spi.write( (modeflag << 7) | (comflag << 6) | (clearflag << 5) ); - _spi.write(0x00); - - wait_us(5); - _cs=0; - - if(comflag == 0) { - comflag = 1; - } else { - comflag = 0; - } -} - -void AkiSpiLcd::updateSingle(int line, uint8_t* data) -{ - modeflag=1; - clearflag=0; - - _cs=1; - wait_us(5); - - _spi.write( (modeflag << 7) | (comflag << 6) | (clearflag << 5) ); - _spi.write( - ( ( (line+1) & 0x01 ) << 7 )| - ( ( (line+1) & 0x02 ) << 5 )| - ( ( (line+1) & 0x04 ) << 3 )| - ( ( (line+1) & 0x08 ) << 1 )| - ( ( (line+1) & 0x10 ) >> 1 )| - ( ( (line+1) & 0x20 ) >> 3 )| - ( ( (line+1) & 0x40 ) >> 5 )| - ( ( (line+1) & 0x80 ) >> 7 ) - ); - - for(int i=0; i<50; i++) { - _spi.write( *(data+i) ); - } - _spi.write(0x00); - _spi.write(0x00); - - wait_us(5); - _cs=0; - - if(comflag == 0) { - comflag = 1; - } else { - comflag = 0; - } -} - -void AkiSpiLcd::updateMulti(int line, int length, uint8_t* data) -{ - modeflag=1; - clearflag=0; - - if(length>0) { - _cs=1; - wait_us(5); - for (int j=0; j<length; j++) { - _spi.write( (modeflag << 7) | (comflag << 6) | (clearflag << 5) ); - _spi.write( - ( ( (line+1) & 0x01 ) << 7 )| - ( ( (line+1) & 0x02 ) << 5 )| - ( ( (line+1) & 0x04 ) << 3 )| - ( ( (line+1) & 0x08 ) << 1 )| - ( ( (line+1) & 0x10 ) >> 1 )| - ( ( (line+1) & 0x20 ) >> 3 )| - ( ( (line+1) & 0x40 ) >> 5 )| - ( ( (line+1) & 0x80 ) >> 7 ) - ); - - for(int i=0; i<50; i++) { - _spi.write( *(data+(50*j+i)) );//hogepic[50*j+i] - } - line+=1; - } - _spi.write(0x00); - _spi.write(0x00); - wait_us(5); - _cs=0; - } - if(comflag == 0) { - comflag = 1; - } else { - comflag = 0; - } -} - -void AkiSpiLcd::cominvert() -{ - modeflag=0; - clearflag=0; - - _cs=1; - - _spi.write( (modeflag << 7) | (comflag << 6) | (clearflag << 5) ); - _spi.write(0x00); - wait_us(5); - _cs=0; - if(comflag == 0) { - comflag = 1; - } else { - comflag = 0; - } -}
--- a/AkiSpiLcd.h Tue May 06 13:01:55 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -/* -this is for SHARP LCD LS027B4DH01 -by Kazuki Yamamoto, or _K4ZUKI_ -*/ -#include "mbed.h" - -class AkiSpiLcd -{ -public: - AkiSpiLcd(PinName mosi,PinName sck, PinName cs, PinName disp); - void cls(); - void updateSingle(int line, uint8_t* data); - void updateMulti(int line, int length, uint8_t* data); - void cominvert(); -private: - int comflag; - int modeflag; - int clearflag; - SPI _spi; - DigitalOut _cs; - DigitalOut _disp; -};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AkiSpiLcd.lib Tue May 06 14:57:37 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/k4zuki/code/AkiSpiLcd_lib/#06927342f2f1