diff --git a/include/pros/distance.hpp b/include/pros/distance.hpp index 9ab2b4e39..fc7a4130d 100644 --- a/include/pros/distance.hpp +++ b/include/pros/distance.hpp @@ -50,7 +50,7 @@ class Distance { * errno. */ - int32_t distance_get(); + int32_t get(); /** * Get the confidence in the distance reading @@ -68,7 +68,7 @@ class Distance { * errno. */ - int32_t distance_get_confidence(); + int32_t get_confidence(); /** * Get the current guess at relative object size @@ -86,7 +86,7 @@ class Distance { * errno. */ - double distance_get_object_size(); + double get_object_size(); /** * Get the object velocity in m/s @@ -100,12 +100,12 @@ class Distance { * errno. */ - double distance_get_object_velocity(); + double get_object_velocity(); /** - * Gets the port number of the motor. + * Gets the port number of the distance sensor. * - * \return The motor's port number. + * \return The distance sensor's port number. */ std::uint8_t get_port(); diff --git a/src/devices/vdml_distance.cpp b/src/devices/vdml_distance.cpp new file mode 100644 index 000000000..c9d85cb46 --- /dev/null +++ b/src/devices/vdml_distance.cpp @@ -0,0 +1,39 @@ +/** + * \file devices/vdml_distance.cpp + * + * Contains functions for interacting with the V5 ADI. + * + * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "pros/distance.hpp" + +namespace pros { +using namespace pros::c; + +Distance::Distance(const std::uint8_t port):_port(port){} + +Distance::get(){ + return distance_get(_port); +} + +Distance::get_confidence(){ + return distance_get_confidence(_port); +} + +Distance::get_object_size(){ + return distance_get_object_size(_port); +} + +Distance::get_object_velocity(){ + return distance_get_object_velocity(_port); +} + +Distance::get_port(){ + return _port; +} +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index e4a07c91a..2cc89c635 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,12 +7,10 @@ * "I was pressed!" and nothing. */ void on_center_button() { - pros::Controller master(pros::E_CONTROLLER_MASTER); static bool pressed = false; pressed = !pressed; if (pressed) { pros::lcd::set_text(2, "I was pressed!"); - master.clear_line(1); } else { pros::lcd::clear_line(2); } @@ -77,9 +75,18 @@ void autonomous() {} */ void opcontrol() { pros::Controller master(pros::E_CONTROLLER_MASTER); - master.set_text(1,0,"Adrenocorticotropic"); + pros::Motor left_mtr(1); + pros::Motor right_mtr(2); while (true) { - + pros::lcd::print(0, "%d %d %d", (pros::lcd::read_buttons() & LCD_BTN_LEFT) >> 2, + (pros::lcd::read_buttons() & LCD_BTN_CENTER) >> 1, + (pros::lcd::read_buttons() & LCD_BTN_RIGHT) >> 0); + int left = master.get_analog(ANALOG_LEFT_Y); + int right = master.get_analog(ANALOG_RIGHT_Y); + + left_mtr = left; + right_mtr = right; + pros::delay(20); } }