finak vers

Dependencies:   BSP_DISCO_F746NG

Revision:
1:a9bc635779dd
Parent:
0:6ea52364a685
Child:
2:41fa40a21162
--- a/main.cpp	Fri Feb 07 08:25:48 2020 +0000
+++ b/main.cpp	Fri Feb 07 10:42:50 2020 +0000
@@ -1,9 +1,28 @@
 #include "mbed.h"
 #include "stm32746g_discovery_lcd.h"
 
+DigitalOut light(D8);
+InterruptIn butt(D4);
+
+
+
+
 char let[50];
 int counter = 10;
-int add = 1;
+int downer = 1;
+int add = 0;
+int randomoner;
+
+void lights()
+{
+    light = 0;
+    HAL_Delay(20);
+    light= 1;
+    HAL_Delay(200);
+
+
+}
+
 
 void menu()
 {
@@ -21,8 +40,6 @@
 
 void disp()
 {
-    int rando = rand() % 3;
-    // creates a random number from 0-2, dependant on the number at the code
 
     BSP_LCD_Clear(LCD_COLOR_WHITE); // farve til bagrund
     BSP_LCD_SetTextColor(LCD_COLOR_BLUE); // farve til de neste ting, indtil man vlger ny farve
@@ -48,12 +65,12 @@
     BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
     BSP_LCD_DisplayStringAt(0, 250, (uint8_t *)("%s", let), LEFT_MODE);
     HAL_Delay(10);
-    counter = counter - add;
+    counter = counter - downer + add;
     sprintf(let, "%d",counter);
     BSP_LCD_DisplayStringAt(0, 200, (uint8_t *)("%s", let), LEFT_MODE);
     // den viser counter og random number til LCD'en
 
-    sprintf(let, "%d", rando);
+
     // counter til LCD
     // self comment: sprintf er min nye Savior, fik prøvet alt andet, men den var den eneste jeg kunne fik virket
     HAL_Delay(1000);
@@ -63,17 +80,37 @@
         BSP_LCD_Clear(LCD_COLOR_BLACK);
         BSP_LCD_SetTextColor(LCD_COLOR_RED);
         BSP_LCD_DisplayStringAt(0, 100, (uint8_t *)"KABOOOOOOM!!!!\nYou Died", CENTER_MODE);
+        light = 1;
         getchar();
-
         // the whole code will stop once the counter reaches 0
-
     };
     HAL_Delay(10);
+    add = 0;
 }
 
 
 
 
+void rando()
+{
+    int random = rand() % 3;
+    // creates a random number from 0-2, dependant on the number at the code
+
+    sprintf(let, "%d", random);
+
+    randomoner = random;
+}
+void pressed()
+{
+   while(randomoner == 0)
+   {
+        add = 3;
+    }
+
+    
+
+}
+
 
 int main()
 {
@@ -81,6 +118,9 @@
     menu(); // use the menu code
 
     while (1) {
+        butt.rise(&pressed);
         disp(); // use the disp code
+        lights();
+        rando();
     }
 }