V1.0

Dependencies:   mbed

Committer:
Kelrath1984
Date:
Tue Oct 06 16:57:27 2020 +0000
Revision:
2:bc5080fc7926
Parent:
1:e1a54bf8215a
Child:
3:5a3eedf8ad2d
V1.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kelrath1984 0:25699a99e08b 1 #include "mbed.h"
Kelrath1984 0:25699a99e08b 2
Kelrath1984 1:e1a54bf8215a 3 class MyClass1
Kelrath1984 1:e1a54bf8215a 4 {
Kelrath1984 1:e1a54bf8215a 5 public:
Kelrath1984 1:e1a54bf8215a 6 MyClass1() : m_messwert(0.0) {}
Kelrath1984 1:e1a54bf8215a 7 ~MyClass1() {}
Kelrath1984 1:e1a54bf8215a 8 double getMesswert()
Kelrath1984 1:e1a54bf8215a 9 {
Kelrath1984 1:e1a54bf8215a 10 return m_messwert;
Kelrath1984 1:e1a54bf8215a 11 }
Kelrath1984 1:e1a54bf8215a 12 private:
Kelrath1984 1:e1a54bf8215a 13 double m_messwert;
Kelrath1984 0:25699a99e08b 14 };
Kelrath1984 0:25699a99e08b 15
Kelrath1984 1:e1a54bf8215a 16 class I2CSensor
Kelrath1984 1:e1a54bf8215a 17 {
Kelrath1984 2:bc5080fc7926 18 private:
Kelrath1984 2:bc5080fc7926 19 char m_data[4];
Kelrath1984 1:e1a54bf8215a 20 public:
Kelrath1984 1:e1a54bf8215a 21 I2CSensor(PinName sda, PinName scl) : i2c(sda, scl) {}
Kelrath1984 1:e1a54bf8215a 22 ~I2CSensor() {}
Kelrath1984 2:bc5080fc7926 23 inline float read(uint8_t adress)
Kelrath1984 2:bc5080fc7926 24 {
Kelrath1984 2:bc5080fc7926 25 I2C.read(adress,m_data,4,false);
Kelrath1984 2:bc5080fc7926 26 return (float)m_data;
Kelrath1984 2:bc5080fc7926 27 };
Kelrath1984 1:e1a54bf8215a 28 private:
Kelrath1984 1:e1a54bf8215a 29 I2C i2c;
Kelrath1984 1:e1a54bf8215a 30
Kelrath1984 0:25699a99e08b 31 };
Kelrath1984 0:25699a99e08b 32
Kelrath1984 0:25699a99e08b 33
Kelrath1984 1:e1a54bf8215a 34 int main()
Kelrath1984 1:e1a54bf8215a 35 {
Kelrath1984 1:e1a54bf8215a 36
Kelrath1984 1:e1a54bf8215a 37
Kelrath1984 0:25699a99e08b 38
Kelrath1984 0:25699a99e08b 39 return 0;
Kelrath1984 0:25699a99e08b 40 }