Hadzic Muharem Haris Šemić

Dependencies:   mbed

Revision:
0:a2ffc0e92dde
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Apr 10 15:19:46 2014 +0000
@@ -0,0 +1,88 @@
+#include "mbed.h"
+
+BusOut Broj(dp17,dp18,dp4,dp28,dp6,dp5,dp27,dp26);
+BusOut Cifra(dp23,dp24,dp25);
+
+int broj[10]={0x03,0x9F,0x25,0x0D,0x99,0x49,0x41,0x1F,0x01,0x09};
+int brojDP[10]={0x02,0x9E,0x24,0x0C,0x98,0x48,0x40,0x1E,0x00,0x08};
+int cifra[3]={0xB,0xD,0xE};
+
+InterruptIn taster1(dp1);
+InterruptIn taster2(dp2);
+
+//Timer desetinka;
+//Timer jedinica;
+//Timer desetica;
+
+Ticker osvjezavanje;
+Ticker desetinka;
+Timer debounce;
+
+bool s(false),stop(true);
+int b1(0),b2(0),b3(0),c(0);
+
+void f1(){
+    if(!stop){
+       b1++;
+       if(b1==10){
+            b1=0;
+            b2++;
+            if(b2==10){
+                b2=0;
+                b3++;
+                if(b3==10) b3=0;
+            }
+        } 
+    }
+}
+
+void start(){
+    if(debounce.read_ms()>200){
+       if(!s){
+            stop=false;
+            s=true;
+        }
+        else{
+            stop=true;
+            s=false; 
+        } 
+    }
+    debounce.reset();
+}
+
+void reset(){
+    stop=true;
+    b1=0;
+    b2=0;
+    b3=0;
+    s=false;   
+}
+
+void osvjezi(){
+    Cifra=0xF;
+    if(c==0){
+        Broj=broj[b1];
+    }
+    else if(c==1){
+        Broj=brojDP[b2];
+    }
+    else{
+        Broj=broj[b3];
+    }
+    Cifra=cifra[c];
+    c++;
+    if(c==3) c=0;
+}
+
+
+
+int main() {
+    debounce.start();
+    taster1.rise(&start);
+    taster2.rise(&reset);
+    desetinka.attach(&f1,0.1);
+    osvjezavanje.attach(&osvjezi,0.001);
+    while(1) {
+        
+    }
+}
\ No newline at end of file