E-Paper Device (EPD) based MiniNote module, powered by mbed on LPC1114FBD48. Shared in public domain with enclosure in 3D step format, hardware interface compatible with microBUS interface. Anyone can contribute on this project.

Dependencies:   mbed _24LCXXX

E-Badge MiniNote Project on mbed/NXP LPC1114 platform

Files at this revision

API Documentation at this revision

Comitter:
allankliu
Date:
Wed Jun 11 09:12:36 2014 +0000
Parent:
2:bb9f154ea2f4
Child:
4:5032c106eea1
Commit message:
Demo tested on hardware.

Changed in this revision

SSD1606/rom_image.h Show annotated file Show diff for this revision Revisions of this file
SSD1606/ssd1606.cpp Show annotated file Show diff for this revision Revisions of this file
SSD1606/ssd1606.h 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/SSD1606/rom_image.h	Mon Jun 09 11:01:38 2014 +0000
+++ b/SSD1606/rom_image.h	Wed Jun 11 09:12:36 2014 +0000
@@ -611,7 +611,7 @@
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,};
 
 
-const unsigned char gImage_shousi[3096] = { /* 0X81,0X02,0XAC,0X00,0X48,0X00, */
+const unsigned char gImage_sushi[3096] = { /* 0X81,0X02,0XAC,0X00,0X48,0X00, */
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 0XFF,0XFF,0XF3,0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
@@ -808,7 +808,7 @@
 0X0F,0XC3,0XC0,0X00,0X00,0X00,0X00,0X00,};
 
 
-const unsigned char gImage_bazhe[3096] = { /* 0X01,0X02,0XAC,0X00,0X48,0X00, */
+const unsigned char gImage_20off[3096] = { /* 0X01,0X02,0XAC,0X00,0X48,0X00, */
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 0XFF,0XFF,0XF0,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 0XFF,0XFF,0XFF,0XFF,0XF0,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
@@ -1202,7 +1202,7 @@
 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,};
 
 
-const unsigned char gImage_jifen[3096] = { /* 0X01,0X02,0XAC,0X00,0X48,0X00, */
+const unsigned char gImage_royalty[3096] = { /* 0X01,0X02,0XAC,0X00,0X48,0X00, */
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
@@ -1989,7 +1989,7 @@
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,};
 
-const unsigned char gImage_eluosi[3096] = { /* 0X81,0X02,0XAC,0X00,0X48,0X00, */
+const unsigned char gImage_russian[3096] = { /* 0X81,0X02,0XAC,0X00,0X48,0X00, */
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
@@ -2383,7 +2383,7 @@
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,};
 
 
-const unsigned char gImage_hanwen[3096] = { /* 0X81,0X02,0XAC,0X00,0X48,0X00, */
+const unsigned char gImage_korean[3096] = { /* 0X81,0X02,0XAC,0X00,0X48,0X00, */
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 0XFF,0XCF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
@@ -2975,7 +2975,7 @@
 0XAA,0XAA,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,};
 
 
-const unsigned char gImage_riwen[3096] = { /* 0X81,0X02,0XAC,0X00,0X48,0X00, */
+const unsigned char gImage_japanese[3096] = { /* 0X81,0X02,0XAC,0X00,0X48,0X00, */
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
@@ -3172,7 +3172,6 @@
 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,};
 
 
-
 const unsigned char gImage_RECT[3096] = { /* 0X01,0X02,0XAC,0X00,0X48,0X00, */
 0X00,0X00,0X3F,0XFC,0X00,0X00,0X3F,0XFC,0X00,0X00,0X3F,0XFC,0X00,0X00,0X3F,0XFC,
 0X00,0X00,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
--- a/SSD1606/ssd1606.cpp	Mon Jun 09 11:01:38 2014 +0000
+++ b/SSD1606/ssd1606.cpp	Wed Jun 11 09:12:36 2014 +0000
@@ -49,21 +49,23 @@
     _reset = 1;
     wait_ms(1);
     _reset = 0;
-    wait_ms(5);
+    wait_ms(1);
     _reset = 1;
-    wait_ms(5);
+    wait_ms(1);
 }
 
 void SSD1606::read_busy()
 {
-    while(_busy==1){
-        wait_ms(1);
+    while(1)
+    {
+        asm("nop");
+        if(_busy==0)
+            break;
     }
 }
 
 void SSD1606::initialize()
 {
-    reset();
   _send_command(0x10);
   _send_data(0x00);
 #ifdef MODE3
@@ -196,7 +198,7 @@
 
 void SSD1606::clear()
 {
-    for (int i=0; i<FRAMEBUF_SIZE; i++)
+    for (int i=0; i<3096; i++)
         _send_data(0xFF);
     _cursor_x = 0;
     _cursor_y = 0;
@@ -204,18 +206,21 @@
 
 void SSD1606::_vspi_write(unsigned char value)
 {
+    unsigned char tmp;
+    tmp = value;
+    
     for (int i=0; i<8; i++)
     {
-        if(value & 0x80)
+        if(tmp & 0x80)
         {
             _data = 1;          
         }else{
             _data = 0;
         }
-        _data = _data<<1;
         _clk = 1;
         wait_us(SPI_BUS_DELAY);
         _clk = 0;
+        tmp = tmp<<1;
     }
 }
 
@@ -258,9 +263,9 @@
 {
     int i = 0;
     unsigned char x, y;
-    for (x=0; x<SSD1606_LCDHEIGHT; x++)
+    for (x=0; x<SSD1606_WIDTH; x++)
     {
-        for (y=0; y<SSD1606_LCDWIDTH; y++)
+        for (y=0; y<COLBUF_SIZE; y++)
         {
             i++;
             if (i<pix)
@@ -298,3 +303,12 @@
 void SSD1606::set_font(unsigned char *font, unsigned char width)
 {
 }
+
+void SSD1606::_send_data_1bpp(unsigned char value)
+{
+    unsigned char temp;
+    temp = EPD_2bpp_LUT[value & 0x0F];
+    _send_data(temp);
+    temp = EPD_2bpp_LUT[value>>4 & 0x0F];
+    _send_data(temp);
+}
--- a/SSD1606/ssd1606.h	Mon Jun 09 11:01:38 2014 +0000
+++ b/SSD1606/ssd1606.h	Wed Jun 11 09:12:36 2014 +0000
@@ -4,41 +4,43 @@
 #include "mbed.h"
 #define MODE1
 
-#define IRAM_8KB            0
-#define BPP_2bit            1
-
-#define INT_FB_3K           0
-#define INT_FB_1K           0
-#define EXT_FB_3K           1
-
 /*
     The width/height parameters depend on different vendor. The max is 180x128
     http://www.solomon-systech.com.cn/cn/product/advanced-display/bistable-display-driver-controller/
  */
-#define SSD1606_LCDWIDTH 172
-#define SSD1606_LCDHEIGHT 72
-#define SSD1606_GREYLEVEL   2
+#define SSD1606_WIDTH 172
+#define SSD1606_HEIGHT 72
+
+#define GREY_BPP            2   // [1:2], 1bpp or 2bpp
 
-#define FRAMEBUF_SIZE_1bpp      (SSD1606_LCDWIDTH * SSD1606_LCDHEIGHT / 8)
-#define FRAMEBUF_SIZE_2bpp      (SSD1606_LCDWIDTH * SSD1606_LCDHEIGHT * SSD1606_GREYLEVEL / 8)
+#define COLBUF_SIZE     (SSD1606_HEIGHT / 8 * GREY_BPP) // 72/8*2=18 Byte for 2bpp
+#define FRAMEBUF_SIZE   (SSD1606_WIDTH * COLBUF_SIZE)   // 172 * 18 = 3096B
+
+#define IRAM_8KB
 
-#define FRAMEBUF_SIZE       FRAMEBUF_SIZE_1bpp
+#define ROM2BPP_SIZE    3096
+#define ROM1BPP_SIZE    1548
 
+//ROM IMAGE INDEX
 #define PIC_ONE                 1
 #define PIC_NOKIA               2
 #define PIC_SUNING          3
-#define PIC_SHOUSI          4
-#define PIC_BAZHE           5
+#define PIC_SUSHI           4
+#define PIC_20OFF           5
 #define PIC_CHESSBOARD  6
-#define PIC_JIFEN               7
+#define PIC_ROYALTY         7
 #define PIC_FU                  8
 #define PIC_GC4                 9
 #define PIC_SAVE                10
-#define PIC_GL1                 20
-#define PIC_GL2                 21
-#define PIC_BLACK               22
-#define PIC_WHITE               23
+#define PIC_RUSSIAN         11
+#define PIC_COMPANY         12
+#define PIC_KOREAN          13
+#define PIC_OED                 14
+#define PIC_OEDBOOK         15
+#define PIC_JAPANESE        16
+#define PIC_RECT                17
 
+//FUNCTION IMAGE INDEX
 #define TEST_GREY1          1
 #define TEST_GREY2          2
 #define TEST_BLK                3
@@ -47,7 +49,7 @@
 #define TEST_STRIP1         6
 #define TEST_STRIP2         7
 
-#define SPI_BUS_DELAY       10
+#define SPI_BUS_DELAY       5
 
 class SSD1606
 {
@@ -90,6 +92,7 @@
 
     void _send_command(unsigned char code);
     void _send_data(unsigned char value);
+        void _send_data_1bpp(unsigned char value);
         void _vspi_write(unsigned char value);
         void _draw_pattern(unsigned char value, unsigned int pix);
     
--- a/main.cpp	Mon Jun 09 11:01:38 2014 +0000
+++ b/main.cpp	Wed Jun 11 09:12:36 2014 +0000
@@ -1,75 +1,87 @@
 #include "mbed.h"
 #include "ssd1606.h"
-//#include "Ebadge.h"
 #include "_24LCXXX.h"
 #include "rom_image.h"
+//#include "eeprom.h"
 
-#define STX 0x02
-#define ETX 0x03
-#define DISPWIDTH       172
-#define DISPHEIGHT  72
-#define DISPBPP     2
-#define DISPBUFSIZE DISPWIDTH * DISPHEIGHT * DISPBPP / 8
+// Check mbed LPC1114 LPCXpresso board at mbed.org
+//  http://mbed.org/users/okano/notebook/pinout-picture/
+// Check LPCXpresso LPC1114 schematics at embeddedartists.com
+//  http://www.embeddedartists.com/sites/default/files/docs/schematics/LPCXpressoLPC1114revA.pdf
+
+// WARNING: xp5/xp6/xp7 (P0_9/P0_8/P2_11) are reserved for SPI
+// Check source code at github.com
+//  https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/spi_api.c
+
+// In LPC1114FN28, SPI uses dp2/dp1/dp6 (P0_9/P0_8/P0_6) with different SCK pin
 
 // naked LPC1114 on breadboard, install LED pin28, pasive piezo-buzzer pin1
 DigitalOut myled(dp28);  // LED ... P0_7 (pin 28)
 Serial uart(dp16, dp15); // UART .. P1_7: TX (pin 16), P1_6: RX (pin 15)
 //PwmOut pwm(dp1);         // PWM ... P0_8: CT16B0_MAT0 (pin1); sorry, blocking SPI!  
 
-
-uint16_t xmtptr;
-uint16_t xmtsize;
+// EPD interface: CS | RST | DC | BUSY | MOSI | SCK
+// Consider move P2_3 & P2_1 (xp37, xp13) for MOSI & SCK as 2nd SPI
+// Don't follow schematics from EA, since its silkscreen is wrong for SPI1
+//SSD1606 epd(P0_6,P0_7,P2_0,P1_5,P2_3,P2_1);
+SSD1606 epd(P0_6,P2_2,P2_0,P1_5,P2_3,P2_1);
 
-//SSD1306 display(dp2,dp4,dp5,dp6,dp10);
-// SSD1606(cs, rst, dc, clk, busy, data);
-SSD1606 epd(P0_6,P0_3,P2_0,P1_9,P1_10,P1_11);
+//SSD1606 epd(P0_6,P0_7,P2_0,P1_5,P1_11,P1_10);
+//SSD1606 epd2(xp23,xp11,xp12,xp21,xp38,xp39);
 
-I2C i2c(P0_5, P0_4);
+
+I2C i2c(xp42, xp41);    // I2C ... P0_5: SDA, P0_4: SCL
 _24LCXXX nvmem(&i2c, 0x50);
 
 //enum EEPROM::TypeEeprom T24C256;
-//EEPROM fram2(P0_5,P0_4,0xA0,T24C256);
+//EEPROM nvmem(P0_5,P0_4,0xA0,T24C256);
 
 char c = '0';
 unsigned char sbuf[128];
 
-void setup() {
-    //pwm.period(0.001);  // PWM period 1ms (1kHz)   
-    uart.baud(115200);  // Baud rate
-    //uart.puts("E-Badge MiniNote LPC1114 Demo Start.\n\r");
+void setup()
+{
+    
+  //pwm.period(0.001);  // PWM period 1ms (1kHz)   
+  uart.baud(115200);  // Baud rate
+  //uart.puts("E-Badge MiniNote LPC1114 Demo Start.\n\r");
     //nvmem.write(0x10,0x55);
+    epd.reset();
     epd.initialize();
-    epd.clear();
-    epd.update();
     epd.rom_image(gImage_one);
+    epd.set_command_between_images();
+    wait(5);
+    epd.rom_image(gImage_sushi);
+    epd.set_command_between_images();
+    wait(5);
 
-/*  
-    epd.test_image(TEST_BLK);
-    wait(3);
-    epd.test_image(TEST_GREY2);
-    wait(3);
-    epd.test_image(TEST_GREY1);
-    wait(3);
-    epd.test_image(TEST_WHT);
-    wait(3);
-*/  
     nvmem.byte_write(0,1);
     nvmem.byte_write(1,2);
     nvmem.byte_write(2,3);
     nvmem.byte_write(3,4);
+    nvmem.nbyte_read(0x00,sbuf,16);
+
+
 }
 
-void loop() {
-        if (uart.readable()) {
-            c = uart.getc();
-            uart.putc(c);
-            }
+void loop()
+{
+    /*
+    myled = 0;  // LED on
+    //pwm = 0.5;  // PWM duty cycle 50%, tone 1kHz
+    wait(0.5);
+    uart.putc(c++); if (c > '9') c = '0';  // Put Character & rotate 0,1,2,... 9
+    myled = 1;  // LED off
+    //pwm = 0;    // PWM stop, silent
+    wait(0.5);
+    */
+    uart.putc(c++); if (c > '9') c = '0';  // Put Character & rotate 0,1,2,... 9
 }
 
 int main() {
+    
     setup();
-    
   while(1) {    // repeat (period 1sec)
         loop();
-    }       
+    }
 }