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.
tHIH6130.cpp
00001 #include "tHIH6130.h" 00002 00003 tHIH6130::tHIH6130(unsigned char aAdrHIH,I2C* apI2c) 00004 { 00005 pI2c = apI2c; 00006 WrAdr = ((aAdrHIH)<<1) & 0xFE ; 00007 RdAdr = WrAdr | 0x01; 00008 00009 00010 } 00011 00012 00013 float tHIH6130::getTemp(void) 00014 { 00015 return Temp; 00016 } 00017 00018 00019 00020 float tHIH6130::getHumi(void) 00021 { 00022 return Humi; 00023 } 00024 00025 int tHIH6130::StartMesure(void) 00026 { 00027 int Res; 00028 pI2c->start(); 00029 Res = pI2c->write(WrAdr); 00030 pI2c->stop(); 00031 00032 return Res; 00033 } 00034 00035 int tHIH6130::UpdateData(void) 00036 { 00037 int Res; 00038 unsigned char Data[4]; 00039 unsigned int Tmp; 00040 00041 Res = pI2c->read(RdAdr,(char*)Data,4); 00042 00043 // MAJ Humidité 00044 Tmp = Data[0] & 0x3F; 00045 Tmp <<= 8; 00046 Tmp += Data[1]; 00047 00048 Humi = ((float)Tmp / (float)16383)*float(100); 00049 00050 00051 // MAJ Température 00052 Tmp = Data[2]; 00053 Tmp <<= 8; 00054 Tmp += (Data[3] & 0xFC); 00055 Tmp >>=2; 00056 00057 Temp = ((float)Tmp / (float)16383)*(float)165; 00058 Temp -= 40; 00059 00060 return Res; 00061 } 00062 00063 00064 00065 00066
Generated on Wed Jul 13 2022 19:52:43 by
1.7.2