Michael Planner
/
InitListen
Codeschnippseln für diese Übung
main.cpp@0:76d9c940a794, 2020-10-06 (annotated)
- Committer:
- Aagrus
- Date:
- Tue Oct 06 16:36:31 2020 +0000
- Revision:
- 0:76d9c940a794
- Child:
- 1:c65875995efb
Uebung 1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Aagrus | 0:76d9c940a794 | 1 | #include "mbed.h" |
Aagrus | 0:76d9c940a794 | 2 | |
Aagrus | 0:76d9c940a794 | 3 | |
Aagrus | 0:76d9c940a794 | 4 | class MyClassB |
Aagrus | 0:76d9c940a794 | 5 | { |
Aagrus | 0:76d9c940a794 | 6 | private: |
Aagrus | 0:76d9c940a794 | 7 | I2C i2c; |
Aagrus | 0:76d9c940a794 | 8 | float result; |
Aagrus | 0:76d9c940a794 | 9 | |
Aagrus | 0:76d9c940a794 | 10 | public: |
Aagrus | 0:76d9c940a794 | 11 | MyClassB(PinName sda, PinName scl) : i2c(sda, scl) |
Aagrus | 0:76d9c940a794 | 12 | { |
Aagrus | 0:76d9c940a794 | 13 | result = 0; |
Aagrus | 0:76d9c940a794 | 14 | } |
Aagrus | 0:76d9c940a794 | 15 | float read(); |
Aagrus | 0:76d9c940a794 | 16 | }; |
Aagrus | 0:76d9c940a794 | 17 | |
Aagrus | 0:76d9c940a794 | 18 | float MyClassB::read() { return result; } |
Aagrus | 0:76d9c940a794 | 19 | |
Aagrus | 0:76d9c940a794 | 20 | |
Aagrus | 0:76d9c940a794 | 21 | |
Aagrus | 0:76d9c940a794 | 22 | MyClassB sensor(p28, p27); |
Aagrus | 0:76d9c940a794 | 23 | |
Aagrus | 0:76d9c940a794 | 24 | int main() |
Aagrus | 0:76d9c940a794 | 25 | { |
Aagrus | 0:76d9c940a794 | 26 | float x = sensor.read(); |
Aagrus | 0:76d9c940a794 | 27 | } |