Taras Popiv / Mbed OS GL_task
Revision:
3:dd96529b7ae9
Parent:
2:35f13b7f3659
Child:
4:d4aeacb47955
diff -r 35f13b7f3659 -r dd96529b7ae9 main.cpp
--- a/main.cpp	Thu Nov 23 13:09:25 2017 +0000
+++ b/main.cpp	Sat Dec 09 16:18:22 2017 +0000
@@ -7,25 +7,61 @@
 }
 
 Thread thread;
+Thread thread1;
+int print = 1;
+char input [64];
+int lamp = 50;
 
-DigitalOut led1(LED1);
+//DigitalOut led1(LED1);
+PwmOut led1(D11);
+//PwmOut led2(D13);
 
 void print_thread()
 {
     while (true) {
-        wait(1);
-        print_char();
+        
+        if (print == 1) {
+//          printf("\r\n*** Do you love me too?  ***\r\n");
+          printf("\r\nLamp is ON\r\n");
+          printf("\r\nPlese type + or - to change brightness\r\n");
+          print = 0;
+        }
+        scanf("%s",input);
+        printf("\r\n* %s *\r\n",input);
+        if (!strcmp(input,"-")){
+         if (lamp < 90) lamp = lamp + 10;
+         else if (lamp < 100) lamp = lamp + 1;
+         printf("\r\n*** Lamp brightness is %d ***\r\n", lamp);
+        }
+        else if (!strcmp(input,"+")){
+          printf("\r\n*** %d ***\r\n", lamp);  
+          if (lamp > 10) lamp = lamp - 10; 
+          else if (lamp > 0) lamp = lamp - 1; 
+          printf("\r\n*** Lamp brightness is %d ***\r\n", lamp);
+        }
+        else {
+          printf("\r\n(plese type + or -)\r\n");
+        }
     }
 }
 
 int main()
 {
-    printf("\n\n*** RTOS basic example ***\n");
+    printf("\r\n*** Welcome ***\n\r");
 
     thread.start(print_thread);
+    
 
     while (true) {
-        led1 = !led1;
-        wait(0.5);
-    }
+        led1 = (0.01 * lamp);
+//          led2 = !led2;
+        wait(0.2);
+//         led1 = led1 + 0.01;
+//         wait(0.2);
+//         if(led1 == 1.0) {
+//             led1 = 0;
+//         }
+        
+        }
+
 }