scrolling example code for SHARP LCD LS027B4DH01/LS027B7DH01, using AkiSpiLcd library

Dependencies:   AkiSpiLcd mbed

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: /media/uploads/k4zuki/akispilcd_v2.1m.sch.png
  • schematic example2: /media/uploads/k4zuki/2.7inchshield.sch.png
  • example1 photo: /media/uploads/k4zuki/2014-09-17_20.22.26.jpg /media/uploads/k4zuki/2014-09-17_20.22.48.jpg
  • example2 photo: /media/uploads/k4zuki/2014-04-29_13.17.57.jpg
  • example2 movie (mpeg4 movie):

Files at this revision

API Documentation at this revision

Comitter:
k4zuki
Date:
Sun May 04 03:34:28 2014 +0000
Parent:
0:3569e2cfb60b
Child:
2:3554ec6df722
Commit message:
library fix / scrolling hogepic

Changed in this revision

AkiSpiLcd.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/AkiSpiLcd.cpp	Thu May 01 00:01:02 2014 +0000
+++ b/AkiSpiLcd.cpp	Sun May 04 03:34:28 2014 +0000
@@ -76,33 +76,32 @@
     modeflag=1;
     clearflag=0;
 
-    _cs=1;
-    wait_us(5);
+    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 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]
+            for(int i=0; i<50; i++) {
+                _spi.write( *(data+(50*j+i)) );//hogepic[50*j+i]
+            }
+            line+=1;
         }
-        line+=1;
+        _spi.write(0x00);
+        _spi.write(0x00);
+        wait_us(5);
+        _cs=0;
     }
-    _spi.write(0x00);
-    _spi.write(0x00);
-
-    wait_us(5);
-    _cs=0;
-
     if(comflag == 0) {
         comflag = 1;
     } else {
@@ -119,7 +118,7 @@
 
     _spi.write( (modeflag << 7) | (comflag << 6) | (clearflag << 5) );
     _spi.write(0x00);
-    wait_us(20);
+    wait_us(5);
     _cs=0;
     if(comflag == 0) {
         comflag = 1;
--- a/main.cpp	Thu May 01 00:01:02 2014 +0000
+++ b/main.cpp	Sun May 04 03:34:28 2014 +0000
@@ -3,78 +3,42 @@
 #include "mbed.h"
 #include "hogepic.h"
 #include "AkiSpiLcd.h"
+
 /*
-1 SCLK d3=p13
-2 MOSI d5=p11
-3 CS d2=p14
-4 DISP enable d7=p24
+1 SCLK D3=p13
+2 MOSI D5=p11
+3 CS D2=p14
+4 DISP enable D5=p22
 */
-/*
-SPI LCD(MOSI_,NC,SCK_);
-DigitalOut CS(D2);
-DigitalOut DISP(D5);
-DigitalOut COMCLK(D4);
-*/
+
 AkiSpiLcd LCD(MOSI_, SCK_, D2, D5);
 DigitalOut myled(LED1);
-//Ticker disp;
+Ticker disp;
 extern volatile const uint8_t hogepic[];
-/*
+
 void dispinvert(void)
 {
+    LCD.cominvert();
 }
-*/
+
 int main()
 {
 
     wait_ms(1);
+//    disp.attach(&dispinvert,0.1);
     LCD.cls();
     LCD.updateSingle(10,(uint8_t*)(hogepic+2000));
     LCD.updateMulti(100,(240-100),(uint8_t*)(hogepic));
-/*
-//    disp.attach(&dispinvert,0.1);
-    CS=0;
-
-    LCD.format(8,0);
-    LCD.frequency(1000000);
-
-    CS=1;
-    LCD.write(0x20);
-    LCD.write(0x00);
-    wait_us(5);
-    CS=0;
-
-    DISP=1;
-
-    CS=1;
-    LCD.write(0x80);
-    for(int j=0; j<240; j++) {
-        LCD.write(
-            ( ( (j+1) & 0x01 ) << 7 )|
-            ( ( (j+1) & 0x02 ) << 5 )|
-            ( ( (j+1) & 0x04 ) << 3 )|
-            ( ( (j+1) & 0x08 ) << 1 )|
-            ( ( (j+1) & 0x10 ) >> 1 )|
-            ( ( (j+1) & 0x20 ) >> 3 )|
-            ( ( (j+1) & 0x40 ) >> 5 )|
-            ( ( (j+1) & 0x80 ) >> 7 )
-        );
-
-        for(int i=0; i<50; i++) {
-//            LCD.write(0xf0);
-            LCD.write(hogepic[50*j+i]);
-        }
-        LCD.write(0x00);
-        LCD.write(0x00);
+    
+    while(1) {
+    for(int i=0;i<240;i++){
+        LCD.updateMulti(i,(240-i),(uint8_t*)(hogepic));
+        LCD.updateMulti(0,(i),(uint8_t*)(hogepic+50*(240-i)));
     }
-    wait_us(2);
-    CS=0;
-*/
-    while(1) {
-        myled = 1;
+/*        myled = 1;
         wait(0.2);
         myled = 0;
-        wait(0.2);
+        wait(0.2);*/
     }
 }