Example program using the MLX90620 and KL25Z. Best viewed with wide-screen VT-100 color terminal. Tested with Tera Term. Easy i2c pin name change for mbed1768.

Dependencies:   MLX9062x PrintBuffer mbed

KL25Z_MLX90620 home page:

This program takes temperature data from the MLX90620 and displays the temperature data in the same format as the 16x4 pixel array. The display is updated once a second. Temperature can be displayed in degrees C or F and changed on the fly. Also, the data pixel format can be swapped. If the MLX90620 is pointing inward (toward you) or outward (away from you) you can change that on the fly as well. For each display output, the coolest pixel is displayed in BLUE and the warmest pixel in RED. The new data is painted over the old data.

NOTE: This program relys heavily on the mbed's USB Serial communication. ASCII ESCape codes are used. Use a terminal emulator like Tera Term. Be sure that the terminal has a wide screen (136 characters wide), with VT100 color emulation enabled and an even spaced character font like "Terminal".

The maximum USB serial communication you can use on the mbed1768 is 921600 baud. The KL25Z is limited to 115200 baud. Faster speeds cause characters drop out.

If you get bored, you can watch the RGB led on the KL25Z change color. Since the LED does not blend colors well, put a small piece of kleenex or a single layer from a napkin over the LED. You'll have a much better appreciation for the LED that way. Thanks to David Dicarlo's FRDM_RGBLED program for that idea.

Typical output from program:

/media/uploads/loopsva/mlx90620output.jpg

...kevin

Revision:
2:1f1157f04539
Parent:
1:9d7894633924
--- a/main.cpp	Thu Aug 01 18:37:35 2013 +0000
+++ b/main.cpp	Fri Jul 22 00:18:09 2016 +0000
@@ -2,6 +2,8 @@
 #include "PrintBuffer.h"
 #include "MLX90620.h"
 
+int revision = 110;
+
 #define BS          0x08                    //ascii backspace
 #define CR          0x0d                    //ascii CR
 #define LF          0x0a                    //ascii LF
@@ -11,16 +13,55 @@
 #define ticC        0x03                    //ascii control C
 #define ticX        0x18                    //ascii control X
 
-extern "C" void mbed_reset();
-int revision = 102;
+#define DOBLACK     "\033[0;30;2m"
+#define DORED       "\033[0;31;2m"
+#define DOGREEN     "\033[0;32;2m"
+#define DOYELLOW    "\033[0;33;2m"
+#define DOBLUE      "\033[0;34;2m"
+#define DOMAGENTA   "\033[0;35;2m"
+#define DOCYAN      "\033[0;36;2m"
+#define DOWHITE     "\033[0;37;2m"
+#define DODEFAULT   "\033[0;39;2m"
+#define DONONE      "\033[0m"
+
+char *doBLACK   = DOBLACK;
+char *doRED     = DORED;
+char *doGREEN   = DOGREEN;
+char *doYELLOW  = DOYELLOW;
+char *doBLUE    = DOBLUE;
+char *doMAGENTA = DOMAGENTA;
+char *doCYAN    = DOCYAN;
+char *doWHITE   = DOWHITE;
+char *doDEFAULT = DODEFAULT;
+char *doNONE    = DONONE;
+
+
+#if defined(TARGET_KL25Z)
+extern "C" void NVIC_SystemReset();         //for KL25Z
+#else
+#include "FATFileSystem.h" 
+extern "C" void mbed_reset();               //for mbed1768
+#endif
+
 int gDebug = 2;
 
 Serial pc (USBTX, USBRX);
+
+#if defined(TARGET_KL25Z)
 I2C i2c1(PTE0, PTE1); 
-I2C i2c2(PTE25, PTE24); 
-MLX90620 mlx(PTE0, PTE1, "mlx");            //MLX90620 register access
+I2C i2c2(PTE25, PTE24);
+//MLX90620 mlx(PTE0, PTE1, "mlx");            //MLX90620 register access
+MLX9062x mlx(PTE0, PTE1, MLX9062x::mlx90621, "mlx"); //MLX90620 or MLX90621 IR array
+MLX9062x::mlx_struct mlxSTR = {};               //data structure for MLX90260
+#else 
+LocalFileSystem local("local");             //for access of files on mbed itself
+I2C i2c1(p9, p10); 
+MLX90620 mlx(p9, p10, "mlx");
+#endif
+
 PrintBuffer pb("pb");                       //new for 132.  Moved PrintBuffer off to .cpp and .h files
 
+#if defined(TARGET_KL25Z)
 PwmOut rled(LED_RED);
 PwmOut gled(LED_GREEN);
 PwmOut bled(LED_BLUE);
@@ -34,6 +75,7 @@
 int bLedDelay = 0;
 float bLedPwm = 0.01;                       //LED1 brightness
 bool bLedUp = true;                         //LED1 auto up-down
+#endif
 
 //MLX90620 buffers used by MLX90620.cpp
 char* EEbuf = new char[256];
@@ -69,12 +111,14 @@
 float hiEnd = 100.0;                        //***USED BY .INI FILE  top end of color temperature scale (red end)
 int PutOnPC = 1;                            //***USED BY .INI FILE  display temperature array on PC  0 or 1.  Requires VT100 terminal operation
 
+//USB Serial Port Support
 const int PCRXBUFSIZE = 128;                //pc RX buffer size
 char pcRxBuffer[PCRXBUFSIZE];               //RX data buffer
 volatile int pcRxQty = 0;                   //RX data counter/pointer
 volatile char inchar = 0;                   //RX input character
 volatile bool LocalEcho = false;            //whether or not, to local echo input chars from pc
 volatile bool pcRxLine = false;             //CR or LF detected in RX buffer
+volatile bool pcRxTicC = false;             //^C detected in RX buffer
 volatile bool pcRxEOB = false;              //RX buffer EOB (full)
 volatile bool pcRxIsNumb = false;           //whether or not string is a valid number (including dp)
 volatile double pcRxNumb = 0.0;             //RX buffer comversion
@@ -82,8 +126,27 @@
 int pcRxIRQCnt = 0;                         //total number of pc RX interrupts received since boot
 
 //--------------------------------------------------------------------------------------------------------------------------------------//
+// Checks to see if a ^C happend.  reboot if so...
+
+void PcChekTicC() {
+    if(pcRxTicC == true) {
+        pc.printf("\n\n%s*** Control C detected, Resetting ***%s \n", doRED, doNONE);
+//        i2c1.stop();
+        wait_ms(200);
+
+#if defined(TARGET_KL25Z)
+        NVIC_SystemReset();
+#else
+        mbed_reset();
+#endif
+    }
+}
+
+//--------------------------------------------------------------------------------------------------------------------------------------//
 // This function is called when a character goes into the RX buffer.
 
+int TicC2 = 0;
+
 void PcRxChar() {
     pcRxCharCnt++;
     if(inchar == BS) { 
@@ -96,11 +159,22 @@
     } else if((inchar == CR) || (inchar == LF)) { 
         pcRxLine = true;
         if(LocalEcho) pc.printf("\n");
+    } else if(inchar == ticC) {
+        pcRxTicC = true;
+        TicC2++;
+        if(TicC2 > 2) {
+            wait_ms(200);
+            pc.printf("\n\n%s*** Control C detected, Resetting %sfrom IRQ!!!%s***%s \n", doRED, doGREEN, doRED, doNONE);
+            wait_ms(200);
+            i2c1.stop();
 
-// no s/w reset in the KL25Z mbed.
-//    } else if(inchar == ticC) {
-//        pc.printf("\n\n*** Control C detected, Resetting ***\n");
-//        mbed_reset();
+#if defined(TARGET_KL25Z)
+            NVIC_SystemReset();
+#else
+            mbed_reset();
+#endif
+
+        }
     } else if((inchar == 'C') || (inchar == 'c')) { 
         TempC = inchar;
     } else if((inchar == 'F') || (inchar == 'f')) { 
@@ -112,7 +186,8 @@
     } else {
         if(pcRxQty < sizeof(pcRxBuffer)) {
             pcRxBuffer[pcRxQty] = inchar;
-            pcRxQty++; 
+//            pcRxQty++;    //NOTE: no buffer needed for this code, don't inc char pointer
+            pcRxBuffer[pcRxQty] = 0;
             if(LocalEcho) pc.putc(inchar);
         } else {
             pc.printf ("\n*** pcRxBuffer is full!!\n");
@@ -147,15 +222,96 @@
 
 void PcRxIRQ(void){
     pcRxIRQCnt++;
-//    LPC_UART0->IER = 0;                     //Disable Rx interrupt
+#if defined(TARGET_KL25Z)
+    NVIC_DisableIRQ(UART0_IRQn);        // n=0, 1 or 2  Disable Rx interrupt on kl25z
+#else
+    LPC_UART0->IER = 0;                 //Disable Rx interrupt on mbed1768
+#endif
     while (pc.readable()) {
         inchar = pc.getc();             //read data from USB
         PcRxChar();                     //go process char
     }
-//    LPC_UART0->IER = 1;                 //re-enable Rx interrupt
+#if defined(TARGET_KL25Z)
+    NVIC_EnableIRQ(UART0_IRQn);         //re-enable Rx interrupt on kl25z
+#else
+    LPC_UART0->IER = 1;                 //re-enable Rx interrupt on mbed1768
+#endif
+}
+
+//--------------------------------------------------------------------------------------------------------------------------------------//
+//fixing a screwup on the eeprom from an accidental write
+
+void FixEEP() {    
+    EEbuf[0] = 0x10;               //starting address of EEP to write to, pages 0 - 31 * 8
+    EEbuf[1] = 0xed;
+    EEbuf[2] = 0xee;
+    EEbuf[3] = 0xee;
+    EEbuf[4] = 0xec;
+    EEbuf[5] = 0xee;
+    EEbuf[6] = 0xef; 
+    EEbuf[7] = 0xef; 
+    EEbuf[8] = 0xed; 
+    i2c1.write(0xa0, EEbuf, 9, false);
+    wait_ms(6);                 //datasheet says 5mS max
+
 }
 
 //--------------------------------------------------------------------------------------------------------------------------------------//
+//Reload EEPROM image from file /local/EEP.CSV
+
+#if defined(TARGET_KL25Z)
+#else
+char* FileBuf = new char[1024];
+char tbuf[256];
+
+int ReloadEEP() {
+    FILE *fps = fopen("/local/EEP.CSV", "r");
+    if (fps == NULL) {
+        return(0);
+    } else {
+        for(int i = 0; i < 256; i++) {
+            int x = -1;
+            do{
+                x++;
+                FileBuf[x] = fgetc(fps);
+                if(FileBuf[x] == '\n') {
+                    x--;
+                }
+            } while((FileBuf[x] != ','));
+            x--;
+            tbuf[i] = char(strtod(FileBuf, &FileBuf));
+            EEbuf[i] = tbuf[i];
+        }
+        fclose(fps);
+        return(1);
+    } 
+}
+
+//--------------------------------------------------------------------------------------------------------------------------------------//
+//re-write all of the MLX EEPROM from file EEP.CSV. Returns 0, no write error. 1 - 32 for failed page
+//tbuf contains the source data.  ReloadEEP() must be run first!!!
+
+int FixAllEEP() {
+    for(int i = 0; i < 32; i++) {           //32, 8 byte pages 
+        EEbuf[0] = i * 8;                   //EEPROM page #
+        EEbuf[1] = tbuf[i * 8];
+        EEbuf[2] = tbuf[i * 8 + 1];
+        EEbuf[3] = tbuf[i * 8 + 2];
+        EEbuf[4] = tbuf[i * 8 + 3];
+        EEbuf[5] = tbuf[i * 8 + 4];
+        EEbuf[6] = tbuf[i * 8 + 5]; 
+        EEbuf[7] = tbuf[i * 8 + 6]; 
+        EEbuf[8] = tbuf[i * 8 + 7]; 
+        if(!(i2c1.write(0xa0, EEbuf, 9, false))) {  //store 8 byte page
+            i2c1.stop();
+        }
+        wait_ms(10);                        //datasheet says 5mS max
+    }
+    return(0);
+}
+#endif
+
+//--------------------------------------------------------------------------------------------------------------------------------------//
 //Detect I2C device chain
 
 int i2cQty = 16;                            //number of bytes to get
@@ -179,7 +335,7 @@
 }
 
 //---------
-
+#if defined(TARGET_KL25Z)
 void find_i2c2() {
     if(gDebug > 1) pc.printf("Searching for I2C devices on bus 2...\n");
 
@@ -198,90 +354,6 @@
 }
 
 //--------------------------------------------------------------------------------------------------------------------------------------//
-// Slowly rise and lower red LED's brightness
-
-const float ALLLEDSTEPS = 21.0;
-
-const float RLEDMAX = 0.150;
-const float RLEDSTEP = (RLEDMAX / ALLLEDSTEPS);
-
-void rWinkLed() {
-    rLedDelay++;
-    if(rLedDelay >= 1) {
-        rLedDelay = 0;
-        if(rLedUp == true) {
-            rLedPwm = rLedPwm + RLEDSTEP;
-            if(rLedPwm > RLEDMAX) {
-                rLedUp = false;
-                rLedPwm = RLEDMAX;
-            }
-        } else {
-            rLedPwm = rLedPwm - RLEDSTEP;
-            if(rLedPwm < RLEDSTEP) {
-                rLedUp = true;
-                rLedPwm = 0.001;
-            }
-        }
-        rled = 1.0 - rLedPwm;
-    }
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-// Slowly rise and lower green LED's brightness
-
-const float GLEDMAX = 0.970;
-const float GLEDSTEP = (GLEDMAX / ALLLEDSTEPS);
-
-void gWinkLed() {
-    gLedDelay++;
-    if(gLedDelay >= 1) {
-        gLedDelay = 0;
-        if(gLedUp == true) {
-            gLedPwm = gLedPwm + GLEDSTEP;
-            if(gLedPwm > GLEDMAX) {
-                gLedUp = false;
-                gLedPwm = GLEDMAX;
-            }
-        } else {
-            gLedPwm = gLedPwm - GLEDSTEP;
-            if(gLedPwm < GLEDSTEP) {
-                gLedUp = true;
-                gLedPwm = 0.001;
-            }
-        }
-        gled = 1.0 - gLedPwm;
-    }
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
-// Slowly rise and lower blue LED's brightness
-
-const float BLEDMAX = 0.500;
-const float BLEDSTEP = (BLEDMAX / ALLLEDSTEPS);
-
-void bWinkLed() {
-    bLedDelay++;
-//    pc.printf("%c%c%c%c%c%c%5.3f ", BS, BS, BS, BS, BS, BS, bLedPwm);
-    if(bLedDelay >= 1) {
-        bLedDelay = 0;
-        if(bLedUp == true) {
-            bLedPwm = bLedPwm + BLEDSTEP;
-            if(bLedPwm > BLEDMAX) {
-                bLedUp = false;
-                bLedPwm = BLEDMAX;
-            }
-        } else {
-            bLedPwm = bLedPwm - BLEDSTEP;
-            if(bLedPwm < BLEDSTEP) {
-                bLedUp = true;
-                bLedPwm = 0.001;
-            }
-        }
-        bled = 1.0 - bLedPwm;
-    }
-}
-
-//--------------------------------------------------------------------------------------------------------------------------------------//
 // moving RGB LED display.  Hacked from:  david dicarlo / FRDM_RGBLED
 
 const float pi = 3.1415927;
@@ -298,6 +370,7 @@
     bled = bLedPwm;
 }
 
+#endif
 //--------------------------------------------------------------------------------------------------------------------------------------//
 // See if new temperature in array is higher then the current hottest or colder then the current coldest
 
@@ -340,7 +413,7 @@
 // Pick a pixel to print out temperature. X = column 0 - 15, Y = row 0 - 3
 
 void PickaPixel(int pX, int pY) {
-    TempPxl = mlx.CalcPixel(pX + pY);
+    TempPxl = mlx.CalcPixel(mlxSTR, pX + pY);
     if ((TempC == 'c') || (TempC == 'C')) {  
         pc.printf("Pixel X:%d  Y:%d  Temp: %.2f degC\n", pX / 4, pY, TempPxl);
     } else {
@@ -368,7 +441,7 @@
         pc.printf("%c[8;30m%c[6AArray Temperature  deg%c         \\\\ ^ // \n   F       E       D       C       B       A       9       8       7       6       5       4       3       2       1       0        \n", ESC, ESC, (TempC & 0x5f));
         for(pixY = 0; pixY <= 3; pixY++) {
             for(pixX = 60; pixX >= 0; pixX = pixX - 4) {
-                TempPxl = mlx.CalcPixel(pixX + pixY);
+                TempPxl = mlx.CalcPixel(mlxSTR, pixX + pixY);
                 if ((TempC == 'c') || (TempC == 'C')) {  
                     HoldTemp = TempPxl;
                 } else {
@@ -398,7 +471,7 @@
         pc.printf("%c[8;30m%c[6AArray Temperature  deg%c         // v \\\\ \n   0       1       2       3       4       5       6       7       8       9       A       B       C       D       E       F        \n", ESC, ESC, (TempC & 0x5f));
         for(pixY = 0; pixY <= 3; pixY++) { 
             for(pixX = 0; pixX < 64; pixX = pixX + 4) {
-                TempPxl = mlx.CalcPixel(pixX + pixY);
+                TempPxl = mlx.CalcPixel(mlxSTR, pixX + pixY);
                 if ((TempC == 'c') || (TempC == 'C')) {  
                     HoldTemp = TempPxl;
                 } else {
@@ -433,17 +506,31 @@
 bool FirstRamDump = true;
 
 int ShowTempsColor() {
-    ConfigReg = mlx.GetConfigReg();
+//    ConfigReg = mlx.GetConfigReg();
+    
+    //because of change to normal mode...
+    ConfigReg = 0;
+    wait_ms(185);   //balance out to display is about once per second
+    //end of because of change
+
+/*
+#ifdef MLX_KL25Z
+    NVIC_DisableIRQ(UART0_IRQn);        // n=0, 1 or 2  Disable Rx interrupt on kl25z
+#else
+    LPC_UART0->IER = 0;                 //Disable Rx interrupt on mbed1768
+#endif
+*/    
     if(GotAmbient == false) {
-        if((ConfigReg & 0x0100) == 0) {
-            Ta = mlx.GetDieTemp();
+        if((ConfigReg & MLX_TAMEASFLAG) == 0) {
+            mlx.CalcTa_To(mlxSTR);
+            Ta = mlx.GetDieTemp(mlxSTR);
 //            pc.printf("Ta = %f\n\n\n\n\n\n\n", Ta);
             GotAmbient = true;
         } else {
-            return(ConfigReg & 0x0100);
+            return(ConfigReg & MLX_TAMEASFLAG);
         }
     }
-    if((ConfigReg & 0x0200) == 0) {
+    if((ConfigReg & MLX_IRMEASFLAG) == 0) {
         loop++;
         GotAmbient = false;
         if(ReFrame == true) {
@@ -453,7 +540,7 @@
         AllowVT100++;
         HotPxl = -40.0;
         ColdPxl = 200.0;
-        mlx.LoadMLXRam();
+        mlx.LoadMLXRam(mlxSTR);
         if((gDebug > 1) && (FirstRamDump == true)) {
             FirstRamDump = false;
             pc.printf("First RAM dump");
@@ -469,7 +556,14 @@
         
         tX = TTX;
         tY = TTY;
-        mlx.StartMeasurement();
+        mlx.StartMeasurement(mlxSTR);
+/*        
+#ifdef MLX_KL25Z
+        NVIC_EnableIRQ(UART0_IRQn);         //re-enable Rx interrupt on kl25z
+#else
+        LPC_UART0->IER = 1;                 //re-enable Rx interrupt on mbed1768
+#endif
+*/   
         if(gDebug > 3) pc.printf("Array Temperature degC\n  3      2      1      0\n");
         if(SensFacingAway == 1) {
             for(pixX = 60; pixX >= 0; pixX = pixX - 4) {
@@ -480,7 +574,7 @@
                     } else {
                         PickPix = false;
                     }
-                    TempPxl = mlx.CalcPixel(pixX + pixY);
+                    TempPxl = mlx.CalcPixel(mlxSTR, pixX + pixY);
                     CheckNewExtreme();
                     if(gDebug > 3) pc.printf("%4.2f  ", TempPxl);
                 }
@@ -495,7 +589,7 @@
                     } else {
                         PickPix = false;
                     }
-                    TempPxl = mlx.CalcPixel(pixX + pixY);
+                    TempPxl = mlx.CalcPixel(mlxSTR, pixX + pixY);
                     CheckNewExtreme();
                     if(gDebug > 3) pc.printf("%4.2f  ", TempPxl);
                 }
@@ -511,44 +605,61 @@
 //--------------------------------------------------------------------------------------------------------------------------------------//
 
 int main(void) {
+    GotAmbient = false;
+    i2c1.frequency(400000);                  //set up i2c speed
+    i2c1.stop();
+    
+#if defined(TARGET_KL25Z)
+    i2c2.frequency(400000);                  //set up i2c speed
+    i2c2.stop();
     rled.period_us(1000);
     gled.period_us(1000);
     bled.period_us(1000);
     gLedUp = false;
     rLedPwm = 0.001;
-    gLedPwm = GLEDSTEP * 14.0;
-    bLedPwm = BLEDSTEP * 14.0;
+    gLedPwm = 0.700;
+    bLedPwm = 0.300;
     rled = 1.0 - rLedPwm;
     gled = 1.0 - gLedPwm;
     bled = 1.0 - bLedPwm; 
     pc.baud(115200);
-    GotAmbient = false;
-    i2c1.frequency(400000);                  //set up i2c speed
-    i2c1.stop();
+#else
+    pc.baud(921600);
+#endif
+
     pc.printf("\n\n--------------------------------------------\n");
-    pc.printf("FRDM-KL25Z  MLX90620 Tests  v%d\n", revision);
+    pc.printf("mbed1768 / FRDM-KL25Z  MLX90620 Tests  %sv%d%s\n", doBLUE, revision, doNONE);
     
     //initialize the USB serial port interrupt
     pc.printf("Initializing Serial Port Rx Interrupt...   \n");
     pc.attach(&PcRxIRQ, pc.RxIrq);
     
+    //look for devices on i2c buses
     find_i2c1();
+
+#if defined(TARGET_KL25Z)
     find_i2c2();
-/*    
+#else
+    //mbed1768 only, see if MLX90620 eeprom contents file saved.  If so, dump on display
     if (ReloadEEP()) {
         if(gDebug > 1) {
-            pc.printf("\nCVS file dump");
-            pb.dump(16, 0, EEbuf);
+            pb.dump("\nEEP.CVS file dump", 16, 0,tbuf);
         }
-//    } else {
-//        pc.printf("*** file /local/EEP.CSV does not exist\n");
+    } else {
+        pc.printf("*** file /local/EEP.CSV does not exist\n");
     }
-        
-//    FixEEP();
-*/
+#endif
+
+    //DANGEROUS!!!  FixEEP is for fixing small portions of the EEPROM on the MLX90620.
+    //Fixes 8 bytes in EEPROM at a time.  This is a manual operation, requiring a recompile each
+    //time.  You have to set up the starting EEP address and 8 bytes of data to be written
+    //in routine FixEEP
+    
+    //FixEEP();
+
     int initFail = 0;
     //load up eeprom into buffer
-    if((mlx.LoadEEPROM())) {
+    if((mlx.LoadEEPROM(mlxSTR))) {
         pc.printf("*** MLX90620 dump failed!!!\n");
         initFail++;
     } else {   
@@ -560,25 +671,25 @@
     
     //Init MLX90620
     unsigned short x = 0;
-    if((mlx.SetOscTrimReg())) {
+    if((mlx.SetOscTrimReg(mlxSTR))) {
         pc.printf("*** set osc trim failed!!!\n");
         initFail++;
     } else {
-        x = mlx.GetOscTrimReg();
+        x = mlx.GetOscTrimReg(mlxSTR);
         pc.printf("Osc Trim Value:  0x%04x\n", x);
     }
     
-    if((mlx.SetConfigReg())) {
+    if((mlx.SetConfigReg(mlxSTR))) {
         pc.printf("*** set MLX config failed!!!\n");
         initFail++;
     } else {
-        x = mlx.GetConfigReg();
+        x = mlx.GetConfigReg(mlxSTR);
         pc.printf("Config Register: 0x%04x\n", x);
-        x = mlx.GetPTATReg();
+        x = mlx.GetPTATReg(mlxSTR);
         pc.printf("PTAT Register:   0x%04x\n", x);
     }
     
-    if((mlx.StartMeasurement())) {
+    if((mlx.StartMeasurement(mlxSTR))) {
         pc.printf("*** Start Measurement failed!!!\n");
         initFail++;
     }
@@ -586,23 +697,22 @@
     
     if(initFail == 0) {
         pc.printf("Calculating Ta...\n");
-        mlx.CalcTa_To();
+        mlx.CalcTa_To(mlxSTR);
         pc.printf("Getting die temperature...\n");
-        Ta = mlx.GetDieTemp();
+        Ta = mlx.GetDieTemp(mlxSTR);
         pc.printf("Ta = %f\n\n", Ta);
     } else {
         pc.printf("*** MLX90620 non operational!!!\n");
     }
     ShowTempsColor();
-    //no s/w reset on KL25Z mbed
-    //pc.printf("At any time, type:\n O = Pointing Outward\n I = Pointing Inward\n C = Temp Degrees C\n F = Temp Degrees F\n^C = reboot\n\n");
-    pc.printf("At any time, type:\n O = Pointing Outward\n I = Pointing Inward\n C = Temp Degrees C\n F = Temp Degrees F\n\n");
+
+    pc.printf("At any time, type:\n %sO%s = Pointing Outward\n %sI%s = Pointing Inward\n %sC%s = Temp Degrees C\n %sF%s = Temp Degrees F\n%s^C%s = reboot\n\n",
+                doGREEN, doNONE, doGREEN, doNONE, doGREEN, doNONE, doGREEN, doNONE, doRED, doNONE);
     pc.printf("Ready...\n");
     pc.printf("\n\n\n\n\n\n\n");
     
     while (true) {
-
-        
+        PcChekTicC();
         int lc = 0;
         if(!(ShowTempsColor())) {
             do {
@@ -610,18 +720,16 @@
                 //pc.printf("waiting... %d\n", lc);
                 wait_ms(1);
             } while(ShowTempsColor() != 0);
-            //rWinkLed();
-            //gWinkLed();
-            //bWinkLed();
+
+#if defined(TARGET_KL25Z)
             sinLEDs();
-            if(gDebug > 2) {
-                pc.printf("rls: %f   rlw: %f\n", RLEDSTEP, rLedPwm);
-                pc.printf("gls: %f   glw: %f\n", GLEDSTEP, gLedPwm);
-                pc.printf("bls: %f   blw: %f\n\n", BLEDSTEP, bLedPwm);
-            }
+#endif
+
         }
         if(PutOnPC == 1) {
             ShowTempsVT100();
         }
     }
 }
+
+