// Stores portData (bit masked On/Off data) for a whole port in // digitalInputData array //[Description("Puts but masked On/Off data for a whole digital port into array")] public void SetDigitalOutputs(int portNumber, int portData) { int previous = digitalInputData[portNumber]; digitalInputData[portNumber] = portData; int pin = portNumber * 8; int mask = 1; int changed = previous ^ portData; for (int i = 0; i <= 7; i++) { if ((changed & mask) != 0) { int pinIndex = pin + i; RemotePin p = _Pins[pinIndex]; if (p != null) { p.Value = DigitalRead(pinIndex); } } mask = mask << 1; } }
// Stores analog value data in array for each analog pin //[Description("Stores analog value data in array")] public void SetAnalogOutput(int pin, int value) { RemotePin p = _Pins[pin]; if (p != null) { p.Value = value; } }
private void ReportAnalog(int channel, int onOff) { int anPin = Board.ANALOG_TO_PIN(channel); if (anPin < Board.TOTAL_PINS) { RemotePin p = _Pins[anPin]; if (p != null) { p.AnalogReportEnabled = onOff != 0; } } }
public void PinMode(int pin, int mode) { RemotePin p = _Pins[pin]; if (p != null) { if (p.PinMode == ANALOG) { _analogPins.Remove(p); } p.PinMode = mode; if (mode == ANALOG) { _analogPins.Add(p); } } }
private void ReportDigital(int channel, int onOff) { int pin = 8 * channel; for (int i = 0; i <= 7; i++) { if (pin < Board.TOTAL_PINS) { RemotePin p = _Pins[pin]; if (p != null) { p.DigitalReportEnabled = (onOff != 0); } pin += 1; } } }