Complete Build
Dependencies: 4DGL-uLCD-SE1 Motor SDFileSystem X_NUCLEO_53L0A1 mbed-rtos mbed BotwithWavePlayerLevel
Fork of BotWithBluetoothLIDARV2 by
Revision 15:c8360ceaad61, committed 2017-10-16
- Comitter:
- bdragon52
- Date:
- Mon Oct 16 02:23:52 2017 +0000
- Parent:
- 14:cc2e4fbaffd8
- Child:
- 16:61e88b0e3689
- Commit message:
- semaphore
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Oct 09 21:04:05 2017 +0000
+++ b/main.cpp Mon Oct 16 02:23:52 2017 +0000
@@ -16,15 +16,17 @@
PwmOut red(p23);
PwmOut blue(p21);
PwmOut green(p22);
-
+ Thread *(test);
PwmOut myled(LED1);
uLCD_4DGL uLCD(p28,p27,p30);
-Mutex ourMutex;
+Semaphore three_slots(1);
Thread thread2;
Thread thread3;
Thread thread4;
Thread thread5;
Thread thread6;
+
+
float y=0.0;
int c=80;
int d=1;
@@ -44,13 +46,13 @@
int a=20;
int r=8;
- ourMutex.lock();
+ three_slots.wait();
uLCD.background_color(BLACK);
uLCD.cls();
uLCD.filled_circle(a, 105-(y*80), r, BLUE);
uLCD.line(3,25,13,25,RED);
uLCD.line(3,105,13,105,RED);
- ourMutex.unlock();
+
//while(b<100){
// uLCD.filled_circle(a, b, r, BLUE);
@@ -67,9 +69,9 @@
//Thread::wait(1000.0*0.002);
// }
-
- Thread::wait(1000.0*0.02);
-
+ three_slots.release();
+ Thread::wait(50);
+
}
}
@@ -97,7 +99,7 @@
void t4() {
while (true) {
- ourMutex.lock();
+ three_slots.wait();
if(c==70){
d=20;
@@ -116,8 +118,9 @@
Thread::wait(50);
uLCD.filled_circle(c, 64 , 10, BLACK);
- ourMutex.unlock();
+ three_slots.release();
Thread::wait(50);
+
}
}
@@ -131,7 +134,7 @@
if(blues.readable()==1){
- ourMutex.lock();
+ three_slots.wait();
if (blues.getc()=='!') {
if (blues.getc()=='B') { //button data
bnum = blues.getc(); //button number
@@ -199,15 +202,16 @@
}//end of if bnum 1 -8
}//end of if getc B
}//end of if getc !
-
+ three_slots.release();
}// end of if readable
-
+ Thread::yield();
- ourMutex.unlock();
+
Thread::wait(50);
+
}// end of while loop
}
@@ -216,10 +220,15 @@
int main() {
- thread2.start(t2);
+ thread2.start((t2));
thread3.start(t3);
- thread4.start(t4);
- thread5.start(t5);
+ thread4.start((t4));
+ thread5.start((t5));
+
+ test = &thread4;
+ test->set_priority(osPriorityHigh);
+
+
previousButton = '0';
