Robert Fischer / Mbed 2 deprecated ILI9341_Clock_Nucleo

Dependencies:   BMP180 DS3231 RHT03 SDFileSystem SPI_TFT_ILI9341 _24LCXXX mbed SHTx

Files at this revision

API Documentation at this revision

Comitter:
RobertFischer
Date:
Sun Jun 01 13:21:48 2014 +0000
Parent:
1:5c0b32a77708
Commit message:
Some major changes. Now using SHT11 temperature humidity sensor. Code for AM2302 and DHT22 still available. Display changed to landscape orientation and inverted to white letters on black background.;

Changed in this revision

SHTx.lib Show annotated file Show diff for this revision Revisions of this file
TFT_fonts/Arial28x28.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 5c0b32a77708 -r 47de2d58ecc7 SHTx.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SHTx.lib	Sun Jun 01 13:21:48 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/NegativeBlack/code/SHTx/#8465801be23f
diff -r 5c0b32a77708 -r 47de2d58ecc7 TFT_fonts/Arial28x28.h
--- a/TFT_fonts/Arial28x28.h	Sat May 17 22:59:43 2014 +0000
+++ b/TFT_fonts/Arial28x28.h	Sun Jun 01 13:21:48 2014 +0000
@@ -484,10 +484,16 @@
 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // Code for char ~
 
+0x0A, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x03, 0x00, 0x00, 0xF0, 0x07, 0x00, 0x00, 0x38, 0x0E, 0x00, 0x00, 0x18, 0x0C, 0x00, 0x00, 0x18, 0x0C, 0x00, 0x00, 0x18, 0x0C, 0x00, 
+0x00, 0x38, 0x0E, 0x00, 0x00, 0xF0, 0x07, 0x00, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+/*
 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00   // Code for char };
+*/
 
-};
 
diff -r 5c0b32a77708 -r 47de2d58ecc7 main.cpp
--- a/main.cpp	Sat May 17 22:59:43 2014 +0000
+++ b/main.cpp	Sun Jun 01 13:21:48 2014 +0000
@@ -2,6 +2,7 @@
  * Simple indoor weather station with TFT display
  *
  * Sensors: AM2302 aka DHT22 hygrometer thermometer
+ *      or  SHT10/SHT11/SHT15 hygrometer thermometer
  *          BMP180 barometer atmospheric pressure
  *
  * Real time clock: DS3231
@@ -21,6 +22,15 @@
  * will release this code later.
  *
  * Changes:
+ * June, 1st :  Version 2.0
+ *              Changed to landscape view and inverted display
+ *              add support for SHT11 sensor. 
+ *              SHT10 and SHT15 should also work.
+ *              Using TTP224 capacity toch switch with 4 sensors
+ *              Touch 1 = show statistics graph
+ *              Touch 2 = show normal display
+ *              Touch 3 = (not used yet)
+ *              Touch 4 = toggle diplay led on/off
  * May, 18.: Now guessing weather. First splash screen disabled.
  *           Changed the reading of temp sensor. If after 5 tries 
  *           no luck, take old values. The AM2302 reading is not
@@ -42,20 +52,25 @@
 #include "_24LCXXX.h"
 #include "BMP180.h"
 #include "RHT03.h" //AM2303
+#include "sht15.hpp"
 
 // some fonts
 #include "Courier9x15.h"
 #include "Arial12x12.h"
+#include "Arial28x28.h"
 #include "Times_New_Roman28x27.h"
 
 // my functions
 void drawClock(void);
 void drawAnalogTime(void);
 void drawDigitalTime(void);
-void drawTemp(void);
+void drawTempAM2302(void);
+void drawTempSHT(void);
 void drawPressure(void);
 void SetTime(void);
 void UpdateDisplay(void);
+void UpdateDisplayNoStore(void);
+void switchBackLight(void);
 void storeData(void);
 void showGraph(void);
 int map (int ,int , int , int , int);
@@ -66,8 +81,8 @@
 
 // analog clock size and locate
 #define CLOCK_RADIUS 64           // radius of clock face
-#define CLOCK_CENTER_X 68         // If you adjust the radius, you'll probably want to adjust this
-#define CLOCK_CENTER_Y 68         // If you adjust the radius, you'll probably want to adjust this
+#define CLOCK_CENTER_X 82         // If you adjust the radius, you'll probably want to adjust this
+#define CLOCK_CENTER_Y 150         // If you adjust the radius, you'll probably want to adjust this
 
 // Maximum of stored value into eeprom
 #define max_datastorage 576       // 576 * 6 = 3456
@@ -78,6 +93,9 @@
 #define FAIR    1020
 #define SUNNY   1030 // hPa
 
+#define BGCOLOR    0x0000
+#define TEXTCOLOR  0xFFFF
+
 // the TFT is connected to SPI
 SPI_TFT_ILI9341 TFT(PA_7, PA_6, PA_5, PB_6, PA_9, PC_7,"TFT"); // NUCLEO mosi, miso, sclk, cs, reset, dc
 
@@ -85,31 +103,39 @@
 SDFileSystem sd(PB_15, PB_14, PB_13, PB_12, "sd"); // MOSI, MISO, SCLK, SSEL
 
 I2C i2c(PB_9, PB_8);            // sda, scl
+
 BMP180 bmp(PB_9, PB_8);
 DS3231 rtc(PB_9,PB_8);
 _24LCXXX eeprom(&i2c, 0x57);
-RHT03 humtemp(PA_10); //Initalise the RHT03 (change pin number to the pin its connected to)
+SHTx::SHT15 sht11(PB_11, PB_10);// SDA,SCL extra I2C port needed for sht1x sensor
+RHT03 humtemp(PA_10);           //Initalise the RHT03 (change pin number to the pin its connected to)
 
 // set interrupts
-InterruptIn RTCInt(PB_4);
-InterruptIn ShowGraphInt(PB_5);
+InterruptIn RTCInt(PC_4);       // from rtc module
+InterruptIn ShowGraphInt(PC_2); // from touch pad [1]
+InterruptIn UpDispInt(PC_3);    // from touch pad [2]
+//InterruptIn   (PC_10);        // not yet used   [3]
+InterruptIn BackLight(PC_5);    // from touch pad [4]
+
+DigitalOut TFTBL(PB_3);         // backlit control
 
 int main()
 {
     char Control;
     int err;
-    //unsigned int y;
 
     // Test if SD-Card works
     //FILE *fp = fopen("/sd/mbed.txt", "a");
     //fprintf(fp, "Hello World!\n");
     //fclose(fp);
+    
+    TFTBL = 1;  // Switch back light on
 
-    TFT.set_orientation(0);
+    TFT.set_orientation(1); // Oriantation landscape
     TFT.claim(stdout);      // send stdout to the TFT display
     TFT.claim(stderr);      // send stderr to the TFT display
-    TFT.background(White);    // set background to black
-    TFT.foreground(Black);    // set chars to white
+    TFT.background(BGCOLOR);    // set background color
+    TFT.foreground(TEXTCOLOR);    // set chars color
     TFT.set_font((unsigned char*) Arial12x12);
     TFT.cls();                // clear the screen
 
@@ -121,16 +147,23 @@
     TFT.cls();                // clear the screen
     */
     
+    sht11.update();
+    
+    
     TFT.locate(0,0);
-    printf("  Hello Mbed ");
-    TFT.Bitmap(20,20,172,55,p1);
-    err = TFT.BMP_16(2,80,"/sd/rain.bmp");  // load test.bmp from external SD-card
+    printf("  Hello mbed.org ");
+    TFT.locate(100,0);
+    printf("Temp: %2.2f  Hum: %2.2f",sht11.getTemperature(),sht11.getHumidity());
+    //TFT.Bitmap(20,20,172,55,p1);
+    err = TFT.BMP_16(2,20,"/sd/sun_b.bmp");  // load bmp from external SD-card
     if (err != 1) TFT.printf(" - Err: %d",err);
-    err = TFT.BMP_16(82,80,"/sd/cloud.bmp");  // load test.bmp from external SD-card
+    err = TFT.BMP_16(100,20,"/sd/suncloud_b.bmp");  // load bmp from external SD-card
+    if (err != 1) TFT.printf(" - Err: %d",err);
+    err = TFT.BMP_16(200,20,"/sd/cloud_b.bmp");  // load bmp from external SD-card
     if (err != 1) TFT.printf(" - Err: %d",err);
-    err = TFT.BMP_16(2,160,"/sd/suncloud.bmp");  // load test.bmp from external SD-card
+    err = TFT.BMP_16(2,120,"/sd/rain_b.bmp");  // load bmp from external SD-card
     if (err != 1) TFT.printf(" - Err: %d",err);
-    err = TFT.BMP_16(82,160,"/sd/sun.bmp");  // load test.bmp from external SD-card
+    err = TFT.BMP_16(100,120,"/sd/thunder_b.bmp");  // load bmp from external SD-card
     if (err != 1) TFT.printf(" - Err: %d",err);
 
 
@@ -148,19 +181,27 @@
     rtc.writeRegister(DS3231_Control_Status,Control);
 
 
-    wait(1);        // wait two seconds
+    wait(2);        // wait a second
 
     UpdateDisplay();
 
-    RTCInt.fall(&UpdateDisplay);     // interrupt for display update every minute called by rtc alarm
+    ShowGraphInt.rise(&showGraph);  // interrupt for showing value history diagram. called by a button or capacitive touch switch
 
-    ShowGraphInt.fall(&showGraph);  // interrupt for showing value history diagram. called by a button or capacitive touch switch
+    BackLight.rise(&switchBackLight);  // interrupt for showing value history diagram. called by a button or capacitive touch switch
+    
+    UpDispInt.rise(&UpdateDisplayNoStore);
+
+    RTCInt.fall(&UpdateDisplay);     // interrupt every minute called by rtc alarm for display update
 
     while(1) {
         wait(10.0);
     }
 }
 
+void switchBackLight(void)
+{
+    TFTBL = !TFTBL;
+    }
 
 void UpdateDisplay(void)
 {
@@ -169,7 +210,7 @@
 
     TFT.cls();
 
-    TFT.fillrect(237,317,239,319,Red); // Just for status: during update there is a small red dot at the bottom right corner
+    TFT.fillrect(317,237,319,239,Red); // Just for status: during update there is a small red dot at the bottom right corner
 
     drawClock();
     drawAnalogTime();
@@ -177,12 +218,10 @@
 
     drawPressure();
 
-    drawTemp();
+    drawTempSHT();
 
     storeData();
 
-    TFT.fillrect(237,317,239,319,White);
-
     // Reset clock alarm
     char Control=rtc.readRegister(DS3231_Control_Status)& 0xFC;
     rtc.writeRegister(DS3231_Control_Status,Control);
@@ -191,6 +230,24 @@
 
 }
 
+void UpdateDisplayNoStore(void)
+{   // Data should only stored on rtc interrupt
+
+    TFT.cls();
+
+    TFT.fillrect(317,237,319,239,Red); // Just for status: during update there is a small red dot at the bottom right corner
+
+    drawClock();
+    drawAnalogTime();
+    drawDigitalTime();
+
+    drawPressure();
+
+    drawTempAM2302();
+
+}
+
+
 // store every ten minute values into file and eeprom
 void storeData(void)
 {
@@ -198,8 +255,6 @@
     unsigned int store_address;
     char b[6];
 
-    //led1=0;
-
     rtc.readDateTime(&dayOfWeek,&date,&month,&year,&hour,&minute,&second);
 
     // Save only every 10 minutes
@@ -232,7 +287,6 @@
 
     }
 
-    //led1=1;
 }
 
 // show grap of stored data (at the moment landscape oriented. not yet changed to potrait display)
@@ -240,22 +294,24 @@
 {
     unsigned int store_address,i;
     char b[6];
-    char temp_arr[204], temp_min, temp_max;
-    char humidity_arr[204], hum_min, hum_max;
-    int pressure_arr[204], press_min, press_max;
+    char temp_arr[250], temp_min, temp_max;
+    char humidity_arr[250], hum_min, hum_max;
+    int pressure_arr[250], press_min, press_max;
 
     eeprom.nbyte_read( COUNTERADDRESS, &store_address, sizeof(int) );
 
+    TFTBL = 1;  // Switch back light on
+
     TFT.set_font((unsigned char*) Courier9x15);
 
-    TFT.set_orientation(1);
+    //TFT.set_orientation(1);
     TFT.cls();
-    TFT.line(58,8,58,50,0);
-    TFT.line(56,48,263,48,0);
-    TFT.line(58,60,58,102,0);
-    TFT.line(56,100,263,100,0);
-    TFT.line(58,112,58,154,0);
-    TFT.line(56,152,263,152,0);
+    TFT.line(68,8,68,50,TEXTCOLOR);
+    TFT.line(66,48,319,48,TEXTCOLOR);
+    TFT.line(68,80,68,122,TEXTCOLOR);
+    TFT.line(66,120,319,120,TEXTCOLOR);
+    TFT.line(68,152,68,204,TEXTCOLOR);
+    TFT.line(66,202,319,202,TEXTCOLOR);
 
     // store_address is allways one step ahead of last stored values
     if ( store_address == 0)
@@ -272,17 +328,19 @@
     press_max = 0;
 
     // Read from EEPROM storage into arrays
-    for (i=0; i<204; i++) {
+    for (i=0; i<250; i++) {
         eeprom.nbyte_read( store_address, &b, 6);
 
         // draw every 2 hour an line
         if ( b[2] == 0 && (b[1]%4 == 0 || b[1] == 0) ) {
-            TFT.line(263-i,46,263-i,50,1);
-            TFT.line(263-i,98,263-i,102,1);
-            TFT.line(263-i,150,263-i,154,1);
-            TFT.locate(254-i,158);
+            TFT.line(319-i,46,319-i,50,TEXTCOLOR);
+            TFT.line(319-i,118,319-i,122,TEXTCOLOR);
+            TFT.line(319-i,200,319-i,204,TEXTCOLOR);
             if ( i > 15 )                     // do not write at the right border
+            {
+                TFT.locate(310-i,208);
                 printf("%2i",b[1]);
+            }
         }
 
         // store temp into array and check min max
@@ -329,38 +387,35 @@
     hum_min = hum_min - (hum_min%5);
     hum_max += 1;
     hum_max = hum_max + (5 - (hum_max%5));
-    TFT.locate(0,54);
+    TFT.locate(0,74);
     printf("%i%%",hum_max);
-    TFT.locate(0,92);
+    TFT.locate(0,112);
     printf("%i%%",hum_min);
 
     press_min -= 1;
     press_min = press_min - (press_min%5);
     press_max += 1;
     press_max = press_max + (5 - (press_max%5));
-    TFT.locate(0,106);
+    TFT.locate(0,146);
     printf("%ihPa",press_max);
-    TFT.locate(0,144);
+    TFT.locate(0,184);
     printf("%ihPa",press_min);
 
     // drawing lines
-    for (i=0; i<204; i++) {
+    for (i=0; i<250; i++) {
         // temp line
-        TFT.pixel(263-i,map(temp_arr[i],temp_min,temp_max,48,8),Red);
+        TFT.pixel(319-i,map(temp_arr[i],temp_min,temp_max,48,8),Red);
         // humidity line
-        TFT.pixel(263-i,map(humidity_arr[i],hum_min,hum_max,100,60),Blue);
+        TFT.pixel(319-i,map(humidity_arr[i],hum_min,hum_max,120,80),Blue);
         // pressure line
-        TFT.pixel(263-i,map(pressure_arr[i],press_min,press_max,152,112),Green);
+        TFT.pixel(319-i,map(pressure_arr[i],press_min,press_max,202,152),Green);
 
     }
 
-    //epaper.write_disp(); // update screen
-    TFT.set_orientation(0);
-
 }
 
 // draw temp and humidity
-void drawTemp(void)
+void drawTempAM2302(void)
 {
     int done=0, i;
     float temp,hum;
@@ -372,27 +427,45 @@
             i=5;
         }
     }
-    /*
-    while(!done) { //Loop keeps running until RHT03 is read succesfully
-        wait(2.2); //Needed to make sure the sensor has time to initalise and so its not polled too quickly
-        if(humtemp.readData() == RHT_ERROR_NONE) done=1; //Request data from the RHT03
-    }
-    */
 
     if(done) { // only if read was successful
         temp = humtemp.getTemperatureC(); //Gets the current temperature in centigrade
         store_temp = temp;
         hum = humtemp.getHumidity(); //Gets the current humidity in percentage
         store_humidity = hum;
+        TFT.fillrect(317,237,319,239,BGCOLOR);
     } else { // read was not successful, take old values
         temp = store_temp;
         hum = store_humidity;
+        TFT.fillrect(317,237,319,239,0x7000);
     }
 
-    TFT.set_font((unsigned char*) Times_New_Roman28x27);  // select the font
-    TFT.locate(156,0);
+    //TFT.set_font((unsigned char*) Times_New_Roman28x27);  // select the font
+    TFT.set_font((unsigned char*) Arial28x28);  // select the font
+    TFT.locate(232,0);
     printf("%2.0f%cC",temp,127);
-    TFT.locate(156,31);
+    TFT.locate(240,40);
+    printf("%2.0f%%",hum);
+
+}
+
+void drawTempSHT(void)
+{
+    float temp,hum;
+
+    sht11.update();
+
+    temp = sht11.getTemperature(); //Gets the current temperature
+    store_temp = temp;
+    hum = sht11.getHumidity(); //Gets the current humidity in percentage
+    store_humidity = hum;
+    TFT.fillrect(317,237,319,239,BGCOLOR);
+
+    //TFT.set_font((unsigned char*) Times_New_Roman28x27);  // select the font
+    TFT.set_font((unsigned char*) Arial28x28);  // select the font
+    TFT.locate(232,0);
+    printf("%2.0f%cC",temp,127);
+    TFT.locate(240,40);
     printf("%2.0f%%",hum);
 
 }
@@ -408,26 +481,27 @@
 
     Pressure /= 100; // convert to hPa
 
-    TFT.set_font((unsigned char*) Times_New_Roman28x27);  // select the font
-    TFT.locate(0,138);
+    //TFT.set_font((unsigned char*) Times_New_Roman28x27);  // select the font
+    TFT.set_font((unsigned char*) Arial28x28);  // select the font
+    TFT.locate(180,200);
     printf("%4dhPa",Pressure);
     TFT.set_font((unsigned char*) Courier9x15);
-    TFT.locate(0,168);
+    TFT.locate(220,100);
     printf("%i,%1i%cC",BMP180_Temperature/10,BMP180_Temperature%10,127);
 
     // Draw some weather icons for test
     int err ;
     if ( Pressure < RAIN ) {
-        err = TFT.BMP_16(2,190,"/sd/rain.bmp");  // load test.bmp from external SD-card
+        err = TFT.BMP_16(192,92,"/sd/rain_b.bmp");  // load test.bmp from external SD-card
         if (err != 1) TFT.printf(" - Err: %d",err);
     } else if ( Pressure < CHANGE ) {
-        err = TFT.BMP_16(2,190,"/sd/cloud.bmp");  // load test.bmp from external SD-card
+        err = TFT.BMP_16(192,92,"/sd/cloud_b.bmp");  // load test.bmp from external SD-card
         if (err != 1) TFT.printf(" - Err: %d",err);
     } else if ( Pressure < FAIR ) {
-        err = TFT.BMP_16(2,190,"/sd/suncloud.bmp");  // load test.bmp from external SD-card
+        err = TFT.BMP_16(192,92,"/sd/suncloud_b.bmp");  // load test.bmp from external SD-card
         if (err != 1) TFT.printf(" - Err: %d",err);
     } else {
-        err = TFT.BMP_16(2,190,"/sd/sun.bmp");  // load test.bmp from external SD-card
+        err = TFT.BMP_16(192,92,"/sd/sun_b.bmp");  // load test.bmp from external SD-card
         if (err != 1) TFT.printf(" - Err: %d",err);
     }
 
@@ -442,18 +516,24 @@
 
     rtc.readDateTime(&dayOfWeek,&date,&month,&year,&hour,&minute,&second);
 
-    TFT.set_font((unsigned char*) Times_New_Roman28x27);  // select the font
-    TFT.locate(0,290);
+    //TFT.set_font((unsigned char*) Times_New_Roman28x27);  // select the font
+    TFT.set_font((unsigned char*) Arial28x28);  // select the font
 
     if (date > 0) {
-        printf("%02i.%02i.%i %02i:%02d",date,month,year,hour,minute);
+        TFT.locate(0,0);
+        printf("%02i.%02i.%i",date,month,year);
+        TFT.locate(44,40);
+        printf("%02i:%02d",hour,minute);
     } else {
+        TFT.locate(0,0);
         printf("Error read RTC");
     }
 
 }
 
 // guess what ;-)
+// procedure to set time. mosty only used once for rtc
+// rtc module wil keep time with battery
 void SetTime()
 {
     // DS3231
@@ -487,9 +567,9 @@
     y3 = CLOCK_CENTER_Y + 3 * cos(3.14 * ((double) (m + 90))/180);
     x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 20) * sin(3.14 * ((double) m)/180);
     y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 20) * cos(3.14 * ((double) m)/180);
-    TFT.line(x1,y1,x2,y2,0x001F);
-    TFT.line(x3,y3,x2,y2,0x001F);
-    TFT.line(x1,y1,x3,y3,0x001F);
+    TFT.line(x1,y1,x2,y2,Red);
+    TFT.line(x3,y3,x2,y2,Red);
+    TFT.line(x1,y1,x3,y3,Red);
 
     // Draw hour hand
 
@@ -514,9 +594,9 @@
     y3 = CLOCK_CENTER_Y + 3 * cos(3.14 * ((double) (h + 90))/180);
     x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 32) * sin(3.14 * ((double) h)/180);
     y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 32) * cos(3.14 * ((double) h)/180);
-    TFT.line(x1,y1,x2,y2,0xF400);
-    TFT.line(x3,y3,x2,y2,0xF400);
-    TFT.line(x1,y1,x3,y3,0xF400);
+    TFT.line(x1,y1,x2,y2,Green);
+    TFT.line(x3,y3,x2,y2,Green);
+    TFT.line(x1,y1,x3,y3,Green);
 
 }
 
@@ -526,14 +606,14 @@
 {
     int x1, x2, y1, y2;
 
-    TFT.background(White);    // set background to black
-    TFT.foreground(Black);    // set chars to white
-    TFT.set_font((unsigned char*) Arial12x12);
+    TFT.background(BGCOLOR);    // set background to black
+    TFT.foreground(TEXTCOLOR);    // set chars to white
 
-    TFT.fillcircle(CLOCK_CENTER_X,CLOCK_CENTER_Y,CLOCK_RADIUS,0x0000);
-    TFT.fillcircle(CLOCK_CENTER_X,CLOCK_CENTER_Y,CLOCK_RADIUS-4,0xFFFF);
+    TFT.fillcircle(CLOCK_CENTER_X,CLOCK_CENTER_Y,CLOCK_RADIUS,TEXTCOLOR);
+    TFT.fillcircle(CLOCK_CENTER_X,CLOCK_CENTER_Y,CLOCK_RADIUS-4,BGCOLOR);
 
     /*
+        TFT.set_font((unsigned char*) Arial12x12);
         TFT.locate( CLOCK_CENTER_X - 8, CLOCK_CENTER_Y  - CLOCK_RADIUS + 6);
         printf("12");
         TFT.locate( CLOCK_CENTER_X - CLOCK_RADIUS + 6, CLOCK_CENTER_Y - 6);
@@ -548,73 +628,73 @@
     y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 16);
     x2 = CLOCK_CENTER_X + 1;
     y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6);
-    TFT.fillrect(x1,y1,x2,y2,0x0000);
+    TFT.fillrect(x1,y1,x2,y2,TEXTCOLOR);
 
     x1 = CLOCK_CENTER_X - 1;
     y1 = CLOCK_CENTER_Y - (CLOCK_RADIUS - 6);
     x2 = CLOCK_CENTER_X + 1;
     y2 = CLOCK_CENTER_Y - (CLOCK_RADIUS - 16);
-    TFT.fillrect(x1,y1,x2,y2,0x0000);
+    TFT.fillrect(x1,y1,x2,y2,TEXTCOLOR);
 
     x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 16);
     y1 = CLOCK_CENTER_Y - 1;
     x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6);
     y2 = CLOCK_CENTER_Y + 1;
-    TFT.fillrect(x1,y1,x2,y2,0x0000);
+    TFT.fillrect(x1,y1,x2,y2,TEXTCOLOR);
 
     x1 = CLOCK_CENTER_X - (CLOCK_RADIUS - 6);
     y1 = CLOCK_CENTER_Y - 1;
     x2 = CLOCK_CENTER_X - (CLOCK_RADIUS - 16);
     y2 = CLOCK_CENTER_Y + 1;
-    TFT.fillrect(x1,y1,x2,y2,0x0000);
+    TFT.fillrect(x1,y1,x2,y2,TEXTCOLOR);
 
     x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 30)/180);
     y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 30)/180);
     x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 30)/180);
     y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 30)/180);
-    TFT.line(x1,y1,x2,y2,0x0000);
+    TFT.line(x1,y1,x2,y2,TEXTCOLOR);
 
     x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 60)/180);
     y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 60)/180);
     x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 60)/180);
     y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 60)/180);
-    TFT.line(x1,y1,x2,y2,0x0000);
+    TFT.line(x1,y1,x2,y2,TEXTCOLOR);
 
     x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 120)/180);
     y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 120)/180);
     x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 120)/180);
     y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 120)/180);
-    TFT.line(x1,y1,x2,y2,0x0000);
+    TFT.line(x1,y1,x2,y2,TEXTCOLOR);
 
     x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 150)/180);
     y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 150)/180);
     x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 150)/180);
     y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 150)/180);
-    TFT.line(x1,y1,x2,y2,0x0000);
+    TFT.line(x1,y1,x2,y2,TEXTCOLOR);
 
     x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 210)/180);
     y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 210)/180);
     x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 210)/180);
     y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 210)/180);
-    TFT.line(x1,y1,x2,y2,0x0000);
+    TFT.line(x1,y1,x2,y2,TEXTCOLOR);
 
     x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 240)/180);
     y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 240)/180);
     x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 240)/180);
     y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 240)/180);
-    TFT.line(x1,y1,x2,y2,0x0000);
+    TFT.line(x1,y1,x2,y2,TEXTCOLOR);
 
     x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 300)/180);
     y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 300)/180);
     x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 300)/180);
     y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 300)/180);
-    TFT.line(x1,y1,x2,y2,0x0000);
+    TFT.line(x1,y1,x2,y2,TEXTCOLOR);
 
     x1 = CLOCK_CENTER_X + (CLOCK_RADIUS - 13) * sin(3.14 * ((double) 330)/180);
     y1 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 13) * cos(3.14 * ((double) 330)/180);
     x2 = CLOCK_CENTER_X + (CLOCK_RADIUS - 6) * sin(3.14 * ((double) 330)/180);
     y2 = CLOCK_CENTER_Y + (CLOCK_RADIUS - 6) * cos(3.14 * ((double) 330)/180);
-    TFT.line(x1,y1,x2,y2,0x0000);
+    TFT.line(x1,y1,x2,y2,TEXTCOLOR);
 
 }
 
diff -r 5c0b32a77708 -r 47de2d58ecc7 mbed.bld
--- a/mbed.bld	Sat May 17 22:59:43 2014 +0000
+++ b/mbed.bld	Sun Jun 01 13:21:48 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877
\ No newline at end of file