-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDigitalOutput.cpp
More file actions
70 lines (62 loc) · 1.94 KB
/
DigitalOutput.cpp
File metadata and controls
70 lines (62 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#include "DigitalOutput.h"
#include "DigitalModule.h"
void DigitalOutput::InitDigitalOutput(UINT32 slot, UINT32 channel)
{
m_channel = channel;
m_module = DigitalModule::GetInstance(slot);
m_module->AllocateDIO(m_channel, false);
}
/**
* Create an instance of a digital output.
* Create a digital output given a channel. The default module is used.
*/
DigitalOutput::DigitalOutput(UINT32 channel)
{
InitDigitalOutput(GetDefaultDigitalModule(), channel);
}
/**
* Create an instance of a digital output.
* Create an instance of a digital output given a slot and channel.
*/
DigitalOutput::DigitalOutput(UINT32 slot, UINT32 channel)
{
InitDigitalOutput(slot, channel);
}
/**
* Free the resources associated with a digital output.
*/
DigitalOutput::~DigitalOutput()
{
m_module->FreeDIO(m_channel);
}
/**
* Set the value of a digital output.
* Set the value of a digital output to either one (true) or zero (false).
*/
void DigitalOutput::Set(UINT32 value)
{
m_module->SetDIO(m_channel, value);
}
/**
* Output a single pulse on the digital output line.
* Send a single pulse on the digital output line where the pulse diration is specified in seconds.
* Maximum pulse length is 0.0016 seconds.
* @param length The pulselength in seconds
*/
void DigitalOutput::Pulse(float length)
{
m_module->Pulse(m_channel, length);
}
/**
* Determine if the pulse is still going.
* Determine if a previously started pulse is still going.
*/
bool DigitalOutput::IsPulsing()
{
return m_module->IsPulsing(m_channel);
}