public Gc9a01(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin) : base(device, spiBus, chipSelectPin, dcPin, resetPin, 240, 240, DisplayColorMode.Format16bppRgb565) { Initialize(); SetRotation(Rotation.Normal); }
public Ssd1327(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin) { this.spiBus = (SpiBus)spiBus; spiBuffer = new byte[Width * Height / 2]; spiReceive = new byte[Width * Height / 2]; dataCommandPort = device.CreateDigitalOutputPort(dcPin, false); if (resetPin != null) { resetPort = device.CreateDigitalOutputPort(resetPin, true); } if (chipSelectPin != null) { chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin, false); } spiPeripheral = new SpiPeripheral(spiBus, chipSelectPort); Initialize(); Thread.Sleep(300); FillBuffer(); Show(); }
public MeadowApp() { led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); var config = new SpiClockConfiguration(10000000, SpiClockConfiguration.Mode.Mode0); ISpiBus spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); radio = new Nrf24l01( device: Device, spiBus: spiBus, chipEnablePin: Device.Pins.D13, chipSelectLine: Device.Pins.D12, interruptPin: Device.Pins.D00); radio.SetChannel(76); radio.OpenWritingPipe(Encoding.UTF8.GetBytes(address)); radio.SetPALevel(0); radio.StopListening(); led.SetColor(RgbLed.Colors.Green); while (true) { string helloWorld = "Hello World"; radio.Write(Encoding.UTF8.GetBytes(helloWorld), (byte)(helloWorld.Length)); Console.WriteLine($"Sending: {helloWorld} \n"); Thread.Sleep(1000); } }
public RegisterManager(IIODevice device, ISpiBus spiBus, IPin chipSelectPin) { // Chip select pin configuration ChipSelectGpioPin = device.CreateDigitalOutputPort(chipSelectPin, initialState: true); Rfm9XLoraModem = new SpiPeripheral(spiBus, ChipSelectGpioPin); }
/// <summary> /// Initializes SPI connection and control pins /// </summary> /// <param name="chipEnablePin"> /// Number representing the chip enable pin. This pin will be set to drive output /// </param> /// <param name="chipSelectLine"> /// Number representing the chip select line. For RPi2, this is typically 0 /// </param> /// <param name="interruptPin"> /// Number representing the interrupt pin. This should be a Pull-up pin, and will drive Input /// </param> public void Initialize(IIODevice device, ISpiBus spiBus, IPin chipEnablePin, IPin chipSelectLine, IPin interruptPin) { _SpiBus = spiBus; _cePin = device.CreateDigitalOutputPort(chipEnablePin, false); _csPin = device.CreateDigitalOutputPort(chipSelectLine, false); _irqPin = device.CreateDigitalInputPort(interruptPin, InterruptMode.EdgeFalling, resistorMode: ResistorMode.PullUp); _irqPin.Changed += InterruptGpioPin_ValueChanged; // Module reset time Task.Delay(100).GetAwaiter().GetResult(); IsInitialized = true; // Set reasonable default values Address = Encoding.UTF8.GetBytes("NRF1"); DataRate = DataRate.DR2Mbps; IsDynamicPayload = true; IsAutoAcknowledge = true; FlushReceiveBuffer(); FlushTransferBuffer(); ClearIrqMasks(); SetRetries(5, 60); // Setup, CRC enabled, Power Up, PRX SetReceiveMode(); }
private static St7789 InitializeLcdScreen(out int displayWidth, out int displayHeight, out GraphicsLibrary graphicsLibrary) { Console.WriteLine("Initializing LCD screen..."); SpiClockConfiguration config = new SpiClockConfiguration( speedKHz: 6000, SpiClockConfiguration.Mode.Mode3); ISpiBus spiBus = Device.CreateSpiBus( Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); St7789 st7789 = new St7789( device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240 ); displayWidth = Convert.ToInt32(st7789.Width); displayHeight = Convert.ToInt32(st7789.Height); graphicsLibrary = new GraphicsLibrary(st7789) { Rotation = GraphicsLibrary.RotationType._270Degrees }; LoadScreen(graphicsLibrary, displayWidth, displayHeight); return(st7789); }
public MeadowApp() { led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); var config = new SpiClockConfiguration(10000000, SpiClockConfiguration.Mode.Mode0); ISpiBus spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); radio = new Nrf24l01( device: Device, spiBus: spiBus, chipEnablePin: Device.Pins.D13, chipSelectLine: Device.Pins.D12, interruptPin: Device.Pins.D00); radio.SetChannel(76); radio.OpenReadingPipe(0, Encoding.UTF8.GetBytes(address)); radio.SetPALevel(0); radio.StartListening(); led.SetColor(RgbLed.Colors.Green); byte[] text = new byte[32]; while (true) { if (radio.IsAvailable()) { radio.Read(text, (byte)text.Length); Thread.Sleep(1000); } } }
public ST7735(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin, uint width, uint height, DisplayType displayType = DisplayType.ST7735R) : base(device, spiBus, chipSelectPin, dcPin, resetPin, width, height) { this.displayType = displayType; Initialize(); }
internal Ms5611Spi(ISpiBus spi, IPin chipSelect, Ms5611.Resolution resolution) : base(resolution) { _spi = spi; _chipSelect = chipSelect; throw new NotImplementedException(); }
public MeadowApp() { Console.WriteLine($"SPI TEST"); _chipSelect = Device.CreateDigitalOutputPort(Device.Pins.D04); _spiBus = Device.CreateSpiBus(); _peripheral = new SampleSpi(_spiBus, _chipSelect); }
public Ili9488(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin, uint width = 320, uint height = 480, DisplayColorMode displayColorMode = DisplayColorMode.Format12bppRgb444) : base(device, spiBus, chipSelectPin, dcPin, resetPin, width, height, displayColorMode) { Initialize(); SetRotation(Rotation.Normal); }
public MeadowApp() { Console.WriteLine("TftSpi sample"); Console.WriteLine("Create Spi bus"); spiBus = Device.CreateSpiBus(3000); Console.WriteLine("Create display driver instance"); display = new Ssd1351(device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 128, height: 128); Console.WriteLine("Create graphics lib"); var graphicsLib = new GraphicsLibrary(display); graphicsLib.CurrentFont = new Font8x12(); graphicsLib.Clear(); graphicsLib.DrawCircle(80, 80, 40, Meadow.Foundation.Color.Cyan, false); int indent = 0; int spacing = 10; int y = indent; graphicsLib.DrawText(indent, y, "Meadow F7 (SSD1351)"); graphicsLib.DrawText(indent, y += spacing, "Red", Meadow.Foundation.Color.Red); graphicsLib.DrawText(indent, y += spacing, "Purple", Meadow.Foundation.Color.Purple); graphicsLib.DrawText(indent, y += spacing, "BlueViolet", Meadow.Foundation.Color.BlueViolet); graphicsLib.DrawText(indent, y += spacing, "Blue", Meadow.Foundation.Color.Blue); graphicsLib.DrawText(indent, y += spacing, "Cyan", Meadow.Foundation.Color.Cyan); graphicsLib.DrawText(indent, y += spacing, "LawnGreen", Meadow.Foundation.Color.LawnGreen); graphicsLib.DrawText(indent, y += spacing, "GreenYellow", Meadow.Foundation.Color.GreenYellow); graphicsLib.DrawText(indent, y += spacing, "Yellow", Meadow.Foundation.Color.Yellow); graphicsLib.DrawText(indent, y += spacing, "Orange", Meadow.Foundation.Color.Orange); graphicsLib.DrawText(indent, y += spacing, "Brown", Meadow.Foundation.Color.Brown); Console.WriteLine("Show"); graphicsLib.Show(); Console.WriteLine("Show complete"); }
public St7735(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin, uint width, uint height, DisplayType displayType = DisplayType.ST7735R, DisplayColorMode displayColorMode = DisplayColorMode.Format12bppRgb444) : base(device, spiBus, chipSelectPin, dcPin, resetPin, width, height, displayColorMode) { this.displayType = displayType; Initialize(); }
public Apa102(ISpiBus spiBus, PixelOrder pixelOrder = PixelOrder.BGR, bool autoWrite = false, int width = 1, int height = 1) : this(spiBus, width *height, pixelOrder, autoWrite) { this.width = width; this.height = height; }
/// <summary> /// Create a new ADXL362 object using the specified SPI module. /// </summary> /// <param name="spiBus">Spi Bus object</param> /// <param name="chipSelect">Chip select pin.</param> public Adxl362(IIODevice device, ISpiBus spiBus, IPin chipSelect) { // // ADXL362 works in SPI mode 0 (CPOL = 0, CPHA = 0). // _adxl362 = new SpiPeripheral(spiBus, device.CreateDigitalOutputPort(chipSelect)); Reset(); Start(); }
/// <summary> /// Create a new SSD1306 object using the default parameters for /// </summary> /// <remarks> /// Note that by default, any pixels out of bounds will throw and exception. /// This can be changed by setting the <seealso cref="IgnoreOutOfBoundsPixels" /> /// property to true. /// </remarks> /// protected SSD1306(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin) { dataCommandPort = device.CreateDigitalOutputPort(dcPin, false); resetPort = device.CreateDigitalOutputPort(resetPin, true); chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin, false); _spiPeripheral = new SpiPeripheral(spiBus, chipSelectPort); connectionType = ConnectionType.SPI; }
void Initialize() { Console.WriteLine("Initialize hardware..."); ISpiBus spiBus = Device.CreateSpiBus(); //Not used but is need to create the SPI Peripheral IDigitalOutputPort spiPeriphChipSelect = Device.CreateDigitalOutputPort(Device.Pins.D04); apa102 = new Apa102(spiBus, spiPeriphChipSelect, 150, Apa102.PixelOrder.BGR); }
public ArducamMini(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, II2cBus i2cBus, byte address = 0x30) { i2cDevice = new I2cPeripheral(i2cBus, address); chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin); spiDevice = new SpiPeripheral(spiBus, chipSelectPort); Initialize(); }
public Max7219(ISpiBus spiBus, IDigitalOutputPort csPort, int deviceCount = 0, bool characterMode = false) { max7219 = new SpiPeripheral(spiBus, csPort); DeviceCount = deviceCount; _buffer = new byte[DeviceCount, NumDigits]; _writeBuffer = new byte[2 * DeviceCount]; Initialize(characterMode); }
/* * GND * VCC 3.3-5V * LCK - LCD internal register clock line * RS - LCD internal register selection * CS - Chip select * WR - LCD data input * SCL - Clock signal * MOSI - Device data output */ public St7687s(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin lckPin, IPin wrPin, IPin rsPin) { lckPort = device.CreateDigitalOutputPort(lckPin, false); wrPort = device.CreateDigitalOutputPort(wrPin, false); rsPort = device.CreateDigitalOutputPort(rsPin, false); chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin); spiPerihperal = new SpiPeripheral(spiBus, chipSelectPort); Init(); }
public Max7219(ISpiBus spiBus, IDigitalOutputPort csPort, int deviceCount = 1, Max7219Type maxMode = Max7219Type.Display) { max7219 = new SpiPeripheral(spiBus, csPort); DeviceCount = deviceCount; _buffer = new byte[DeviceCount, NumDigits]; _writeBuffer = new byte[2 * DeviceCount]; Initialize(maxMode); }
/// <summary> /// Create a new SSD1306 object using the default parameters for /// </summary> /// <remarks> /// Note that by default, any pixels out of bounds will throw and exception. /// This can be changed by setting the <seealso cref="IgnoreOutOfBoundsPixels" /> /// property to true. /// </remarks> /// <param name="displayType">Type of SSD1306 display</param> /// public SSD1306Bitmap(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin, DisplayType displayType) { this.dataCommandPort = device.CreateDigitalOutputPort(dcPin, false); this.resetPort = device.CreateDigitalOutputPort(resetPin, true); this.chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin, false); this.spiPeripheral = new SpiPeripheral(spiBus, chipSelectPort); this.connectionType = ConnectionType.SPI; this.InitSSD1306(displayType); }
public MeadowApp() { try { var config = new Meadow.Hardware.SpiClockConfiguration(2000, SpiClockConfiguration.Mode.Mode0); ISpiBus spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); Radio.OnDataReceived += Radio_OnDataReceived; Radio.OnTransmitFailed += Radio_OnTransmitFailed; Radio.OnTransmitSuccess += Radio_OnTransmitSuccess; Radio.Initialize(Device, spiBus, Device.Pins.D09, Device.Pins.D10, Device.Pins.D11); Radio.Address = Encoding.UTF8.GetBytes(DeviceAddress); Radio.Channel = nRF24Channel; Radio.PowerLevel = PowerLevel.High; Radio.DataRate = DataRate.DR250Kbps; Radio.IsEnabled = true; Radio.IsAutoAcknowledge = true; Radio.IsDyanmicAcknowledge = false; Radio.IsDynamicPayload = true; Console.WriteLine($"Address: {Encoding.UTF8.GetString(Radio.Address)}"); Console.WriteLine($"Channel: {Radio.Channel}"); Console.WriteLine($"Frequency: {Radio.Frequency}"); Console.WriteLine($"PowerLevel: {Radio.PowerLevel}"); Console.WriteLine($"DataRate: {Radio.DataRate}"); Console.WriteLine($"IsEnabled: {Radio.IsEnabled}"); Console.WriteLine($"IsAutoAcknowledge: {Radio.IsAutoAcknowledge}"); Console.WriteLine($"IsDynamicAcknowledge: {Radio.IsDyanmicAcknowledge}"); Console.WriteLine($"IsDynamicPayload: {Radio.IsDynamicPayload}"); Console.WriteLine($"IsInitialized: {Radio.IsInitialized}"); Console.WriteLine($"IsPowered: {Radio.IsPowered}"); while (true) { string payload = "hello " + DateTime.Now.ToShortTimeString(); Console.WriteLine($"{DateTime.UtcNow:HH:mm:ss}-TX {payload.Length} byte message {payload}"); Radio.SendTo(Encoding.UTF8.GetBytes(BaseStationAddress), Encoding.UTF8.GetBytes(payload)); Task.Delay(10000).Wait(); } } catch (Exception ex) { Console.WriteLine(ex.Message); return; } }
public Nrf24l01( IIODevice device, ISpiBus spiBus, IPin chipEnablePin, IPin chipSelectLine, IPin interruptPin) : this( spiBus, device.CreateDigitalOutputPort(chipEnablePin), device.CreateDigitalOutputPort(chipSelectLine), device.CreateDigitalInputPort(interruptPin)) { }
/// <summary> /// Create a new SSD1306 object using the default parameters for /// </summary> /// <remarks> /// Note that by default, any pixels out of bounds will throw and exception. /// This can be changed by setting the <seealso cref="IgnoreOutOfBoundsPixels" /> /// property to true. /// </remarks> /// <param name="displayType">Type of SSD1306 display (default = 128x64 pixel display).</param> /// public SSD1306(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin, DisplayType displayType = DisplayType.OLED128x64) { dataCommandPort = device.CreateDigitalOutputPort(dcPin, false); resetPort = device.CreateDigitalOutputPort(resetPin, true); chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin, false); _spiPeripheral = new SpiPeripheral(spiBus, chipSelectPort); connectionType = ConnectionType.SPI; InitSSD1306(displayType); }
/// <summary> /// Create a new ST7565 object using the default parameters for /// </summary> public ST7565(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin, uint width = 128, uint height = 64) { dataCommandPort = device.CreateDigitalOutputPort(dcPin, false); resetPort = device.CreateDigitalOutputPort(resetPin, false); var chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin); spiPerihperal = new SpiPeripheral(spiBus, chipSelectPort); Width = width; Height = height; InitST7565(); }
public PCD8544(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin) { spiBuffer = new byte[Width * Height / 8]; spiReceive = new byte[Width * Height / 8]; dataCommandPort = device.CreateDigitalOutputPort(dcPin, true); resetPort = device.CreateDigitalOutputPort(resetPin, true); var chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin); spi = (SpiBus)spiBus; spiDisplay = new SpiPeripheral(spiBus, chipSelectPort); Initialize(); }
public DisplayTftSpiBase(IIODevice device, ISpiBus spiBus, IPin chipSelectPin, IPin dcPin, IPin resetPin, uint width, uint height) { _width = width; _height = height; spiBuffer = new byte[_width * _height * sizeof(ushort)]; dataCommandPort = device.CreateDigitalOutputPort(dcPin, false); resetPort = device.CreateDigitalOutputPort(resetPin, true); chipSelectPort = device.CreateDigitalOutputPort(chipSelectPin, false); spiDisplay = new SpiPeripheral(spiBus, chipSelectPort); }
/// <remarks>NOTE: The dotstar feather by default is not connected to the SPI MOSI or SCK pins. /// https://learn.adafruit.com/adafruit-dotstar-featherwing-adafruit/pinouts /// </remarks> void Initialize() { Console.WriteLine("Initialize hardware..."); ISpiBus spiBus = Device.CreateSpiBus(); IDigitalOutputPort spiPeriphChipSelect = Device.CreateDigitalOutputPort(Device.Pins.D04); dotStarWing = new DotstarWing(spiBus, spiPeriphChipSelect); graphics = new GraphicsLibrary(dotStarWing); graphics.CurrentFont = new Font4x8(); dotStarWing.SetPenColor(Color.Blue); dotStarWing.Brightness = 0.1f; }
public Max7219(ISpiBus spiBus, IDigitalOutputPort csPort, int deviceRows, int deviceColumns, Max7219Type maxMode = Max7219Type.Display) { spi = (SpiBus)spiBus; chipSelectPort = csPort; max7219 = new SpiPeripheral(spiBus, csPort); DeviceRows = deviceRows; DeviceColumns = deviceColumns; _buffer = new byte[DeviceCount, NumDigits]; _writeBuffer = new byte[2 * DeviceCount]; _readBuffer = new byte[2 * DeviceCount]; Initialize(maxMode); }