blob: fba5a24e05fbf0699ffb9febfd3621ff5d4ce955 [file] [log] [blame]
Brian Silverman41cdd3e2019-01-19 19:48:58 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
6/*----------------------------------------------------------------------------*/
7
8#include "frc/GearTooth.h"
9
10#include "frc/smartdashboard/SendableBuilder.h"
11
12using namespace frc;
13
14constexpr double GearTooth::kGearToothThreshold;
15
16GearTooth::GearTooth(int channel, bool directionSensitive) : Counter(channel) {
17 EnableDirectionSensing(directionSensitive);
18 SetName("GearTooth", channel);
19}
20
21GearTooth::GearTooth(DigitalSource* source, bool directionSensitive)
22 : Counter(source) {
23 EnableDirectionSensing(directionSensitive);
24 SetName("GearTooth", source->GetChannel());
25}
26
27GearTooth::GearTooth(std::shared_ptr<DigitalSource> source,
28 bool directionSensitive)
29 : Counter(source) {
30 EnableDirectionSensing(directionSensitive);
31 SetName("GearTooth", source->GetChannel());
32}
33
34void GearTooth::EnableDirectionSensing(bool directionSensitive) {
35 if (directionSensitive) {
36 SetPulseLengthMode(kGearToothThreshold);
37 }
38}
39
40void GearTooth::InitSendable(SendableBuilder& builder) {
41 Counter::InitSendable(builder);
42 builder.SetSmartDashboardType("Gear Tooth");
43}