Dino Šatrović / Mbed 2 deprecated LV3_Grupa6_Tip008_Z2

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
diinnoo
Date:
Thu Mar 19 17:02:39 2015 +0000
Commit message:
Ivona Ivkovi?; Dino ?atrovi?;

Changed in this revision

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Mar 19 17:02:39 2015 +0000
@@ -0,0 +1,109 @@
+#include "mbed.h"
+#define dp23 P0_0
+
+
+
+//tastatura:
+BusOut Redovi  (dp16, dp15, dp17, dp18);
+BusIn Kolone  (dp9, dp10, dp11, dp13);
+
+//display:
+DigitalOut enableSignal(dp14);
+BusOut odabirCifre(dp25,dp24,dp23);
+BusOut segmentBroja(dp2,dp1,dp28,dp6,dp5,dp27,dp26);
+int prazanDisplay = 127;
+
+int ucitajTipkuSaTastature()
+{   
+    int i = 0; int j = 0;
+    for(i = 0; i < 4; i++)
+        {
+           Redovi [i] = 1;
+           
+           for(j = 0; j < 4; j++)
+           {
+               if(Kolone [j] == 1)
+               {
+                   if(i == 0 && j == 0) {Redovi[i] = 0; return 1; }
+                   if(i == 0 && j == 1) {Redovi[i] = 0; return 2; }
+                   if(i == 0 && j == 2) {Redovi[i] = 0; return 3; } 
+                   if(i == 1 && j == 0) {Redovi[i] = 0; return 4; }
+                   if(i == 1 && j == 1) {Redovi[i] = 0; return 5; } 
+                   if(i == 1 && j == 2) {Redovi[i] = 0; return 6; }
+                   if(i == 2 && j == 0) {Redovi[i] = 0; return 7; }
+                   if(i == 2 && j == 1) {Redovi[i] = 0; return 8; }
+                   if(i == 2 && j == 2) {Redovi[i] = 0; return 9; }
+                   if(i == 3 && j == 1) {Redovi[i] = 0; return 0; }
+                   if(i == 2 && j == 3) {Redovi[i] = 0; return -1; }
+                }
+            }
+         Redovi[i] = 0;       
+    }
+    return 999;
+}
+
+int brojevi[10] = {1, 79, 18, 6, 76, 36, 32, 14, 0, 4};
+int pamtiPoziciju = 0;
+int cifre[3] = {888, 888, 888}; 
+        
+void ispisiCifru1(int cifra)
+{
+        odabirCifre = 6;
+        segmentBroja = brojevi[cifra];   
+        wait(0.1);  
+        cifre[2] = cifra;      
+}
+
+void ispisiCifru(int cifra)
+{
+         //ispis stotinki:
+    odabirCifre = 7;
+    if(cifre[2] == 888) segmentBroja = prazanDisplay;
+    else segmentBroja = brojevi[cifre[2]];
+    odabirCifre = 6; 
+    
+    wait(0.001);
+    //ispis manje cifre sekundi:
+    odabirCifre = 7;
+    if(cifre[1] == 888) segmentBroja = prazanDisplay;
+    else segmentBroja = brojevi[cifre[1]];
+    odabirCifre = 5;
+    
+
+    wait(0.001);
+    
+    //ispis vece cifre sekundi:
+    odabirCifre = 7;
+    if(cifre[0] == 888) segmentBroja = prazanDisplay;
+    else segmentBroja = brojevi[cifre[0]];
+    odabirCifre = 3; 
+    wait(0.001);  
+}
+
+void pomjeriCifre(int nova)
+{
+    cifre[0] = cifre[1]     ;
+    cifre[1] = cifre[2];
+    cifre[2] = nova;  
+}
+
+int brojac = 0;
+
+int main() {
+    enableSignal = 1;
+    odabirCifre = 6; pamtiPoziciju = 1;
+    segmentBroja = brojevi[8];
+    wait(2);
+    int odabranaCifra = brojevi[0];
+    while(1) {
+        if (ucitajTipkuSaTastature() != 999) {
+            brojac++;
+            odabranaCifra = ucitajTipkuSaTastature(); 
+            if(brojac == 50) pomjeriCifre(odabranaCifra); 
+            
+            } 
+        if (odabranaCifra == -1) { pomjeriCifre(888); pomjeriCifre(888); segmentBroja = prazanDisplay; continue; }
+        if(ucitajTipkuSaTastature() == 999) brojac = 0;
+        ispisiCifru(odabranaCifra);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Mar 19 17:02:39 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0
\ No newline at end of file