public override void ReadBuffer(object sender, BufferEventArgs e) { Runner.AddTask((o) => { if (ReadBegin != null) { ReadBegin(this, e); } if (e.Length == 1) { e.Buffer.buffer[e.Offset] = BCM2835Managed.GPIOExtras.read_bitbang_byte(port); } else { var segment = new ArraySegment <byte>(e.Buffer.buffer, e.Offset, e.Length); BCM2835Managed.GPIOExtras.read_bitbang_buffer(port, segment); } if (ReadEnd != null) { ReadEnd(this, e); } }); }
public unsafe override void WriteBuffer(object sender, BufferEventArgs e) { Runner.AddTask((o) => { if (WriteBegin != null) { WriteBegin(this, e); } if (e.Length == 1) { RaspExtern.Ports.writeNibbleByte(e.Buffer.buffer[e.Offset], dataPin0, dataPin1, dataPin2, dataPin3, clockPin, polarity, lowCycle, highCycle); } else { fixed(byte *bData = e.Buffer.buffer) RaspExtern.Ports.writeNibbleBuffer(bData + e.Offset, (uint)e.Length, dataPin0, dataPin1, dataPin2, dataPin3, clockPin, polarity, lowCycle, highCycle); } if (WriteEnd != null) { WriteEnd(this, e); } }); }
public override void TransferBuffer(object sender, BufferEventArgs e) { Runner.AddTask((o) => { if (TransferBegin != null) { TransferBegin(this, e); } for (int buc = e.Offset; buc < e.Offset + e.Length; buc++) { BCM2835Managed.GPIOExtras.write_nibble_byte(port, rs, e.Buffer.buffer[buc], false); } for (int buc = e.Offset; buc < e.Offset + e.Length; buc++) { e.Buffer.buffer[buc] = BCM2835Managed.GPIOExtras.read_nibble_byte(port, rs); } if (TransferEnd != null) { TransferEnd(this, e); } }); }
public void Input(object sender, BufferEventArgs e) { Runner.AddTask((o) => { bool newState = true; if (e.Buffer.Size - (offset + e.Offset) >= value.Length) { for (int buc = e.Offset + offset; buc < e.Offset + offset + value.Length; buc++) { if (e.Buffer.buffer[buc] != value[buc - offset]) { newState = false; break; } } } else { newState = false; } newState = valueIsHigh ? newState : !newState; if (newState != outputState && Output != null) { outputState = newState; Output(this, new SignalEventArgs { Signal = newState }); } }); }
public unsafe override void ReadBuffer(object sender, BufferEventArgs e) { Runner.AddTask((o) => { if (ReadBegin != null) { ReadBegin(this, e); } if (e.Length == 1) { e.Buffer.buffer[e.Offset] = RaspExtern.Ports.readBitBangByte(dataPin, clockPin, polarity, lowCycle, highCycle); } else { fixed(byte *bData = e.Buffer.buffer) RaspExtern.Ports.readBitBangBuffer(bData + e.Offset, (uint)e.Length, dataPin, clockPin, polarity, lowCycle, highCycle); } if (ReadEnd != null) { ReadEnd(this, e); } }); }
public unsafe override void TransferBuffer(object sender, BufferEventArgs e) { Runner.AddTask((o) => { if (TransferBegin != null) { TransferBegin(this, e); } if (e.Length == 1) { RaspExtern.Ports.writeOctetByte(e.Buffer.buffer[e.Offset], pinList, clockPin, polarity, lowCycle, highCycle); e.Buffer.buffer[e.Offset] = RaspExtern.Ports.readOctetByte(pinList, clockPin, polarity, lowCycle, highCycle); } else { fixed(byte *bData = e.Buffer.buffer) { RaspExtern.Ports.writeOctetBuffer(bData + e.Offset, (uint)e.Length, pinList, clockPin, polarity, lowCycle, highCycle); RaspExtern.Ports.readOctetBuffer(bData + e.Offset, (uint)e.Length, pinList, clockPin, polarity, lowCycle, highCycle); } } if (TransferEnd != null) { TransferEnd(this, e); } }); }
public void Reset(object sender, SignalEventArgs e) { if (e.Signal == clockPolarity) { inputA = null; inputB = null; } }
public void CopyTo(object sender, BufferEventArgs e) { Buffer.BlockCopy(buffer, 0, e.Buffer.buffer, e.Offset, Math.Min((int)(buffer.Length - e.Offset), e.Length)); if (CopiedTo != null) { CopiedTo(this, e); } }
private void Input(BufferEventArgs e, byte ChannelNumber) { Runner.AddTask((o) => { if (currentInput == ChannelNumber) { Output(this, e); } }); }
public void Input(object sender, BufferEventArgs e) { Runner.AddTask((o) => { if (currentOutput != null) { currentOutput(this, e); } }); }
public void CopyFrom(object sender, BufferEventArgs e) { Buffer.BlockCopy(e.Buffer.buffer, 0, buffer, e.Offset, Math.Min((int)(buffer.Length - e.Offset), e.Length)); if (CopiedFrom != null) { CopiedFrom(this, new BufferEventArgs { Buffer = this, Length = e.Length, Offset = e.Offset }); } }
public void Input(object sender, BufferEventArgs e) { Runner.AddTask((o) => { if (Output != null) { Output(this, new ByteEventArgs { Value = e.Buffer.buffer[offset] }); } }); }
public void Input(object sender, BufferEventArgs e) { Runner.AddTask((o) => { BCM2835Managed.bcm2835_delayMicroseconds(delay); if (Output != null) { Output(this, e); } }); }
public void Input(object sender, BufferEventArgs e) { Runner.AddTask((o) => { e.Offset = offset; e.Length = length; if (Output != null) { Output(this, e); } }); }
public void Input(object sender, BufferEventArgs e) { ulong start = RaspExtern.Timers.bcm2835_st_read(); Runner.AddTask((o) => { RaspExtern.Timers.bcm2835_st_delay(start, delay); if (Output != null) { Output(this, e); } }); }
public override unsafe void TransferBuffer(object sender, BufferEventArgs e) { Runner.AddTask((o) => { if (TransferBegin != null) { TransferBegin(this, e); } fixed(byte *bData = &e.Buffer.buffer[e.Offset]) RaspExtern.SPI.bcm2835_spi_transfern(bData, (uint)e.Length); if (TransferEnd != null) { TransferEnd(this, e); } }); }
public override unsafe void WriteBuffer(object sender, BufferEventArgs e) { Runner.AddTask((o) => { if (WriteBegin != null) { WriteBegin(this, e); } fixed(byte *bData = &e.Buffer.buffer[e.Offset]) RaspExtern.I2C.bcm2835_i2c_write(bData, (uint)e.Length); if (WriteEnd != null) { WriteEnd(this, e); } }); }
public override unsafe void TransferBuffer(object sender, BufferEventArgs e) { Runner.AddTask((o) => { if (TransferBegin != null) { TransferBegin(this, e); } ArraySegment <byte> seg = new ArraySegment <byte>(e.Buffer.buffer, e.Offset, e.Length); BCM2835Managed.bcm2835_spi_transfern(seg); if (TransferEnd != null) { TransferEnd(this, e); } }); }
public override unsafe void WriteBuffer(object sender, BufferEventArgs e) { Runner.AddTask((o) => { if (WriteBegin != null) { WriteBegin(this, e); } ArraySegment <byte> seg = new ArraySegment <byte>(e.Buffer.buffer, e.Offset, e.Length); BCM2835Managed.bcm2835_i2c_write(seg); if (WriteEnd != null) { WriteEnd(this, e); } }); }
public void Input(object sender, BufferEventArgs e) { Runner.AddTask((o) => { var val = e.Buffer.buffer[offset + e.Offset]; if (val != outputState) { outputState = val; if (Output != null) { Output(this, new ByteEventArgs { Value = val }); } } }); }
public void WriteHalfBuffer(object sender, BufferEventArgs e) { Runner.AddTask((o) => { if (WriteBegin != null) { WriteBegin(this, e); } for (int buc = e.Offset; buc < e.Offset + e.Length; buc++) { BCM2835Managed.GPIOExtras.write_nibble_byte(port, rs, e.Buffer.buffer[buc], true); } if (WriteEnd != null) { WriteEnd(this, e); } }); }
public void Input(object sender, BufferEventArgs e) { Runner.AddTask((o) => { int count = Math.Min(e.Length - offset, 4); int value = 0; int pos = 0; if (order == ByteOrder.MSB) { for (int buc = e.Offset + offset + count - 1; buc >= e.Offset; buc--) { value |= e.Buffer.buffer[buc] << (pos * 8); pos++; } } else { for (int buc = e.Offset + offset; buc < e.Offset + offset + count; buc++) { value |= e.Buffer.buffer[buc] << (pos * 8); pos++; } } if (outputValue != value) { outputValue = value; if (Output != null) { Output(this, new IntegerEventArgs { Value = outputValue }); } } }); }
public void Input(object sender, BufferEventArgs e) { Runner.AddTask((o) => { bool newOutput = false; switch (condition) { case BufferConditionType.Equal: if (e.Buffer == null && compareValue == null) { newOutput = true; } else if (e.Buffer == null || compareValue == null) { newOutput = false; } else { if (e.Length != compareValue.Size) { newOutput = false; } else { newOutput = true; for (int buc = 0; buc < e.Length; buc++) { if (e.Buffer.buffer[buc + e.Offset] != compareValue.buffer[buc]) { newOutput = false; break; } } } } break; case BufferConditionType.NotEqual: if (e.Buffer == null && compareValue == null) { newOutput = false; } else if (e.Buffer == null || compareValue == null) { newOutput = true; } else { if (e.Length != compareValue.Size) { newOutput = false; } else { newOutput = false; for (int buc = 0; buc < e.Length; buc++) { if (e.Buffer.buffer[buc + e.Offset] != compareValue.buffer[buc]) { newOutput = true; break; } } } } break; } if (newOutput != currentOutput) { currentOutput = newOutput; if (Output != null) { Output(this, new SignalEventArgs { Signal = currentOutput }); } } }); }
public void InputB(object sender, BufferEventArgs e) { inputB = e; }
public abstract void ReadBuffer(object sender, BufferEventArgs e);
public abstract void WriteBuffer(object sender, BufferEventArgs e);
public void Input7(object sender, BufferEventArgs e) { Input(e, 8); }
public abstract void TransferBuffer(object sender, BufferEventArgs e);