Kod za upravljanje rasvjetom

Dependents:   Upravljanje_svijetlima

Files at this revision

API Documentation at this revision

Comitter:
keepurhealth
Date:
Fri Aug 26 15:37:32 2022 +0000
Commit message:
Upravljanje svjetlima v2.0

Changed in this revision

Light.cpp Show annotated file Show diff for this revision Revisions of this file
Light.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Light.cpp	Fri Aug 26 15:37:32 2022 +0000
@@ -0,0 +1,16 @@
+#include "Light.h" // Inicijalizacija Light biblioteke
+#include "mbed.h"  // Inicijalizacija mbed biblioteke
+
+Light :: Light(PinName pin) : _pin(pin) // Deklaracija klonstruktora "Light"
+{
+    _pin = 0;
+}                     
+void Light::Flash_control(int n) // Deklaracija funkcije "Flash_control"
+{
+    _pin = !_pin;
+    ThisThread::sleep_for(n); // Funkcija slična wait_ms
+}
+
+void Light :: Flash_off () { // Deklaracija funkcije Flash_control
+    _pin = 0;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Light.h	Fri Aug 26 15:37:32 2022 +0000
@@ -0,0 +1,14 @@
+#ifndef LIGHT   // Provjera biblioteke "LIGHT"
+#define LIGHT   // Provjera biblioteke "LIGHT"
+#include "mbed.h"
+
+class Light     // Stvaranje klase "Light"
+{
+public:
+    Light(PinName pin); // Konstruktor klase "Light"
+    void Flash_control(int n); // Inicijalizacija funkcije Flash_control
+    void Flash_off(); // Inicijalizacija funkcije Flash_off
+private:
+    DigitalOut _pin; // Varijabla za prosljeđivanje digitalnog izlaza
+};
+#endif  // završava definiranje biblioteke "LIGHT"
\ No newline at end of file