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

ProximityController.cpp

Committer:
sbouber1
Date:
2016-06-14
Revision:
28:f4a4ee58d57e
Parent:
27:4f73f754fdc9
Child:
44:7c932cc5991b

File content as of revision 28:f4a4ee58d57e:

#include "ProximityController.h"
#include "rtos.h"

Ping pinger(p30);

float distance_to_base = 14.5;

void ProximityController::update() {
    int range;
     
    pinger.Send();    
    Thread::wait(30);
    range = pinger.Read_cm()/ 2;   
    this->distance = (float)range;
}        

float ProximityController::getDistance()
{
    return this->distance;
}

float ProximityController::getValue() {
    this->volume = (distance_to_base - this->distance) * ((100/12) *10);
    return this->volume;    
}

std::string ProximityController::get_name() {
    return "ProximityController";
}