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

Committer:
joran
Date:
Mon Jun 20 10:53:46 2016 +0000
Revision:
66:133398875949
Parent:
58:b5f0c0f305ff
Child:
68:b769c0f23406
setLed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joran 5:44ce56378b65 1 #include "ProximityController.h"
joran 5:44ce56378b65 2
sbouber1 58:b5f0c0f305ff 3 static Ping pinger(p30);
joran 66:133398875949 4 static DigitalOut alarmled(LED3);
joran 5:44ce56378b65 5
sbouber1 10:fd4670ec0806 6 void ProximityController::update() {
joran 5:44ce56378b65 7 int range;
joran 5:44ce56378b65 8
joran 5:44ce56378b65 9 pinger.Send();
sbouber1 10:fd4670ec0806 10 Thread::wait(30);
joran 5:44ce56378b65 11 range = pinger.Read_cm()/ 2;
sbouber1 10:fd4670ec0806 12 this->distance = (float)range;
sbouber1 10:fd4670ec0806 13 }
sbouber1 10:fd4670ec0806 14
sbouber1 58:b5f0c0f305ff 15 float ProximityController::getDistance() {
joran 25:169672dbab91 16 return this->distance;
joran 25:169672dbab91 17 }
sbouber1 10:fd4670ec0806 18
sbouber1 10:fd4670ec0806 19 float ProximityController::getValue() {
sbouber1 58:b5f0c0f305ff 20 this->volume = (DISTANCE_TO_BASE - this->distance) * ((100/12) *10);
joran 25:169672dbab91 21 return this->volume;
sbouber1 10:fd4670ec0806 22 }
sbouber1 10:fd4670ec0806 23
sbouber1 58:b5f0c0f305ff 24 std::string ProximityController::getName() {
sbouber1 10:fd4670ec0806 25 return "ProximityController";
joran 66:133398875949 26 }
joran 66:133398875949 27
joran 66:133398875949 28 void ProximityController::setLed(bool value){
joran 66:133398875949 29 if (value) alarmled = 1;
joran 66:133398875949 30 if (!value) alarmled = 0;
sbouber1 10:fd4670ec0806 31 }