NerfUS mobile node that manages a target for the Nerf gun firing range

Dependencies:   LedController mbed-rtos mbed NerfUSXbee Servomotor TargetManager

Fork of NerfUS by NerfUS

mbed_source/Calibrator.cpp

Committer:
Maxime Dupuis
Date:
2017-04-12
Revision:
51:6bf268cd1a1b
Parent:
49:4475f0760594

File content as of revision 51:6bf268cd1a1b:

#include "Calibrator.hpp"
#include "mbed.h"

Calibrator::Calibrator(Servomotor& servomotor):
    servomotor(servomotor),
    is_bumper_pressed(false)
{
}

void Calibrator::calibrate()
{
    float angle;
 
    for(angle = 50; !is_bumper_pressed && angle <= 125; angle++)
    {
        servomotor.set_angle(angle);
        angle++;
        wait_ms(25);
    }
    angle -= 3;

    servomotor.up_angle = angle;
}

void Calibrator::on_rise()
{
    is_bumper_pressed = true;
}