First class MyLed with member initializer lists

Dependents:   class_blinky

Files at this revision

API Documentation at this revision

Comitter:
bulmecisco
Date:
Tue Oct 06 15:32:23 2020 +0000
Commit message:
First program with member initializer lists

Changed in this revision

MyLed.cpp Show annotated file Show diff for this revision Revisions of this file
MyLed.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyLed.cpp	Tue Oct 06 15:32:23 2020 +0000
@@ -0,0 +1,15 @@
+#include "mbed.h"
+#include "MyLed.h"
+
+// Methoden oder Memberfunktions
+void MyLed::ledOn() {
+    _led = 1;
+}
+
+void MyLed::ledOff() {
+    _led = _wert;
+}
+
+void MyLed::printStatus() {
+    printf("Led is now: %d\n", _led.read());
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyLed.h	Tue Oct 06 15:32:23 2020 +0000
@@ -0,0 +1,20 @@
+#include "mbed.h"
+#ifndef MYLED_H
+#define MYLED_H
+
+// Klasse
+class MyLed{
+private:
+    // Memebervariable
+    DigitalOut _led;
+    const int _wert;
+public:
+    // Konstruktor  
+    MyLed(PinName led) : _led(led), _wert(0) {
+    }
+    // Methodenprototyping
+    void ledOn();
+    void ledOff();
+    void printStatus();
+};
+#endif
\ No newline at end of file