blob: e7ae36dcc649804df60b4c0c3eaa456d40778d6c [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
5/*----------------------------------------------------------------------------*/
6
7#include "DigitalInput.h"
8#include "WPIErrors.h"
9
10/**
11 * Create an instance of a Digital Input class.
12 * Creates a digital input given a channel and uses the default module.
13 *
14 * @param channel The digital channel (1..14).
15 */
16DigitalInput::DigitalInput(uint32_t channel)
17{
18 char buf[64];
19 m_channel = channel;
20 int n = sprintf(buf, "dio/%d", channel);
21 m_impl = new SimDigitalInput(buf);
22}
23
24/*
25 * Get the value from a digital input channel.
26 * Retrieve the value of a single digital input channel from the FPGA.
27 */
28uint32_t DigitalInput::Get() const
29{
30 return m_impl->Get();
31}
32
33/**
34 * @return The GPIO channel number that this object represents.
35 */
36uint32_t DigitalInput::GetChannel() const
37{
38 return m_channel;
39}
40
41void DigitalInput::UpdateTable() {
42 if (m_table != nullptr) {
43 m_table->PutBoolean("Value", Get());
44 }
45}
46
47void DigitalInput::StartLiveWindowMode() {
48
49}
50
51void DigitalInput::StopLiveWindowMode() {
52
53}
54
55std::string DigitalInput::GetSmartDashboardType() const {
56 return "DigitalInput";
57}
58
59void DigitalInput::InitTable(std::shared_ptr<ITable> subTable) {
60 m_table = subTable;
61 UpdateTable();
62}
63
64std::shared_ptr<ITable> DigitalInput::GetTable() const {
65 return m_table;
66}