Learning classes.

Dependencies:   C12832

Dependents:   PURS_ZI_004

Files at this revision

API Documentation at this revision

Comitter:
tbjazic
Date:
Wed Feb 10 11:19:25 2016 +0000
Commit message:
Initial.

Changed in this revision

C12832.lib Show annotated file Show diff for this revision Revisions of this file
Mikrovalna.cpp Show annotated file Show diff for this revision Revisions of this file
Mikrovalna.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r df735aa160f3 C12832.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832.lib	Wed Feb 10 11:19:25 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/askksa12543/code/C12832/#990d5eec2ef6
diff -r 000000000000 -r df735aa160f3 Mikrovalna.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Mikrovalna.cpp	Wed Feb 10 11:19:25 2016 +0000
@@ -0,0 +1,58 @@
+#include "mbed.h"
+#include "C12832.h"
+#include "Mikrovalna.h"
+
+Mikrovalna::Mikrovalna(PinName sekundePin, PinName startStopPin) : sekunde(sekundePin), startStop(startStopPin), lcd(p5, p7, p6, p8, p11), relej(LED1) {
+    ukljucena = false;
+    sekunde.rise(this, &Mikrovalna::namjestiVrijeme);
+    startStop.rise(this, &Mikrovalna::ukljuciIskljuci);
+    debounceSekunde.start();
+    debounceStartStop.start();
+    relej = 0;
+    vrijeme = 0;
+    lcd.cls();
+    lcd.locate(0,3);
+    lcd.printf("PURS_ZI_004\nNamjesti vrijeme/pokreni");
+}
+
+void Mikrovalna::ukljuciIskljuci() {
+    if(debounceStartStop.read_ms() > 200) {
+        if (!ukljucena && vrijeme > 0) {
+            iskljuci.attach(this, &Mikrovalna::iskljucenje, vrijeme);
+            relej = 1;
+            ukljucena = true;
+            lcd.cls();
+            lcd.locate(0,3);
+            lcd.printf("Ukljucena na %d s", vrijeme);
+        } else {
+            iskljuci.detach();
+            relej = 0;
+            vrijeme = 0;
+            ukljucena = false;
+            lcd.cls();
+            lcd.locate(0,3);
+            lcd.printf("Iskljucena");
+        }
+        debounceStartStop.reset();
+    }
+}
+
+void Mikrovalna::iskljucenje() {
+    relej = 0;
+    vrijeme = 0;
+    ukljucena = false;
+    lcd.cls();
+    lcd.locate(0,3);
+    lcd.printf("Gotovo");
+}
+
+void Mikrovalna::namjestiVrijeme() {
+    if(debounceSekunde.read_ms() > 200) {
+        vrijeme += 5;
+        if (vrijeme > 30) vrijeme = 0;
+        debounceSekunde.reset();
+        lcd.cls();
+        lcd.locate(0,3);
+        lcd.printf("%d", vrijeme);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r df735aa160f3 Mikrovalna.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Mikrovalna.h	Wed Feb 10 11:19:25 2016 +0000
@@ -0,0 +1,23 @@
+#ifndef MIKROVALNA_H
+#define MIKROVALNA_H
+
+#include "mbed.h"
+#include "C12832.h"
+
+class Mikrovalna {
+    public:
+    Mikrovalna(PinName sekundePin, PinName startStopPin);
+    private:
+    InterruptIn sekunde, startStop;
+    C12832 lcd;
+    Timer debounceSekunde, debounceStartStop;
+    Timeout iskljuci;
+    void namjestiVrijeme();
+    void ukljuciIskljuci();
+    void iskljucenje();
+    bool ukljucena;
+    DigitalOut relej;
+    int vrijeme;
+};
+
+#endif // MIKROVALNA_H
\ No newline at end of file