ESTE MODULO FUNCIONA EN FRDM-KL25Z CON DISPLAY LCD 16X2

Dependencies:   MAX31855 TextLCD USBDevice mbed

Fork of LCD_FRDM_KL25Z by Gustavo Ramirez

Revision:
1:ac09ff440ce1
Parent:
0:a6771cc1a056
--- a/main.cpp	Tue Sep 03 16:16:26 2013 +0000
+++ b/main.cpp	Tue Aug 26 02:54:05 2014 +0000
@@ -1,11 +1,100 @@
-// Hello World! for the TextLCD
-// EJEMPLO CON UN LCD PARA EL MODULO FRDM-KL25Z
-
 #include "mbed.h"
 #include "TextLCD.h"
+#include "USBSerial.h"
+#include "max31855.h"
 
-TextLCD lcd(PTE0, PTE1, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7
+
+TextLCD lcd(PTA13, PTD5, PTA4, PTA5, PTC8, PTC9); // rs, e, d4-d7
+DigitalOut myled(LED1);
+
+ 
+//----------------------------------------------------------
+//SPI Interfaces
+SPI testSPI(PTD2,PTD3,PTD1);
+//----------------------------------------------------------
+// USBSerial serial;
+
+//----------------------------------------------------------
+//Thermocouples
+max31855 max1(testSPI, PTB18);
+//----------------------------------------------------------
+
 
 int main() {
-    lcd.printf("Hello World!\n");
-}
+    //Initialise chip (starts internal timer)
+    max1.initialise();
+    
+    //Float value to hold temperature returned
+    float fvalue = 0;
+ //----------------------------------------------------------- 
+    lcd.cls();
+          lcd.printf("Welcome\n");
+          myled = 0;
+          wait(2);
+         
+     
+        lcd.cls();
+       lcd.locate(0,0);
+     lcd.printf("Set temperaure\n");
+    // lcd.locate(0,0);
+    // lcd.printf("Current temp");
+       myled =!myled;
+        wait(2);
+       
+//---------------------------------------------------------------
+    while(1) 
+    {
+            //Check if the chip is ready for a reading to be taken
+            if (max1.ready()==1)
+            {
+                    //Get the reading
+                    fvalue = max1.read_temp();
+                    
+                    if (fvalue > 2000){
+                                        if(fvalue==2001){
+                                                        //printf("No TC");
+                                                          lcd.cls();
+                                                        lcd.locate(0,0);
+
+                                                        lcd.printf("NO tc");
+                                                        }
+                                        else if(fvalue==2002){
+                                                               // printf("Short to GND");
+                                                                 lcd.cls();
+                                                               lcd.locate(0,0);
+
+                                                               lcd.printf("short to GND"); 
+                                                             }
+                                             else if(fvalue==2004){
+                                                                       // printf("Short to VCC");
+                                                                          lcd.cls();
+                                                                        lcd.locate(0,0);
+
+                                                                       lcd.printf("short to VCC"); 
+                                                                  }
+                                      }
+                    else{
+                        // printf("Temperature is: %f\n\r", fvalue);
+                         //lcd.locate(6,0);
+                      //   lcd.printf((char*)fvalue);
+                                lcd.cls();
+                                 lcd.locate(0,0);
+                               lcd.printf("Current temp");
+                                lcd.locate(0,1);
+
+                         lcd.printf("T=%2.1fC",fvalue);
+                              
+                        // lcd.printf("T=%f\n\r",fvalue);
+
+
+                        }
+            }
+            
+            //Heartbeat signal (not necessary)
+            myled = !myled;
+            
+            //Delay is not required, here simply for test program
+            wait(0.25);
+    }
+
+}
\ No newline at end of file