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

Dependencies:   MAX31855 TextLCD USBDevice mbed

Fork of LCD_FRDM_KL25Z by Gustavo Ramirez

Files at this revision

API Documentation at this revision

Comitter:
EDCHEN
Date:
Tue Aug 26 02:54:05 2014 +0000
Parent:
0:a6771cc1a056
Commit message:
this program Reads data from thermocouple with max31855 and displays it on LCD

Changed in this revision

MAX31855.lib Show annotated file Show diff for this revision Revisions of this file
USBDevice.lib 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
diff -r a6771cc1a056 -r ac09ff440ce1 MAX31855.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MAX31855.lib	Tue Aug 26 02:54:05 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Stavlin/code/MAX31855/#5eeee89cb281
diff -r a6771cc1a056 -r ac09ff440ce1 USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Tue Aug 26 02:54:05 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/USBDevice/#335f2506f422
diff -r a6771cc1a056 -r ac09ff440ce1 main.cpp
--- 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