STM32-F746NG-DISCO Project.

Dependencies:   BSP_DISCO_F746NG

Revision:
5:f42b50713a12
Parent:
4:875a2d0a996d
--- a/main.cpp	Thu Jan 09 15:20:21 2020 +0000
+++ b/main.cpp	Fri Jan 10 08:41:38 2020 +0000
@@ -2,7 +2,7 @@
     Author: Christian Andresen
     Website: xcha11.skp-dp.sde.dk
     Date: 10-01-2020
-    Brief: STM32 project
+    Brief: STM32-F746NG-DISCO Project
     Project includes:
         Button/Touch sensor input, connected to LED lights and grove buzzer.
         Infinite counter of 0-9999. Resets automatically.
@@ -52,10 +52,10 @@
             countup++;
 
         } else if (restarts == 10) {
-            break;
+            break; // Once BSOD hits, the break statement will end the 9999 counter to simulate proper system shutdown.
         } else {
-            countup = 0;
-            restarts++;
+            countup = 0; // Reset 9999 counter
+            restarts++; // Add to restart
             printf("Counter has finished counting. Reset nr. %d. \r\n", restarts);
         }
     }
@@ -64,9 +64,11 @@
 // Main part of the program
 int main()
 {
-    CounterThread.start(&ninecounter); // Start multithread ninecounter & inputcounter
+    // Start multithread ninecounter & inputcounter
+    CounterThread.start(&ninecounter);
     InputThread.start(&input);
 
+    // Checks when the button is pushed down and when the touch sensor is activated
     button.rise(&buttonpress);
     touch.rise(&touchpress);
 
@@ -77,7 +79,7 @@
     restarts = 0; // Amount of times 9999 counter has been reset
 
     // Boot up LCD screen
-    BSP_LCD_Init();
+    BSP_LCD_Init(); // Starts up the LCD
     BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS);
     BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);
 
@@ -87,17 +89,18 @@
     BSP_LCD_SetTextColor(LCD_COLOR_RED);
 
     // Bootup Message
-    printf("Device is booting up \r\n");
-    BSP_LCD_DisplayStringAt(0, 100, (uint8_t *) "HELLDROP STUDIO", CENTER_MODE);
-    BSP_LCD_DisplayStringAt(0, 150, (uint8_t *) "A big hard business", CENTER_MODE);
-    BSP_LCD_DisplayStringAt(0, 175, (uint8_t *) "in a big hard building", CENTER_MODE);
-    HAL_Delay(10000);
+    printf("Device is booting up \r\n"); // Debug statement that lets you know that the device is booting.
+    BSP_LCD_DisplayStringAt(0, 100, (uint8_t *) "HELLDROP STUDIO", CENTER_MODE); // Company
+    BSP_LCD_DisplayStringAt(0, 150, (uint8_t *) "A big hard business", CENTER_MODE); // Tagline 1
+    BSP_LCD_DisplayStringAt(0, 175, (uint8_t *) "in a big hard building", CENTER_MODE); // Tagline 2
+    HAL_Delay(10000); // Delay 10 seconds to simulate actual bootup
+
     // Change LCD Screen to system
     BSP_LCD_Clear(LCD_COLOR_BLACK);
     printf("Device has started functioning \r\n");
-    // Studio name & department
-    BSP_LCD_DisplayStringAt(0, 25, (uint8_t *) "HELLDROP STUDIO SOFTWARE", CENTER_MODE);
-    BSP_LCD_DisplayStringAt(0, 250, (uint8_t *) "Code by Christian Andresen", CENTER_MODE);
+
+    BSP_LCD_DisplayStringAt(0, 25, (uint8_t *) "HELLDROP STUDIO SOFTWARE", CENTER_MODE); // Studio name & department
+    BSP_LCD_DisplayStringAt(0, 250, (uint8_t *) "Code by Christian Andresen", CENTER_MODE); // Developer credit
 
     // While there are less than 10 restarts of the counter..
     while(restarts < 10) {
@@ -139,7 +142,7 @@
             button_count++; // Add to button counter
             led = 1; // Turn on LED
             buzzer = 1; // Turn on buzzer
-            wait(0.25); // Prevent immediate shutdown
+            wait(0.1); // Prevent immediate shutdown
             // Turn both off
             led = 0;
             buzzer = 0;
@@ -148,11 +151,11 @@
             printf("Touch sensor has been activated \r\n");
             touch_count++; // Add to touch counter on the LCD
             led = 1;
-            wait(0.25);
+            wait(0.1);
             led = 0;
             touchclick = false; // End touch click
         } else if (restarts == 10) {
-            break;
+            break; // Once BSOD hits, the break statement will end the input counter to simulate proper system shutdown.
         } else { // Failsafe if neither are turned off during click.
             led = 0;
             buzzer = 0;
@@ -162,10 +165,10 @@
 
 void buttonpress()
 {
-    buttonclick = true;
+    buttonclick = true; // Bool that activates the input() once it registers a button press
 }
 
 void touchpress()
 {
-    touchclick = true;
+    touchclick = true; // See Buttonpress() comments above
 }
\ No newline at end of file