blob: 8a193c73645c1e6b1925b913f066eb4b478d865d [file] [log] [blame]
jerrymf1579332013-02-07 01:56:28 +00001/*----------------------------------------------------------------------------*/
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#ifndef DIGITAL_OUTPUT_H_
8#define DIGITAL_OUTPUT_H_
9
10#include "DigitalSource.h"
11#include "LiveWindow/LiveWindowSendable.h"
12#include "tables/ITableListener.h"
13
14class DigitalModule;
15
16/**
17 * Class to write to digital outputs.
18 * Write values to the digital output channels. Other devices implemented elsewhere will allocate
19 * channels automatically so for those devices it shouldn't be done here.
20 */
21class DigitalOutput : public DigitalSource, public ITableListener, public LiveWindowSendable
22{
23public:
24 explicit DigitalOutput(UINT32 channel);
25 DigitalOutput(UINT8 moduleNumber, UINT32 channel);
26 virtual ~DigitalOutput();
27 void Set(UINT32 value);
28 UINT32 GetChannel();
29 void Pulse(float length);
30 bool IsPulsing();
31 void SetPWMRate(float rate);
32 void EnablePWM(float initialDutyCycle);
33 void DisablePWM();
34 void UpdateDutyCycle(float dutyCycle);
35
36 // Digital Source Interface
37 virtual UINT32 GetChannelForRouting();
38 virtual UINT32 GetModuleForRouting();
39 virtual bool GetAnalogTriggerForRouting();
40 virtual void RequestInterrupts(tInterruptHandler handler, void *param);
41 virtual void RequestInterrupts();
42
43 void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
44
45 virtual void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew);
46 void UpdateTable();
47 void StartLiveWindowMode();
48 void StopLiveWindowMode();
49 std::string GetSmartDashboardType();
50 void InitTable(ITable *subTable);
51 ITable * GetTable();
52
53private:
54 void InitDigitalOutput(UINT8 moduleNumber, UINT32 channel);
55
56 UINT32 m_channel;
57 UINT32 m_pwmGenerator;
58 DigitalModule *m_module;
59
60 ITable *m_table;
61};
62
63#endif