Skip to content

Commit

Permalink
added the cpp file for the distance sensor and reverted main
Browse files Browse the repository at this point in the history
  • Loading branch information
mooreBrendan committed Sep 25, 2020
1 parent dda2bbf commit f4d8f53
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 10 deletions.
12 changes: 6 additions & 6 deletions include/pros/distance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Distance {
* errno.
*/

int32_t distance_get();
int32_t get();

/**
* Get the confidence in the distance reading
Expand All @@ -68,7 +68,7 @@ class Distance {
* errno.
*/

int32_t distance_get_confidence();
int32_t get_confidence();

/**
* Get the current guess at relative object size
Expand All @@ -86,7 +86,7 @@ class Distance {
* errno.
*/

double distance_get_object_size();
double get_object_size();

/**
* Get the object velocity in m/s
Expand All @@ -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();

Expand Down
39 changes: 39 additions & 0 deletions src/devices/vdml_distance.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
}
15 changes: 11 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
}

0 comments on commit f4d8f53

Please sign in to comment.