Ben with semaphore test 1
Dependencies: mbed mbed-rtos 4DGL-uLCD-SE SDFileSystem ATParser
Revision 7:9b36eb4811eb, committed 2020-04-24
- Comitter:
- bleverett3
- Date:
- Fri Apr 24 22:00:23 2020 +0000
- Parent:
- 6:be33395fe424
- Commit message:
- Ben "change" test 1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r be33395fe424 -r 9b36eb4811eb main.cpp --- a/main.cpp Fri Apr 24 21:40:31 2020 +0000 +++ b/main.cpp Fri Apr 24 22:00:23 2020 +0000 @@ -33,6 +33,7 @@ char buffer[10]; volatile int risk_level = 0; int temp_risk = -1; +int changed = 0; //RTOS Mutex Lock Mutex mutex_lock; @@ -57,7 +58,6 @@ void parse_RSSI() { mutex_lock.lock(); - lcd_lock.lock(); at.send("AT+BLEGETRSSI") && at.read(buffer, 10); if(buffer[0] == '-') { //datalogged = 1; @@ -87,7 +87,7 @@ } if(risk_level != temp_risk) { risk_level = temp_risk; - lcd_lock.unlock(); + changed = 1; } } pc.printf("Risk level: "); @@ -149,37 +149,38 @@ mutex_lock.unlock(); while(1){ mutex_lock.lock(); - lcd_lock.lock(); - if(risk_level <= 1){ - uLCD.cls(); - uLCD.locate(5, 7); - uLCD.text_width(2); - uLCD.text_height(2); - uLCD.background_color(GREEN); - uLCD.textbackground_color(GREEN); - uLCD.printf("Safe"); - }else if(risk_level == 2){ - uLCD.cls(); - uLCD.locate(1, 7); - uLCD.text_width(2); - uLCD.text_height(2); - uLCD.background_color(0xFFFF00); - uLCD.textbackground_color(0xFFFF00); - uLCD.printf("Cautious"); - }else if(risk_level == 3){ - uLCD.cls(); - uLCD.locate(3, 7); - uLCD.text_width(2); - uLCD.text_height(2); - uLCD.background_color(RED); - uLCD.textbackground_color(RED); - uLCD.printf("Hazard"); - }else{ - uLCD.background_color(BLACK); - uLCD.printf("waiting"); + if (changed) { + if(risk_level <= 1){ + uLCD.cls(); + uLCD.locate(5, 7); + uLCD.text_width(2); + uLCD.text_height(2); + uLCD.background_color(GREEN); + uLCD.textbackground_color(GREEN); + uLCD.printf("Safe"); + }else if(risk_level == 2){ + uLCD.cls(); + uLCD.locate(1, 7); + uLCD.text_width(2); + uLCD.text_height(2); + uLCD.background_color(0xFFFF00); + uLCD.textbackground_color(0xFFFF00); + uLCD.printf("Cautious"); + }else if(risk_level == 3){ + uLCD.cls(); + uLCD.locate(3, 7); + uLCD.text_width(2); + uLCD.text_height(2); + uLCD.background_color(RED); + uLCD.textbackground_color(RED); + uLCD.printf("Hazard"); + }else{ + uLCD.background_color(BLACK); + uLCD.printf("waiting"); + } + changed = 0; } mutex_lock.unlock(); - lcd_lock.unlock(); } }