RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
DigitalOutput.java
1package robotCore;
2
11public class DigitalOutput
12{
13 private int m_pin;
14 private int m_i2cAddr;
15 private Device m_arduino = Device.getInstance();
16
17 // private void SendCommand(String cmd)
18 // {
19 // if (m_i2cAddr != 0)
20 // {
21 // m_arduino.SendCommand(String.format("i%d%s", m_i2cAddr, cmd));
22 // }
23 // else
24 // {
25 // m_arduino.SendCommand(cmd);
26 // }
27 // }
28
29 private void init(int pin, int i2cAddr)
30 {
31 m_pin = pin;
32 m_i2cAddr = i2cAddr;
33 }
34
39 public DigitalOutput(int pin, int i2cAddr)
40 {
41 init(pin, i2cAddr);
42 }
43
49
50 public DigitalOutput(int pin)
51 {
52 init(pin, Device.k_i2cDefAddr);
53 }
54
60 public void set(boolean high)
61 {
62 m_arduino.sendCommand(m_i2cAddr, TwoWire.k_digitalWrite, (byte) m_pin, (byte) (high ? 1 : 0));
63 }
64
65}
DigitalOutput(int pin, int i2cAddr)