Single and Dual Zone Infra Red Thermometer
Diff: MLX90614.h
- Revision:
- 3:6a5b6fcff28e
- Parent:
- 2:1d6817048eb1
- Child:
- 4:c5344a5f3266
--- a/MLX90614.h Tue Dec 26 10:09:48 2017 +0000 +++ b/MLX90614.h Tue Dec 26 11:07:58 2017 +0000 @@ -22,7 +22,55 @@ /** Example: -[TODO] +#include "mbed.h" +#include "MLX90614.h" + +MLX90614 myMLX90614 ( I2C_SDA, I2C_SCL, MLX90614::MLX90614_ADDRESS, 100000 ); +Serial pc ( USBTX, USBRX ); + +Ticker newReading; +DigitalOut myled(LED1); + +MLX90614::MLX90614_status_t aux; +MLX90614::MLX90614_vector_data_t myMLX90614Data; +uint8_t myState = 0; + + +void changeDATA ( void ) +{ + myState = 1; +} + + +int main() +{ + pc.baud ( 115200 ); + + // Get the IDs + aux = myMLX90614.MLX90614_GetID_Numbers ( &myMLX90614Data ); + pc.printf( "ID_0: %d\nID_1: %d\nID_2: %d\nID_3: %d\r\n", myMLX90614Data.ID[0], myMLX90614Data.ID[1], myMLX90614Data.ID[2], myMLX90614Data.ID[3] ); + + newReading.attach( &changeDATA, 1 ); // the address of the function to be attached ( changeDATA ) and the interval ( 1s ) + + // Let the callbacks take care of everything + while(1) { + sleep(); + + myled = 1; + + if ( myState == 1 ) { + // Get the data + aux = myMLX90614.MLX90614_ReadTA ( &myMLX90614Data ); + aux = myMLX90614.MLX90614_ReadTObj1 ( &myMLX90614Data ); + + pc.printf( "Ta: %0.2fC\nTObj1: %0.2fC\r\n", myMLX90614Data.TA, myMLX90614Data.TObj1 ); + + myState = 0; // Reset the variable + } + + myled = 0; + } +} */ @@ -195,51 +243,59 @@ /** It gets the ID numbers. */ - MLX90614_status_t MLX90614_GetID_Numbers ( MLX90614_vector_data_t* myID ); + MLX90614_status_t MLX90614_GetID_Numbers ( MLX90614_vector_data_t* myID ); /** It reads the raw ambient temperature. */ - MLX90614_status_t MLX90614_ReadRawTA ( MLX90614_vector_data_t* myRawTA ); + MLX90614_status_t MLX90614_ReadRawTA ( MLX90614_vector_data_t* myRawTA ); /** It reads the ambient temperature in Celsius degrees. */ - MLX90614_status_t MLX90614_ReadTA ( MLX90614_vector_data_t* myTA ); + MLX90614_status_t MLX90614_ReadTA ( MLX90614_vector_data_t* myTA ); /** It reads the raw object 1 temperature. */ - MLX90614_status_t MLX90614_ReadRawTObj1 ( MLX90614_vector_data_t* myRawTObj1 ); + MLX90614_status_t MLX90614_ReadRawTObj1 ( MLX90614_vector_data_t* myRawTObj1 ); /** It reads the object 1 temperature. */ - MLX90614_status_t MLX90614_ReadTObj1 ( MLX90614_vector_data_t* myObj1 ); + MLX90614_status_t MLX90614_ReadTObj1 ( MLX90614_vector_data_t* myObj1 ); /** It reads the raw object 2 temperature. */ - MLX90614_status_t MLX90614_ReadRawTObj2 ( MLX90614_vector_data_t* myRawTObj2 ); + MLX90614_status_t MLX90614_ReadRawTObj2 ( MLX90614_vector_data_t* myRawTObj2 ); /** It reads the object 2 temperature. */ - MLX90614_status_t MLX90614_ReadTObj2 ( MLX90614_vector_data_t* myObj2 ); + MLX90614_status_t MLX90614_ReadTObj2 ( MLX90614_vector_data_t* myObj2 ); /** It gets the Emissivity correction coefficient. */ - MLX90614_status_t MLX90614_GetEmissivity ( MLX90614_vector_data_t* myEmissivity ); + MLX90614_status_t MLX90614_GetEmissivity ( MLX90614_vector_data_t* myEmissivity ); /** It sets the Emissivity correction coefficient. */ - MLX90614_status_t MLX90614_SetEmissivity ( MLX90614_vector_data_t myEmissivity ); + MLX90614_status_t MLX90614_SetEmissivity ( MLX90614_vector_data_t myEmissivity ); /** It gets the IIR. */ - MLX90614_status_t MLX90614_GetIIR ( MLX90614_vector_data_t* myIIR ); + MLX90614_status_t MLX90614_GetIIR ( MLX90614_vector_data_t* myIIR ); /** It sets the IIR. */ - MLX90614_status_t MLX90614_SetIIR ( MLX90614_configregister1_iir_t myIIR ); + MLX90614_status_t MLX90614_SetIIR ( MLX90614_configregister1_iir_t myIIR ); + + /** It gets the Temperature Source. + */ + MLX90614_status_t MLX90614_GetTemperatureSource ( MLX90614_vector_data_t* myTempSource ); + + /** It sets the Temperature Source. + */ + MLX90614_status_t MLX90614_SetTemperatureSource ( MLX90614_configregister1_temp_t myTempSource ); /** It gets the FLAGS. */ - MLX90614_status_t MLX90614_GetFLAGS ( MLX90614_vector_data_t* myFlags ); + MLX90614_status_t MLX90614_GetFLAGS ( MLX90614_vector_data_t* myFlags );