cagdas d
/
_uebung_demirtas_06102020
first commit
MyClassB.h
- Committer:
- kafka
- Date:
- 2020-10-06
- Revision:
- 2:65f24e5a3ce4
File content as of revision 2:65f24e5a3ce4:
class MyClassB { public: MyClassB(PinName sda, PinName scl) : i2c(sda, scl) {}; // I2C Pins übergeben p28, p27 float read(); private: I2C i2c; }; float MyClassB::read() { const int addr = 0x90; char cmd[2]; i2c.write(addr, cmd, 2); wait(0.5); cmd[0] = 0x00; i2c.write(addr, cmd, 1); i2c.read(addr, cmd, 2); float tmp = (float((cmd[0]<<8)|cmd[1]) / 256.0); return tmp; }