Codeschnippseln für diese Übung

Dependencies:   mbed

Committer:
Aagrus
Date:
Tue Oct 13 16:34:21 2020 +0000
Revision:
1:c65875995efb
Parent:
0:76d9c940a794
Child:
2:7a0bae2281e8
UPDATE: Hinzugefuegt -> Ueberladener Konstruktor

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Aagrus 0:76d9c940a794 1 #include "mbed.h"
Aagrus 1:c65875995efb 2 #include "class4.cpp"
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 1:c65875995efb 8 float _result;
Aagrus 0:76d9c940a794 9
Aagrus 0:76d9c940a794 10 public:
Aagrus 1:c65875995efb 11 MyClassB(I2C& i2cCopy) : i2c(i2cCopy)
Aagrus 1:c65875995efb 12 {
Aagrus 1:c65875995efb 13 //c = i2cCopy;
Aagrus 1:c65875995efb 14 _result = 0;
Aagrus 1:c65875995efb 15 }
Aagrus 0:76d9c940a794 16 MyClassB(PinName sda, PinName scl) : i2c(sda, scl)
Aagrus 0:76d9c940a794 17 {
Aagrus 1:c65875995efb 18 _result = 0;
Aagrus 0:76d9c940a794 19 }
Aagrus 1:c65875995efb 20
Aagrus 1:c65875995efb 21 float Read();
Aagrus 0:76d9c940a794 22 };
Aagrus 0:76d9c940a794 23
Aagrus 1:c65875995efb 24 float MyClassB::Read() { return _result; }
Aagrus 0:76d9c940a794 25
Aagrus 0:76d9c940a794 26
Aagrus 0:76d9c940a794 27
Aagrus 1:c65875995efb 28
Aagrus 1:c65875995efb 29
Aagrus 1:c65875995efb 30
Aagrus 1:c65875995efb 31 Serial pc(USBTX, USBRX);
Aagrus 1:c65875995efb 32 MyPrintClass printClass(&pc);
Aagrus 0:76d9c940a794 33
Aagrus 0:76d9c940a794 34 int main()
Aagrus 0:76d9c940a794 35 {
Aagrus 1:c65875995efb 36 int x[] = { 1, 4, 7, 3, 10, 20 };
Aagrus 1:c65875995efb 37 char s[] = "Hallo Welt!";
Aagrus 1:c65875995efb 38
Aagrus 1:c65875995efb 39 while (1)
Aagrus 1:c65875995efb 40 {
Aagrus 1:c65875995efb 41 printClass.PrintString(s, sizeof(s));
Aagrus 1:c65875995efb 42 printClass.PrintIntValues(68);
Aagrus 1:c65875995efb 43 printClass.PrintIntValues(x, sizeof(x) / sizeof(int));
Aagrus 1:c65875995efb 44
Aagrus 1:c65875995efb 45 wait(500);
Aagrus 1:c65875995efb 46 }
Aagrus 0:76d9c940a794 47 }