Marko Spremic 2020/0066 verzija poslednja

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
markospremic
Date:
Sat Nov 06 09:46:07 2021 +0000
Parent:
0:a95a1295484c
Commit message:
Marko Spremic 2020/0066 verzija poslednja

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Nov 06 08:15:13 2021 +0000
+++ b/main.cpp	Sat Nov 06 09:46:07 2021 +0000
@@ -12,6 +12,7 @@
  #define ADD(x) x+=1;
  #define DEC(x) x-=1;
  #define time 8
+ #define time2 50
  #define CHECK(x) if(x > 15) x = 0;
  #define CHECK_0(x) if(x < 0) x = 15;
  
@@ -39,6 +40,7 @@
          case 7: led_dis = 0xF8; break;
          case 8: led_dis = 0x80; break;
          case 9: led_dis = 0x90; break;
+         default: led_dis = 0xFF;
      }
  }
  
@@ -46,21 +48,22 @@
  
 int main()
 {
-    int x = null, ButtonReleased1  = 0, ButtonReleased2 = 0;
+    int x = null, x1 = null, x2 = null;static char ButtonReleased1  = 1, ButtonReleased2 = 1;
     while(1)
     {
+        x1 = x % 10;
+        x2 = (x / 10 == 1)? 1:-1;
         SEL2.write(0);
         SEL1.write(1);
-        write_num(x%10);
+        write_num(x1);
         wait_ms(time);
-        if(x > 9)
-        {
-            SEL2.write(1);
-            SEL1.write(0);
-            write_num(one);
-            wait_ms(time);
-        }
-        if(!btn1)
+        
+        SEL2.write(1);
+        SEL1.write(0);
+        write_num(x2);
+        wait_ms(time);
+        
+        if(!btn1 && btn2)
         {
             if(ButtonReleased1)
             {
@@ -68,12 +71,13 @@
                 CHECK(x)
                 ButtonReleased1 = 0;
             }
-            wait_ms(2 * time);
+            wait_ms(time2);
         }
         else
+        {
             ButtonReleased1 = 1;
-        
-        if(!btn2)
+        }
+        if(!btn2 && btn1)
         {
             if(ButtonReleased2)
             {
@@ -81,9 +85,11 @@
                 CHECK_0(x)
                 ButtonReleased2 = 0;
             }
-
+            wait_ms(time2);
         }
         else
+        {
             ButtonReleased2 = 1;
+        }
     }
 }
\ No newline at end of file