2020/0425 Milos Novakovic

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
mlos55
Date:
Sat Nov 06 09:27:37 2021 +0000
Parent:
0:e776d140b732
Commit message:
2020/0425 Milos Novakovic;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r e776d140b732 -r 4bf71be0038a main.cpp
--- a/main.cpp	Sat Nov 06 08:15:11 2021 +0000
+++ b/main.cpp	Sat Nov 06 09:27:37 2021 +0000
@@ -1,19 +1,9 @@
+//Milos Novakovic 2020/0425
 
-//Uvoz biblioteka i def direktiva
+
+//Uvoz biblioteka i def. direktiva
 
 #include "mbed.h"
-/*
-#define A PA_10;
-#define B PA_9;
-#define C PA_8;
-#define D PB_10;
-#define E PB_5;
-#define F PB_4;
-#define G PB_3;
-///#define 
-//#define SEL1 PB_6;
-//#define SEL2 PC_7;
-*/
 
 //Globalne promjenljive
 
@@ -21,53 +11,76 @@
 BusOut display2(PA_10, PA_9,PA_8,PB_10,PB_5,PB_4,PB_3);
 DigitalOut SEL2(PC_7);
 DigitalOut SEL1(PB_6);
-DigitalIn BUTTON(PC_9);
+DigitalIn BUTTON(PC_8);  //SW2
+DigitalIn BUTTON2(PC_9); //SW1
 static char i=0;
 
-//deklaracija f-ja
+//Definicija f-ja
 
-//glavni program
 void increment(void){
     switch(i){
-        case 1: SEL1=1; display2=0xF9;break;
-        case 2: display2=0xA4;break;
-        case 3: display2=0xB0;break;
-        case 4: display2=0x99;break;
-        case 5: display2=0x92;break;
-        case 6: display2=0x82;break;
-        case 7: display2=0xF8;break;
-        case 8: display2=0x80;break;
-        case 9: display2=0x90;break;
-        case 10: SEL2=1; SEL1=0; display1=0xF9; wait_ms(5); SEL1=1;display2=0x40;wait_ms(5);break;
-        case 11: SEL2=1; SEL1=0; display1=0xF9; wait_ms(5); SEL1=1;display2=0xF9;wait_ms(5);break;
-        case 12: SEL2=1; SEL1=0; display1=0xF9; wait_ms(5); SEL1=1;display2=0xA4;wait_ms(5);break;
-        case 13: SEL2=1; SEL1=0; display1=0xF9; wait_ms(5); SEL1=1; display2=0xB0;wait_ms(5);break;
-        case 14: SEL2=1; SEL1=0; display1=0xF9; wait_ms(5); SEL1=1; display2=0x99;wait_ms(5);break;
-        case 15: SEL2=1; SEL1=0; display1=0xF9; wait_ms(5); SEL1=1; display2=0x92;wait_ms(5);break;
+        case 0: SEL1=1;display2=0x40; break;
+        case 1: display2=0xF9; break;
+        case 2: display2=0xA4; break;
+        case 3: display2=0xB0; break;
+        case 4: display2=0x99; break;
+        case 5: display2=0x92; break;
+        case 6: display2=0x82; break;
+        case 7: display2=0xF8; break;
+        case 8: display2=0x80; break;
+        case 9: display2=0x90; break;
+        case 10:  SEL1=1; SEL2=0; display2=0x40;break;
+        case 11:  SEL1=1; SEL2=0; display2=0xF9;break;
+        case 12:  SEL1=1; SEL2=0; display2=0xA4;break;
+        case 13:  SEL1=1; SEL2=0; display2=0xB0;break;
+        case 14:  SEL1=1; SEL2=0; display2=0x99;break;
+        case 15:  SEL1=1; SEL2=0;  display2=0x92; SEL2=0;SEL1=1; break;
          
-    
         }
     }
-
+    
+//Glavni program
 int main(){
     SEL1=1;
     SEL2=0;
     display2=0x40;
+    
     while(1){
+        
+        //Testirano bez jumpera
+        
+        while(BUTTON==1){
+            if(i>9){
+                SEL2=1; SEL1=0; display1=0xF9;
+                wait_ms(10);
+                increment();
+                wait_ms(10);
+        }}
+        
         if(BUTTON==0){
+            SEL2=0;
+            if(i!=15){   
             i=i++;
             increment();
-            wait_ms(200);
+            }
+            else i=0;
+            increment();
+            while(BUTTON==0);
+            wait_ms(120);
+            }
+        
+            
+        //Bonus
+        if(BUTTON2==0){
+            if(i==0) i=15;
+            else i=i--;
+            increment();
+            while(BUTTON2==0);
+            }
+            
             }
             
         
-        
-        
-        
-        //SEL2=0;
-        //display2=0x40;
-    
-        }
     }