Michael Planner
/
InitListen
Codeschnippseln für diese Übung
class4.cpp@1:c65875995efb, 2020-10-13 (annotated)
- Committer:
- Aagrus
- Date:
- Tue Oct 13 16:34:21 2020 +0000
- Revision:
- 1:c65875995efb
- Child:
- 2:7a0bae2281e8
UPDATE: Hinzugefuegt -> Ueberladener Konstruktor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Aagrus | 1:c65875995efb | 1 | #include "mbed.h" |
Aagrus | 1:c65875995efb | 2 | |
Aagrus | 1:c65875995efb | 3 | |
Aagrus | 1:c65875995efb | 4 | class MyPrintClass |
Aagrus | 1:c65875995efb | 5 | { |
Aagrus | 1:c65875995efb | 6 | private: |
Aagrus | 1:c65875995efb | 7 | Serial* pc; |
Aagrus | 1:c65875995efb | 8 | |
Aagrus | 1:c65875995efb | 9 | public: |
Aagrus | 1:c65875995efb | 10 | MyPrintClass(Serial* serial) : pc(serial) |
Aagrus | 1:c65875995efb | 11 | { |
Aagrus | 1:c65875995efb | 12 | |
Aagrus | 1:c65875995efb | 13 | } |
Aagrus | 1:c65875995efb | 14 | |
Aagrus | 1:c65875995efb | 15 | |
Aagrus | 1:c65875995efb | 16 | void PrintIntValues(int value) |
Aagrus | 1:c65875995efb | 17 | { |
Aagrus | 1:c65875995efb | 18 | pc->printf("Int-Wert: %d\n", value); |
Aagrus | 1:c65875995efb | 19 | } |
Aagrus | 1:c65875995efb | 20 | void PrintIntValues(int *values, int count) |
Aagrus | 1:c65875995efb | 21 | { |
Aagrus | 1:c65875995efb | 22 | pc->printf("Auflistung der %d Messwerte:\n", count); |
Aagrus | 1:c65875995efb | 23 | |
Aagrus | 1:c65875995efb | 24 | for (int i = 0; i < count; i++) |
Aagrus | 1:c65875995efb | 25 | { |
Aagrus | 1:c65875995efb | 26 | pc->printf("[%d] -> %d\n", i, values[i]); |
Aagrus | 1:c65875995efb | 27 | } |
Aagrus | 1:c65875995efb | 28 | |
Aagrus | 1:c65875995efb | 29 | pc->printf("Auflistung beendet!\n\n"); |
Aagrus | 1:c65875995efb | 30 | } |
Aagrus | 1:c65875995efb | 31 | |
Aagrus | 1:c65875995efb | 32 | void PrintString(char *str, int count) |
Aagrus | 1:c65875995efb | 33 | { |
Aagrus | 1:c65875995efb | 34 | pc->printf("String: "); |
Aagrus | 1:c65875995efb | 35 | |
Aagrus | 1:c65875995efb | 36 | for (int i = 0; i < count; i++) |
Aagrus | 1:c65875995efb | 37 | { |
Aagrus | 1:c65875995efb | 38 | pc->putc(str[i]); |
Aagrus | 1:c65875995efb | 39 | } |
Aagrus | 1:c65875995efb | 40 | |
Aagrus | 1:c65875995efb | 41 | pc->printf("\n"); |
Aagrus | 1:c65875995efb | 42 | } |
Aagrus | 1:c65875995efb | 43 | |
Aagrus | 1:c65875995efb | 44 | }; |