2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "GearTooth.h"
|
2016-09-25 16:50:13 -07:00
|
|
|
|
2017-12-04 23:28:33 -08:00
|
|
|
#include "SmartDashboard/SendableBuilder.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
constexpr double GearTooth::kGearToothThreshold;
|
|
|
|
|
|
2016-09-06 00:01:45 -07:00
|
|
|
GearTooth::GearTooth(int channel, bool directionSensitive) : Counter(channel) {
|
2015-06-25 15:07:55 -04:00
|
|
|
EnableDirectionSensing(directionSensitive);
|
2017-12-04 23:28:33 -08:00
|
|
|
SetName("GearTooth", channel);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
GearTooth::GearTooth(DigitalSource* source, bool directionSensitive)
|
2015-06-25 15:07:55 -04:00
|
|
|
: Counter(source) {
|
|
|
|
|
EnableDirectionSensing(directionSensitive);
|
2017-12-04 23:28:33 -08:00
|
|
|
SetName("GearTooth", source->GetChannel());
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
GearTooth::GearTooth(std::shared_ptr<DigitalSource> source,
|
|
|
|
|
bool directionSensitive)
|
2015-06-25 15:07:55 -04:00
|
|
|
: Counter(source) {
|
|
|
|
|
EnableDirectionSensing(directionSensitive);
|
2017-12-04 23:28:33 -08:00
|
|
|
SetName("GearTooth", source->GetChannel());
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
void GearTooth::EnableDirectionSensing(bool directionSensitive) {
|
|
|
|
|
if (directionSensitive) {
|
|
|
|
|
SetPulseLengthMode(kGearToothThreshold);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-04 23:28:33 -08:00
|
|
|
void GearTooth::InitSendable(SendableBuilder& builder) {
|
|
|
|
|
Counter::InitSendable(builder);
|
|
|
|
|
builder.SetSmartDashboardType("Gear Tooth");
|
|
|
|
|
}
|