LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
opticalSensor.hpp
Go to the documentation of this file.
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 */
6#pragma once
7
8#include "api.h"
11#include <memory>
12
13namespace okapi {
15 hue,
18};
19
20class OpticalSensor : public ControllerInput<double> {
21 public:
38 OpticalSensor(std::uint8_t iport,
40 bool idisableGestures = true,
41 std::unique_ptr<Filter> ifilter = std::make_unique<PassthroughFilter>());
42
43 virtual ~OpticalSensor() = default;
44
50 double get();
51
57 double getHue() const;
58
64 double getBrightness() const;
65
71 double getSaturation() const;
72
79 int32_t getLedPWM() const;
80
88 int32_t setLedPWM(std::uint8_t ivalue) const;
89
96 int32_t getProximity() const;
97
104 pros::c::optical_rgb_s_t getRGB() const;
105
112 double controllerGet() override;
113
120 int32_t enableGestures() const;
121
128 int32_t disableGestures() const;
129
130 protected:
131 std::uint8_t port;
133 std::unique_ptr<Filter> filter;
134
139};
140} // namespace okapi
PROS API header provides high-level user functionality.
std::unique_ptr< Filter > filter
double getSelectedOutput()
Gets the output directly from the sensor using the selected output.
double controllerGet() override
Get the sensor value for use in a control loop.
OpticalSensor(std::uint8_t iport, OpticalSensorOutput ioutput=OpticalSensorOutput::hue, bool idisableGestures=true, std::unique_ptr< Filter > ifilter=std::make_unique< PassthroughFilter >())
An optical sensor on a V5 port.
double getHue() const
Get the current hue value in the range [0, 360).
double getSaturation() const
Get the current saturation value in the range [0, 1].
int32_t setLedPWM(std::uint8_t ivalue) const
Set the PWM value of the white LED in the range [0, 100].
double getBrightness() const
Get the current brightness value in the range [0, 1].
virtual ~OpticalSensor()=default
int32_t getLedPWM() const
Get the PWM value of the white LED in the range [0, 100].
double get()
Get the current filtered value of the selected output (configured by the constructor).
pros::c::optical_rgb_s_t getRGB() const
Get the processed RGBC data from the sensor.
int32_t getProximity() const
Get the current proximity value in the range [0, 255].
int32_t disableGestures() const
Disable gestures.
int32_t enableGestures() const
Enable gestures.
OpticalSensorOutput output
@ brightness
The amount of light.
@ saturation
The color's intensity relative to its brightness.