My first big writted program ;)

Dependencies:   mbed

Revision:
1:d3366745d5ec
Parent:
0:f86463132427
Child:
2:83e427afeea0
--- a/main.cpp	Mon Dec 26 05:34:03 2016 +0000
+++ b/main.cpp	Fri Dec 30 07:30:09 2016 +0000
@@ -1,23 +1,39 @@
+/*
+Author: foreste
+Program name: control led action
+Platform test hardware: Stm32f0RB and Atnel.pl ATB 1,04A
+*/
+
 #include "mbed.h"
 
+//Settings Uart
 Serial rs232(USBTX, USBRX);
 
+//Setting pins
 DigitalOut led[8] {PC_3, PC_2, PA_1, PA_0, PA_15, PC_12, PC_13, PB_7};
-Timer knight, tree;
-char user_input = 0;
+
+//Delay no blocking program
+Timer delay;
+
+char user_input = 0; //user variable
+
+//fuction replace state pin in High
 void ledintilize()
 {
     for(int x=0; x<8; x++) {
         led[x] = 1;
     }
 }
+
+//fuction replace state pin in High special method 
 void pin_clear_state()
 {
     led[0] = led[1] = led[2] = led[3] = led[4] = led[5] = led[6] = led[7] = 1;
 }
+//first method flashing knight
 void led_knight()
 {
-    switch(knight.read_ms()) {
+    switch(delay.read_ms()) {
         case 500:
             pin_clear_state();
             led[0] = 0;
@@ -52,14 +68,14 @@
             break;
         case 4500:
             led[7] = 1;
-            knight.reset();
+            delay.reset();
             break;
     }
 }
-
+// second method flashing knight
 void led_knight2()
 {
-    switch(knight.read_ms()) {
+    switch(delay.read_ms()) {
         case 500:
             pin_clear_state();
             led[0] = 0;
@@ -126,14 +142,16 @@
             break;
         case 8500:
             led[0] = 1;
-            knight.reset();
+            delay.reset();
             break;
     }
 
 }
+
+//Third method flashing knight
 void  knight3()
 {
-    switch(knight.read_ms()) {
+    switch(delay.read_ms()) {
         case 500:
             pin_clear_state();
             // led[7] = 1;
@@ -165,41 +183,40 @@
             break;
         case 4000:
             led[0] = 1;
-            knight.reset();
+            delay.reset();
             break;
     }
 }
-
+//first method flashing Police sirens
 void police_light()
 {
-    if(knight.read_ms() >= 200) {
+    if(delay.read_ms() >= 200) {
         pin_clear_state();
-        //led[4] = led[5] = led[6] = led[7] = 1;
         led[0] = led[1] = led[2] = led[3] = 0;
-        if(knight.read_ms() >= 400) {
+        if(delay.read_ms() >= 400) {
             led[0] = led[1] = led[2] = led[3] = 1;
             led[4] = led[5] = led[6] = led[7] = 0;
-            knight.reset();
+            delay.reset();
         }
     }
 }
 
+//Second method flashing Police sirens
 void police_light2()
 {
-    if(knight.read_ms() >= 200) {
+    if(delay.read_ms() >= 200) {
         pin_clear_state();
-        //led[1] = led[3] = led[5] = led[7] = 1;
         led[0] = led[2] = led[4] = led[6] = 0;
-        if(knight.read_ms() >= 400) {
+        if(delay.read_ms() >= 400) {
             led[0] = led[2] = led[4] = led[6] = 1;
             led[1] = led[3] = led[5] = led[7] = 0;
-            knight.reset();
+            delay.reset();
         }
     }
 }
 
 
-
+//Fuction interruption uart 
 void rs232in()
 {
     if(rs232.readable()) {
@@ -208,39 +225,39 @@
 }
 int main()
 {
-    ledintilize();
-    rs232.attach(&rs232in);
+    ledintilize(); //fuction replace state pin in High
+    rs232.attach(&rs232in); //Fuction interruption uart 
 
     while(1) {
 
 
-
+//Select mode flash light  for user
         switch(user_input) {
 
 
             case '1':
 
-                knight.start();
+                delay.start();
                 led_knight();
                 break;
             case '2':
 
-                knight.start();
+                delay.start();
                 led_knight2();
                 break;
 
             case '3':
-                knight.start();
+                delay.start();
                 knight3();
                 break;
 
             case '4':
-                knight.start();
+                delay.start();
                 police_light();
                 break;
 
             case '5':
-                knight.start();
+                delay.start();
                 police_light2();
                 break;