Peter Drescher's library for the Embedded Artists E-paper display, but modified to also support the LPC4088 QuickStart Board

Dependents:   app_epaper

Fork of EaEpaper by Peter Drescher

Revision:
3:6fb3e296a6fd
Parent:
0:fedcef5319f5
--- a/EPD.cpp	Sun Nov 10 19:32:53 2013 +0000
+++ b/EPD.cpp	Wed Dec 04 12:51:40 2013 +0000
@@ -18,7 +18,10 @@
 
 #include "EPD.h"
 #include "mbed.h"
+
+#if !defined(TARGET_LPC4088)
 #include "BurstSPI.h"
+#endif
 
 
 // delays - more consistent naming
@@ -39,13 +42,6 @@
 #define millis_start() _time.start()
 
 
-//static void PWM_start(int pin);
-//static void PWM_stop(int pin);
-
-//static void SPI_put(uint8_t c);
-//static void SPI_put_wait(uint8_t c, int busy_pin);
-//static void SPI_send(uint8_t cs_pin, const uint8_t *buffer, uint16_t length);
-
 
 EPD_Class::EPD_Class(EPD_size size,
              PinName panel_on_pin,
@@ -139,8 +135,7 @@
     digitalWrite(this->EPD_Pin_BORDER, LOW);
     digitalWrite(this->EPD_Pin_EPD_CS, LOW);
 
-    //PWM_start(this->EPD_Pin_PWM);
-    EPD_Pin_PWM = 0.5;
+    PWM_start();
     Delay_ms(5);
     digitalWrite(this->EPD_Pin_PANEL_ON, HIGH);
     Delay_ms(10);
@@ -221,8 +216,7 @@
 
     // final delay before PWM off
     Delay_ms(30);
-    //PWM_stop(this->EPD_Pin_PWM);
-    EPD_Pin_PWM = 0.0;
+    PWM_stop();
 
     // charge pump negative voltage on
     Delay_us(10);
@@ -594,20 +588,41 @@
 
     // send all data
     for (uint16_t i = 0; i < length; ++i) {
+#if defined(TARGET_LPC4088)
+        spi_.write(*buffer++);
+#elif
         spi_.fastWrite(*buffer++);
         spi_.clearRX();
+#endif    
     }
 
     // CS high
     digitalWrite(cs_pin, HIGH);
 }
 
+#if defined(TARGET_LPC4088)
+void EPD_Class::PWM_flip() {
+    EPD_Pin_PWM = !EPD_Pin_PWM;
+}
+#endif
 
-//static void PWM_start(int pin) {
-//    analogWrite(pin, 128);  // 50% duty cycle
-//}
+void EPD_Class::PWM_start() {
+#if defined(TARGET_LPC4088) 
+    pwmTicker.attach_us(this, &EPD_Class::PWM_flip, 5);
+#elif
+    // we need at least a 100kHz signal -> 10us period
+    EPD_Pin_PWM.period_us(10);
 
+    // 50% duty cycle
+    EPD_Pin_PWM = 0.5;
+#endif
+}
 
-//static void PWM_stop(int pin) {
-//    analogWrite(pin, 0);
-//}
+void EPD_Class::PWM_stop() {
+#if defined(TARGET_LPC4088) 
+    pwmTicker.detach();
+#elif
+    EPD_Pin_PWM = 0;
+#endif
+}
+