/// <summary> /// Create a ADJDS311 device /// </summary> /// <param name="I2CDevice">The I2c port to use</param> /// <param name="LedPin">The pin attached to the led</param> public Adjds311(I2c I2CDevice, DigitalOutPin LedPin) : base(0x74, I2CDevice) { _I2C = I2CDevice; _I2C.Enabled = true; led = LedPin; led.MakeDigitalPushPullOut(); WriteByteData(CAP_RED, 15); WriteByteData(CAP_GREEN, 15); WriteByteData(CAP_BLUE, 15); WriteByteData(CAP_CLEAR, 15); WriteByteData(INT_RED_LO, 0x00); WriteByteData(INT_RED_HI, 0x4); WriteByteData(INT_GREEN_LO, 0x00); WriteByteData(INT_GREEN_HI, 0x5); WriteByteData(INT_BLUE_LO, 0x00); WriteByteData(INT_BLUE_HI, 0x9); WriteByteData(INT_CLEAR_LO, 0x00); WriteByteData(INT_CLEAR_HI, 0x2); }
/// <summary> /// Construct a dual half bridge with PWM speed control /// </summary> /// <param name="A">The "A" channel half-bridge input</param> /// <param name="B">The "B" channel half-bridge input</param> /// <param name="Enable">The PWM input used to control the output enable</param> public DualHalfBridge(DigitalOutPin A, DigitalOutPin B, Pwm Enable) { Enable.Enabled = true; Enable.DutyCycle = 0; Enable.Enabled = true; A.MakeDigitalPushPullOut(); B.MakeDigitalPushPullOut(); enablePwm = Enable; this.A = A; this.B = B; }
/// <summary> /// Construct a dual half bridge with no speed control /// </summary> /// <param name="A">The "A" channel half-bridge input</param> /// <param name="B">The "B" channel half-bridge input</param> /// <param name="Enable">An optional Enable pin of the H-bridge</param> public DualHalfBridge(DigitalOutPin A, DigitalOutPin B, DigitalOutPin Enable = null) { if(Enable != null) { Enable.DigitalValue = false; Enable.MakeDigitalPushPullOut(); enable = Enable; } A.MakeDigitalPushPullOut(); B.MakeDigitalPushPullOut(); this.A = A; this.B = B; }
/// <summary> /// Construct a new instance of the Sn74hc166 /// </summary> /// <param name="spiModule">SPI module to use</param> /// <param name="loadPin">latch pin</param> public Sn74hc166(Spi spiModule, DigitalOutPin loadPin) { loadPin.MakeDigitalPushPullOut(); spiModule.Enabled = true; }
public AnalogMux4051(AdcPin adcInput, DigitalOutPin a, DigitalOutPin b, DigitalOutPin c) { }
/// <summary> /// Construct a new HD44780-compatible display /// </summary> /// <param name="iface">The writable parallel interface to use</param> /// <param name="Columns">The number of columns in the display</param> /// <param name="Rows">The number of rows of the display</param> /// <param name="Backlight">The active-high pin to use for the backlight</param> /// <param name="font">The font mode to use</param> public Hd44780(WriteOnlyParallelInterface iface, int Columns, int Rows, DigitalOutPin Backlight = null, FontMode font = FontMode.Font_5x8) : base(Columns, Rows) { if (iface.Width == 8) this.bits = BitMode.EightBit; else if (iface.Width == 4) this.bits = BitMode.FourBit; else throw new ArgumentException("The IParallelInterface bus must be either 4 or 8 bits wide.", "iface"); if (Rows == 1) this.lines = LinesMode.OneLine; else this.lines = LinesMode.TwoOrMoreLines; this.font = font; this.iface = iface; iface.DelayMicroseconds = 50; iface.Enabled = true; byte cmd; if (bits == BitMode.FourBit) { iface.WriteCommand(new uint[] { 0x03 }).Wait(); Task.Delay(10).Wait(); iface.WriteCommand(new uint[] { 0x03 }).Wait(); Task.Delay(10).Wait(); iface.WriteCommand(new uint[] { 0x03 }).Wait(); Task.Delay(10).Wait(); iface.WriteCommand(new uint[] { 0x02 }).Wait(); } cmd = (byte)((byte)Command.FunctionSet | (byte)bits | (byte)lines | (byte)font); writeCommand(cmd).Wait(); Display = true; Clear().Wait(); if (Backlight != null) { this.backlight = Backlight; backlight.MakeDigitalPushPullOut(); } this.Backlight = true; }
/// <summary> /// Construct an STP16CPC26 attached to the output of another shift register /// </summary> /// <param name="upstreamDevice">The upstream device this shift register is attached to</param> /// <param name="OutputEnablePin">The digital pin to use, if any, to control the display state</param> public Stp16cpc26(ChainableShiftRegisterOutput upstreamDevice, DigitalOutPin OutputEnablePin = null) : base(upstreamDevice, 2) { oe = OutputEnablePin; Start(); }
/// <summary> /// Construct an STP16CPC26 attached directly to a board SPI module /// </summary> /// <param name="SpiModule">The board's SPI module</param> /// <param name="LatchPin">The pin to use for latches</param> /// <param name="OutputEnablePin">The output enable pin, if any, to use.</param> public Stp16cpc26(Spi SpiModule, Pin LatchPin, DigitalOutPin OutputEnablePin = null) : base(SpiModule, LatchPin, 2) { oe = OutputEnablePin; Start(); }
/// <summary> /// Construct an <see cref="I2cMux"/> using a standard 4052-style two-bit 4:1 mux. /// </summary> /// <param name="MuxedPort">The upstream port to mux</param> /// <param name="a">The A (S0) input of the 4052</param> /// <param name="b">The B (S1) input of the 4052</param> public I2cMux4052(I2c MuxedPort, DigitalOutPin a, DigitalOutPin b) : base(MuxedPort, 4) { this.a = a; this.b = b; }