Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed mbed-rtos 4DGL-uLCD-SE SDFileSystem ATParser
Revision 5:53a86492622d, committed 2020-04-24
- Comitter:
- bleverett3
- Date:
- Fri Apr 24 21:38:36 2020 +0000
- Parent:
- 4:0a11aa484a67
- Child:
- 6:be33395fe424
- Commit message:
- Ben lcd_lock test 1
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Apr 24 21:06:06 2020 +0000
+++ b/main.cpp Fri Apr 24 21:38:36 2020 +0000
@@ -36,6 +36,7 @@
//RTOS Mutex Lock
Mutex mutex_lock;
+Mutex lcd_lock;
//Global Data points and arrays
int averageCount = 0;
@@ -56,6 +57,7 @@
void parse_RSSI()
{
mutex_lock.lock();
+ lcd_lock.lock();
at.send("AT+BLEGETRSSI") && at.read(buffer, 10);
if(buffer[0] == '-') {
//datalogged = 1;
@@ -71,6 +73,7 @@
}
averageCount++;
if(averageCount > 15 && buffer[0] == '-') {
+
averageCount = 0;
int average = calculate_average(RSSI_array, 15);
if(average < 55) {
@@ -83,8 +86,8 @@
temp_risk = 0;
}
if(risk_level != temp_risk) {
- sem.release();
risk_level = temp_risk;
+ lcd_lock.release();
}
}
pc.printf("Risk level: ");
@@ -119,15 +122,15 @@
void blink_leds()
{
while(1){
- if(risk_level <= 1 && datalogged){
+ if(risk_level <= 1){
greenLED = 1;
redLED = 0;
yellowLED = 0;
- }else if(risk_level == 2 && datalogged){
+ }else if(risk_level == 2){
yellowLED = 1;
greenLED = 0;
redLED = 0;
- }else if(risk_level == 3 && datalogged){
+ }else if(risk_level == 3){
redLED = 1;
yellowLED = 0;
greenLED = 0;
@@ -145,9 +148,9 @@
uLCD.color(WHITE);
mutex_lock.unlock();
while(1){
- sem.wait();
mutex_lock.lock();
- if(risk_level <= 1 && datalogged){
+ lcd_lock.lock();
+ if(risk_level <= 1){
uLCD.cls();
uLCD.locate(5, 7);
uLCD.text_width(2);
@@ -155,7 +158,7 @@
uLCD.background_color(GREEN);
uLCD.textbackground_color(GREEN);
uLCD.printf("Safe");
- }else if(risk_level == 2 && datalogged){
+ }else if(risk_level == 2){
uLCD.cls();
uLCD.locate(1, 7);
uLCD.text_width(2);
@@ -163,7 +166,7 @@
uLCD.background_color(0xFFFF00);
uLCD.textbackground_color(0xFFFF00);
uLCD.printf("Cautious");
- }else if(risk_level == 3 && datalogged){
+ }else if(risk_level == 3){
uLCD.cls();
uLCD.locate(3, 7);
uLCD.text_width(2);
@@ -176,6 +179,7 @@
uLCD.printf("waiting");
}
mutex_lock.unlock();
+ lcd_lock.unlock();
}
}