USED IMAGE2GLCD

Dependencies:   BLE_API SharpLCD_LucidaFont mbed nRF51822

Fork of Renard_YO by Andrea Corrado

Revision:
3:e73cbdf58f5b
Parent:
2:e6ff3466221e
Child:
4:b131ff1e047c
--- a/main.cpp	Fri Jul 11 13:48:46 2014 +0000
+++ b/main.cpp	Wed Aug 27 10:38:48 2014 +0000
@@ -1,7 +1,7 @@
 #include "mbed.h"
 #include "DebouncedInterrupt.h"
-#include "EaEpaper.h"
-#include "Arial12x12.h"
+#include "font.h"
+#include "SharpLCD.hpp"
 #include "icon.h"
 
 //I/O Initialisation
@@ -11,16 +11,10 @@
 DebouncedInterrupt buttonOne (P0_16);
 DebouncedInterrupt buttonTwo (P0_17);
 
-//Epaper Init
-EaEpaper epaper(P0_0, //PWR_CONTROL
-            P0_1,     //BORDER CONTROL
-            P0_2,     //DISCHARGE
-            P0_3,     //RESET
-            P0_4,     //BUSY
-            P0_5,     //SSEL
-            P0_6,     //PWM
-            P0_12,P0_13,P0_15, //MOSI,MISO,SCLK
-            P0_22,P0_20);//SDA, SDL
+SharpLCD lcd(P0_0, P0_24, P0_20, P0_22, P0_25, P0_27);
+
+uint8_t framebuffer[SharpLCD::SIZEOF_FRAMEBUFFER_FOR_ALLOC];
+SharpLCD::FrameBuffer fb(framebuffer);
 
 //Notification Data struct
 #define NOTIFICATION_TEXT_MAX_LENGTH 20
@@ -97,60 +91,60 @@
 }
 
 //Layout Coordinates
-#define TYPE_ICON_X          5
-#define TYPE_ICON_Y         10
-#define UNREAD_ICON_X       96
-#define UNREAD_ICON_Y       14
-#define PRIMARY_TEXT_X       5
-#define PRIMARY_TEXT_Y      64
-#define SECONDARY_TEXT_X     5
-#define SECONDARY_TEXT_Y    82
+#define TYPE_ICON_X         10 //5
+#define TYPE_ICON_Y         60 //10
+#define UNREAD_ICON_X       60 //96
+#define UNREAD_ICON_Y       60 //14
+#define PRIMARY_TEXT_X      10 //5
+#define PRIMARY_TEXT_Y      30 //64
+#define SECONDARY_TEXT_X    10 //5
+#define SECONDARY_TEXT_Y    50 //82
 //Update Display to show current notification...
+
+//Serial  pc(USBTX, USBRX);
+
 void doDisplayUpdate() {
-    epaper.cls();
+    //pc.printf("display update"); //Debug
+    lcd.clear();
     if(visible_notification_index >= 0) {
         //Write current notification...        
         //Draw type icon...
         switch(notifications[visible_notification_index].type) {
             case NOTIFICATION_TYPE_ALARM:
-                epaper.print_bm(bitmAlarm, TYPE_ICON_X, TYPE_ICON_Y);
+                fb.bitBlit(Alarm, 32, 32, TYPE_ICON_X, TYPE_ICON_Y);
                 break;
                 
             case NOTIFICATION_TYPE_CALL:
-                epaper.print_bm(bitmCall, TYPE_ICON_X, TYPE_ICON_Y);
+                fb.bitBlit(Call, 32, 32, TYPE_ICON_X, TYPE_ICON_Y);
                 break;
                 
             case NOTIFICATION_TYPE_SMS:
-                epaper.print_bm(bitmSMS, TYPE_ICON_X, TYPE_ICON_Y);
+                fb.bitBlit(SMS, 32, 32, TYPE_ICON_X, TYPE_ICON_Y);
                 break;
                 
             case NOTIFICATION_TYPE_EMAIL:
-                epaper.print_bm(bitmEmail, TYPE_ICON_X, TYPE_ICON_Y);
+                fb.bitBlit(Email, 32, 32, TYPE_ICON_X, TYPE_ICON_Y);
                 break;
                 
             case NOTIFICATION_TYPE_EVENT:
-                epaper.print_bm(bitmCalendar, TYPE_ICON_X, TYPE_ICON_Y);
+                fb.bitBlit(Calendar, 32, 32, TYPE_ICON_X, TYPE_ICON_Y);
                 break;
         }
                 
         //Unread notification
         if(isUnread(notifications[visible_notification_index])){
-            epaper.print_bm(bitmUnread, UNREAD_ICON_X, UNREAD_ICON_Y);
+            fb.bitBlit(Unread, 16, 24, UNREAD_ICON_X, UNREAD_ICON_Y);
         }
         //Text fields...
-        epaper.set_font((unsigned char*)Arial12x12);
-        epaper.locate(PRIMARY_TEXT_X,PRIMARY_TEXT_Y);
-        epaper.printf(notifications[visible_notification_index].primary_text);
-        epaper.locate(SECONDARY_TEXT_X,SECONDARY_TEXT_Y);
-        epaper.printf(notifications[visible_notification_index].secondary_text);
+        fb.printString(lookupFontFace("DejaVu Serif", 8), PRIMARY_TEXT_X, PRIMARY_TEXT_Y, BLACK, notifications[visible_notification_index].primary_text);
+        fb.printString(lookupFontFace("DejaVu Serif", 8), SECONDARY_TEXT_X, SECONDARY_TEXT_Y, BLACK, notifications[visible_notification_index].secondary_text);
     } else {
         //no notifications...
         //Write current notification...
-        epaper.set_font((unsigned char*)Arial12x12);
-        epaper.locate(PRIMARY_TEXT_X,PRIMARY_TEXT_Y);
-        epaper.printf("No Notifications");
+        fb.printString(lookupFontFace("DejaVu Serif", 8), PRIMARY_TEXT_X, PRIMARY_TEXT_Y, BLACK, "No");
     }
-    epaper.write_disp();
+    //epaper.write_disp();
+    lcd.drawFrameBuffer(fb);
     needs_display_update = 0;
 }
 
@@ -264,28 +258,38 @@
     
     notifications[0].type = NOTIFICATION_TYPE_ALARM;
     notifications[0].state = NOTIFICATION_STATE_UNREAD;
-    strcpy(notifications[0].primary_text,"Wake Up");
-    strcpy(notifications[0].secondary_text, "07:00");
+    //strcpy(notifications[0].primary_text,"Wake Up");
+    //strcpy(notifications[0].secondary_text, "07:00");
+    strcpy(notifications[0].primary_text,"Test");
+    strcpy(notifications[0].secondary_text, "1");
     
     notifications[1].type = NOTIFICATION_TYPE_CALL;
     notifications[1].state = NOTIFICATION_STATE_UNREAD;
-    strcpy(notifications[1].primary_text,"Eric Gowland");
-    strcpy(notifications[1].secondary_text, "07770909177");
+    //strcpy(notifications[1].primary_text,"Eric Gowland");
+    //strcpy(notifications[1].secondary_text, "07770909177");
+    strcpy(notifications[1].primary_text,"Test");
+    strcpy(notifications[1].secondary_text, "2");
     
     notifications[2].type = NOTIFICATION_TYPE_SMS;
     notifications[2].state = NOTIFICATION_STATE_UNREAD;
-    strcpy(notifications[2].primary_text,"Hi, txt me...");
-    strcpy(notifications[2].secondary_text, "07770909177");
+    //strcpy(notifications[2].primary_text,"Hi, txt me...");
+    //strcpy(notifications[2].secondary_text, "07770909177");
+    strcpy(notifications[2].primary_text,"Test");
+    strcpy(notifications[2].secondary_text, "3");
     
     notifications[3].type = NOTIFICATION_TYPE_EMAIL;
     notifications[3].state = NOTIFICATION_STATE_UNREAD;
-    strcpy(notifications[3].primary_text, "Dear Sir I have $US");
-    strcpy(notifications[3].secondary_text, "not@scam.net");
+    //strcpy(notifications[3].primary_text, "Dear Sir I have $US");
+    //strcpy(notifications[3].secondary_text, "not@scam.net");
+    strcpy(notifications[3].primary_text, "Test");
+    strcpy(notifications[3].secondary_text, "4");
     
     notifications[4].type = NOTIFICATION_TYPE_EVENT;
     notifications[4].state = NOTIFICATION_STATE_UNREAD;
-    strcpy(notifications[4].primary_text,"Review Meeting");
-    strcpy(notifications[4].secondary_text, "10:00 - 10:30");
+    //strcpy(notifications[4].primary_text,"Review Meeting");
+    //strcpy(notifications[4].secondary_text, "10:00 - 10:30");
+    strcpy(notifications[4].primary_text,"Test");
+    strcpy(notifications[4].secondary_text, "5");
     
     //Set location, etc.
     visible_notification_index = 0;
@@ -296,6 +300,7 @@
 
 //Main Program Function
 int main() {
+    lcd.enableDisplay();
     //Init Data
     initNotificationData();
     //Attach interrupt handlers...