
V1.0
main.cpp@1:e1a54bf8215a, 2020-10-06 (annotated)
- Committer:
- Kelrath1984
- Date:
- Tue Oct 06 16:56:19 2020 +0000
- Revision:
- 1:e1a54bf8215a
- Parent:
- 0:25699a99e08b
- Child:
- 2:bc5080fc7926
V1.1;
Who changed what in which revision?
User | Revision | Line number | New 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 | 1:e1a54bf8215a | 18 | private |
Kelrath1984 | 1:e1a54bf8215a | 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 | 1:e1a54bf8215a | 23 | inline float read(uint8_t adress) {I2C.read(adress,m_data,4,false); return (float)m_data;}; |
Kelrath1984 | 1:e1a54bf8215a | 24 | private: |
Kelrath1984 | 1:e1a54bf8215a | 25 | I2C i2c; |
Kelrath1984 | 1:e1a54bf8215a | 26 | |
Kelrath1984 | 0:25699a99e08b | 27 | }; |
Kelrath1984 | 0:25699a99e08b | 28 | |
Kelrath1984 | 0:25699a99e08b | 29 | |
Kelrath1984 | 1:e1a54bf8215a | 30 | int main() |
Kelrath1984 | 1:e1a54bf8215a | 31 | { |
Kelrath1984 | 1:e1a54bf8215a | 32 | |
Kelrath1984 | 1:e1a54bf8215a | 33 | |
Kelrath1984 | 0:25699a99e08b | 34 | |
Kelrath1984 | 0:25699a99e08b | 35 | return 0; |
Kelrath1984 | 0:25699a99e08b | 36 | } |