blob: 5fb50211601fc3f791a509420521ab9a54c3c334 [file] [log] [blame]
Brian Silverman8fce7482020-01-05 13:18:21 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) 2008-2019 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#include "frc/smartdashboard/SendableRegistry.h"
12
13using namespace frc;
14
15constexpr double GearTooth::kGearToothThreshold;
16
17GearTooth::GearTooth(int channel, bool directionSensitive) : Counter(channel) {
18 EnableDirectionSensing(directionSensitive);
19 SendableRegistry::GetInstance().SetName(this, "GearTooth", channel);
20}
21
22GearTooth::GearTooth(DigitalSource* source, bool directionSensitive)
23 : Counter(source) {
24 EnableDirectionSensing(directionSensitive);
25 SendableRegistry::GetInstance().SetName(this, "GearTooth",
26 source->GetChannel());
27}
28
29GearTooth::GearTooth(std::shared_ptr<DigitalSource> source,
30 bool directionSensitive)
31 : Counter(source) {
32 EnableDirectionSensing(directionSensitive);
33 SendableRegistry::GetInstance().SetName(this, "GearTooth",
34 source->GetChannel());
35}
36
37void GearTooth::EnableDirectionSensing(bool directionSensitive) {
38 if (directionSensitive) {
39 SetPulseLengthMode(kGearToothThreshold);
40 }
41}
42
43void GearTooth::InitSendable(SendableBuilder& builder) {
44 Counter::InitSendable(builder);
45 builder.SetSmartDashboardType("Gear Tooth");
46}