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.
Diff: Chirp.cpp
- Revision:
- 1:faff11456df9
- Parent:
- 0:6164b94deb27
diff -r 6164b94deb27 -r faff11456df9 Chirp.cpp
--- a/Chirp.cpp Thu Jan 12 22:01:43 2017 +0000
+++ b/Chirp.cpp Fri Jan 20 00:36:11 2017 +0000
@@ -6,10 +6,11 @@
Chirp::Chirp(PinName sda, PinName scl, char slave_adr)
:i2c_p(new I2C(sda, scl)), i2c(*i2c_p), address(slave_adr)
{
-
+ i2c.frequency(10000);
}
float Chirp::getCapacitance(){
+ i2c.frequency(10000);
short capacitance = 0;
char i2cData[2]= {0};
@@ -29,9 +30,11 @@
}
float Chirp::getTemperature(){
+ i2c.frequency(10000);
short temperature = 0;
char i2cData[2]= {0};
+
char dataReg = 5; //Temperature is stored in 2 bytes at address 5
i2c.write(address, &dataReg, 1);
int success = i2c.read(address, i2cData, 2);