Program for the water play project for the course Software Testing Practical 2016 given at the VU University

Dependencies:   mbed DRV88255 TextLCD Ping mbed-rtos

Revision:
68:b769c0f23406
Parent:
66:133398875949
Child:
72:f8c4f731f0fe
--- a/ProximityController.cpp	Mon Jun 20 10:57:32 2016 +0000
+++ b/ProximityController.cpp	Mon Jun 20 12:48:42 2016 +0000
@@ -1,4 +1,5 @@
 #include "ProximityController.h"
+#include "SensorAlarmController.h"
 
 static Ping pinger(p30);
 static DigitalOut alarmled(LED3);
@@ -10,6 +11,13 @@
     Thread::wait(30);
     range = pinger.Read_cm()/ 2;   
     this->distance = (float)range;
+    
+    if(distance < 0.01) {
+        SensorAlarmController::buzzOnce();
+        setLed(true);
+    } else {
+        setLed(false);
+    }
 }        
 
 float ProximityController::getDistance() {
@@ -17,7 +25,12 @@
 }
 
 float ProximityController::getValue() {
-    this->volume = (DISTANCE_TO_BASE - this->distance) * ((100/12) *10);
+    if(distance < 0.01) {
+        this->volume = -1.0f;    
+    } else {
+        this->volume = (DISTANCE_TO_BASE - this->distance) * ((100.0f/12.0f) * 10);
+    }
+    
     return this->volume;    
 }