USED IMAGE2GLCD

Dependencies:   BLE_API SharpLCD_LucidaFont mbed nRF51822

Fork of Renard_YO by Andrea Corrado

Revision:
1:f0635f12df8c
Parent:
0:9bea6067730f
Child:
2:e6ff3466221e
--- a/main.cpp	Wed Jul 02 13:19:34 2014 +0000
+++ b/main.cpp	Fri Jul 04 13:39:06 2014 +0000
@@ -3,6 +3,7 @@
 #include "EaEpaper.h"
 #include "Arial28x28.h"
 #include "Arial12x12.h"
+#include "icon.h"
 
 //I/O Initialisation
 DigitalOut myled(LED1);
@@ -24,10 +25,11 @@
 
 //Notification Data struct
 #define NOTIFICATION_TEXT_MAX_LENGTH 20
-#define NOTIFICATION_TYPE_CALL     0x01
-#define NOTIFICATION_TYPE_SMS      0x02
-#define NOTIFICATION_TYPE_EMAIL    0x03
-#define NOTIFICATION_TYPE_EVENT    0x04
+#define NOTIFICATION_TYPE_ALARM    0x01
+#define NOTIFICATION_TYPE_CALL     0x02
+#define NOTIFICATION_TYPE_SMS      0x03
+#define NOTIFICATION_TYPE_EMAIL    0x04
+#define NOTIFICATION_TYPE_EVENT    0x05
 #define NOTIFICATION_STATE_DELETED 0x00
 #define NOTIFICATION_STATE_UNREAD  0x01
 #define NOTIFICATION_STATE_READ    0x02
@@ -95,21 +97,58 @@
     return note.state == NOTIFICATION_STATE_READ;
 }
 
+//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
 //Update Display to show current notification...
 void doDisplayUpdate() {
     epaper.cls();
     if(visible_notification_index >= 0) {
-        //Write current notification...
+        //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);
+                break;
+                
+            case NOTIFICATION_TYPE_CALL:
+                epaper.print_bm(bitmCall, TYPE_ICON_X, TYPE_ICON_Y);
+                break;
+                
+            case NOTIFICATION_TYPE_SMS:
+                epaper.print_bm(bitmSMS, TYPE_ICON_X, TYPE_ICON_Y);
+                break;
+                
+            case NOTIFICATION_TYPE_EMAIL:
+                epaper.print_bm(bitmEmail, TYPE_ICON_X, TYPE_ICON_Y);
+                break;
+                
+            case NOTIFICATION_TYPE_EVENT:
+                epaper.print_bm(bitmCalendar, 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);
+        }
+        //Text fields...
         epaper.set_font((unsigned char*)Arial12x12);
-        epaper.locate(5,5);
+        epaper.locate(PRIMARY_TEXT_X,PRIMARY_TEXT_Y);
         epaper.printf(notifications[visible_notification_index].primary_text);
-        epaper.locate(5,15);
+        epaper.locate(SECONDARY_TEXT_X,SECONDARY_TEXT_Y);
         epaper.printf(notifications[visible_notification_index].secondary_text);
     } else {
         //no notifications...
         //Write current notification...
         epaper.set_font((unsigned char*)Arial12x12);
-        epaper.locate(5,5);
+        epaper.locate(PRIMARY_TEXT_X,PRIMARY_TEXT_Y);
         epaper.printf("No Notifications");
     }
     epaper.write_disp();
@@ -223,15 +262,31 @@
 //Initialise notification data...
 void initNotificationData() {
     //For debug purposes...
-    notifications[0].type = NOTIFICATION_TYPE_CALL;
+    
+    notifications[0].type = NOTIFICATION_TYPE_ALARM;
     notifications[0].state = NOTIFICATION_STATE_UNREAD;
-    strcpy(notifications[0].primary_text,"Eric Gowland");
-    strcpy(notifications[0].secondary_text, "07770909177");
+    strcpy(notifications[0].primary_text,"Wake Up");
+    strcpy(notifications[0].secondary_text, "07:00");
+    
+    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");
     
-    notifications[1].type = NOTIFICATION_TYPE_EMAIL;
-    notifications[1].state = NOTIFICATION_STATE_UNREAD;
-    strcpy(notifications[1].primary_text, "Dear Sir I have $US");
-    strcpy(notifications[1].secondary_text, "not@scam.net");
+    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");
+    
+    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");
+    
+    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");
     
     //Set location, etc.
     visible_notification_index = 0;