lol

Dependencies:   TextLCD mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
Paril
Date:
Thu Nov 24 20:56:02 2016 +0000
Commit message:
old shit

Changed in this revision

TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Thu Nov 24 20:56:02 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 24 20:56:02 2016 +0000
@@ -0,0 +1,122 @@
+#include "mbed.h"
+#include "TextLCD.h"
+DigitalOut myled(LED1);
+DigitalOut myled_(LED2);
+
+Semaphore minMutex;
+Semaphore secMutex;
+
+RawSerial pc(USBTX, USBRX); // tx, rx
+TextLCD lcd(p15, p16, p17, p18, p19, p20);
+
+void hundredth(void const *n);
+
+int sec, hsec, min;
+int pause, startFlag; 
+
+void minute(void const *n)
+{
+    while(1)
+    {
+        minMutex.wait();
+        min++;
+    }
+}
+
+void second(void const *n)
+{
+    while(1)
+    {
+        secMutex.wait();
+        sec++;
+        if(sec == 60)
+        {
+            minMutex.release();
+            sec=0;
+        }
+    }
+}    
+
+void hundredth(void const *n)
+{
+//    if(startFlag == 1)
+    {
+        hsec++;
+        if(hsec == 100)
+        {
+            secMutex.release();
+            hsec = 0;
+        }
+    }
+}
+
+void display(void const *n)
+{
+    while(1)
+    {
+        if(!pause)
+        {
+            lcd.locate(0,0);
+            lcd.printf("%2d:%2d:%2d",min,sec,hsec);  
+            Thread::wait(10);
+        }
+    }
+}    
+ 
+
+void key()
+{
+    char c = pc.getc();
+    if(c == 's' || c == 'S')
+    {
+        startFlag = !startFlag;
+    }
+    else if(c == 'p' || c == 'P')
+    {
+        pause = !pause;
+    }
+    else if(c == 'r' || c == 'R')
+    {
+        min = 0;
+        sec = 0;
+        hsec = 0;
+    }
+}    
+
+int main()
+{
+    hsec = 0;
+    sec = 0;
+    min = 0;
+    pause = 0;
+    startFlag = 0;
+        
+    RtosTimer hund(hundredth, osTimerPeriodic,(void *)0);
+
+    Thread secondThread(second);
+    Thread minuteThread(minute);
+    Thread displayThread(display);
+    
+    secondThread.set_priority(osPriorityNormal);
+    minuteThread.set_priority(osPriorityNormal);
+    displayThread.set_priority(osPriorityIdle);
+
+
+
+    hund.stop();
+
+    pc.attach(&key, Serial::RxIrq);
+    
+    while(1)
+    {
+        if(startFlag)
+        {
+            hund.start(10);
+        }
+        else
+        {
+            hund.stop();
+        }
+        Thread::wait(10);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Thu Nov 24 20:56:02 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#3da5f554d8bf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 24 20:56:02 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85
\ No newline at end of file