sat

Dependencies:   Displej mbed

https://os.mbed.com/media/uploads/IsusKrist/mikroupravljaci.jpg

Files at this revision

API Documentation at this revision

Comitter:
IsusKrist
Date:
Wed May 04 15:48:51 2022 +0000
Commit message:
Sat

Changed in this revision

Displej.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 5c66146653b6 Displej.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Displej.lib	Wed May 04 15:48:51 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/IsusKrist/code/Displej/#9c0145823064
diff -r 000000000000 -r 5c66146653b6 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 04 15:48:51 2022 +0000
@@ -0,0 +1,110 @@
+#include "mbed.h"
+#include "Displej.h"
+
+
+DigitalIn switch_namestanje_min(D3);
+DigitalIn switch_namestanje_sat(D2);
+InterruptIn button(PB_1);
+
+Timer debounce;
+Ticker ticker_min;
+
+int namestit_min=0;
+int namestit_sat=0;
+int sati=23;
+int minute=59;
+
+class Sat{
+    public:
+        Sat(int pocetniSat,int pocetnaMinute){
+            _sati=pocetniSat;
+            _minute=pocetnaMinute;
+        }
+        void prikaz(){
+                //Q1
+                QSegment=0x01;
+                LSegment=SegConvert(_sati,1);// jedan ide kad je polje obratno dok uzimas digite
+                wait(0.003);
+                //Q2
+                QSegment=0x02;
+                LSegment=SegConvert(_sati,0);
+                wait(0.003);
+                //Q2 dvotocka
+                QSegment=0x02;
+                LSegment=SegConvert(-1,0);
+                wait(0.003);
+                //Q3
+                QSegment=0x04;
+                LSegment=SegConvert(_minute,1);
+                wait(0.003);
+                //Q4
+                QSegment=0x08;
+                LSegment=SegConvert(_minute,0);
+                wait(0.005);
+            }
+            void setSati(int h){
+                _sati=h;
+            }
+            void setMinute(int m){
+                _minute = m;
+            }
+    private:
+        int _sati,_minute;
+};
+
+void otkucaj(void);
+void toggle(void);
+
+int main(){
+    ticker_min.attach(&otkucaj,60.0);
+    debounce.start();
+    switch_namestanje_min.mode(PullUp);
+    switch_namestanje_sat.mode(PullUp);
+    button.rise(&toggle);
+    Sat sat(sati,minute);
+    while(1) {
+        namestit_min=switch_namestanje_min==0?0:1;
+        namestit_sat=switch_namestanje_sat==0?0:1;
+        sat.setSati(sati);
+        sat.setMinute(minute);
+        sat.prikaz();
+    }
+}
+void otkucaj(){
+    if(namestit_sat==1 && namestit_min==1){
+        if(minute==59){
+            minute=0;
+            if(sati==23){
+                sati=0;
+            }else{
+                sati++;
+            }
+        }else{
+            minute++;
+        }
+    }
+}
+
+void toggle() {
+    if (debounce.read_ms()>100 && (namestit_min==0||namestit_sat==0)){
+        if(namestit_min==0 && namestit_sat==1){
+            if(minute<59){
+                minute++;
+            }else{
+                if(sati<23){
+                    sati++;
+                }else{
+                    sati=0;
+                }
+                minute=0;
+            }
+        }else if(namestit_min==1 && namestit_sat==0){
+            if(sati<23){
+                sati++;
+            }else{
+                sati=0;
+            }
+        }
+    }
+    debounce.reset();
+}
diff -r 000000000000 -r 5c66146653b6 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed May 04 15:48:51 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file