Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MLX90614.h
00001 /* 00002 Copyright (c) 2016 Jens Strümper based on the work of Jonathan Jones. 00003 00004 Permission is hereby granted, free of charge, to any person obtaining a copy 00005 of this software and associated documentation files (the "Software"), to deal 00006 in the Software without restriction, including without limitation the rights 00007 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 copies of the Software, and to permit persons to whom the Software is 00009 furnished to do so, subject to the following conditions: 00010 00011 The above copyright notice and this permission notice shall be included in 00012 all copies or substantial portions of the Software. 00013 00014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 THE SOFTWARE. 00021 */ 00022 00023 #ifndef MLX90614_H 00024 #define MLX90614_H 00025 00026 #ifndef MBED_H 00027 #include "mbed.h" 00028 #endif 00029 00030 namespace js { 00031 00032 /** Due to changes in mbed's I2C stack older implementation of the MLX9064 library do currently not work. 00033 * This recent implementation wraps the example code of Jonathan Jones into a library. 00034 * 00035 * The float read_temp(int select) memeber function will take one argument: 00036 * <ul> 00037 * <li> "0" to return ambient temperature </li> 00038 * <li> "1" to retunr object temperature </li> 00039 * </ul> 00040 * 00041 * Example: 00042 * @code 00043 * #include "mbed.h" 00044 * #include "MLX90614.h" 00045 * 00046 * I2C i2c(p16, p17); //I2C_SDA, I2C_SCL 00047 * MLX90614 mlx90614(&i2c); 00048 * 00049 * float temp; 00050 * int select; // 0 = object temp, 1 = ambient temp 00051 * 00052 * int main(){ 00053 while(true){ 00054 temp=mlx90614.read_temp(1); 00055 printf("%4.2f Celcius\r\n", temp); 00056 wait(1); 00057 } 00058 } 00059 * @endcode 00060 */ 00061 00062 class MLX90614 { 00063 00064 public: 00065 00066 MLX90614(PinName sda, PinName scl); 00067 00068 MLX90614(I2C *i2c); 00069 00070 ~MLX90614(); 00071 00072 float read_temp(int select); 00073 00074 protected: 00075 00076 float get_temp(uint8_t reg); 00077 00078 private: 00079 00080 I2C *i2c_; 00081 00082 static const int default_addr = 0x00; 00083 static const int T_ambient = 0x06; 00084 static const int T_obj1 = 0x07; 00085 static const int ram_access = 0x00; 00086 00087 }; 00088 00089 } //namespace js 00090 00091 using namespace js; 00092 00093 #endif
Generated on Tue Jul 12 2022 15:22:03 by
1.7.2