private static void Lcd(GpioDriver driver) { const int registerSelectPinNumber = 0; const int enablePinNumber = 5; int[] dataPinNumbers = { 6, 16, 20, 21 }; using (var controller = new GpioController(driver)) { GpioPin registerSelectPin = controller.OpenPin(registerSelectPinNumber); GpioPin enablePin = controller.OpenPin(enablePinNumber); GpioPin[] dataPins = controller.OpenPins(dataPinNumbers); var lcd = new LcdController(registerSelectPin, enablePin, dataPins); lcd.Begin(16, 2); lcd.Print("hello, world!"); Stopwatch watch = Stopwatch.StartNew(); while (watch.Elapsed.TotalSeconds < 15) { lcd.SetCursor(0, 1); lcd.Print($"{watch.Elapsed.TotalSeconds:0.00} seconds"); } } }
internal static void Lcd(string message) { const int registerSelectPinNumber = 0; const int enablePinNumber = 5; int[] dataPinNumbers = { 6, 16, 20, 21 }; using (var driver = new UnixDriver()) using (var controller = new GpioController(driver)) { GpioPin registerSelectPin = controller.OpenPin(registerSelectPinNumber); GpioPin enablePin = controller.OpenPin(enablePinNumber); GpioPin[] dataPins = controller.OpenPins(dataPinNumbers); var lcd = new LcdController(registerSelectPin, enablePin, dataPins); lcd.Begin(16, 2); lcd.Print(message); } }
private static void I2c_Color_Lcd(GpioDriver driver) { const int registerSelectPinNumber = 0; const int enablePinNumber = 5; int[] dataPinNumbers = { 6, 16, 20, 21 }; using (var controller = new GpioController(driver)) { GpioPin registerSelectPin = controller.OpenPin(registerSelectPinNumber); GpioPin enablePin = controller.OpenPin(enablePinNumber); GpioPin[] dataPins = controller.OpenPins(dataPinNumbers); var lcd = new LcdController(registerSelectPin, enablePin, dataPins); lcd.Begin(16, 2); var settings = new I2cConnectionSettings(s_i2cBusId, RgbColorSensor.DefaultI2cAddress); var sensor = new RgbColorSensor(settings); Color_Lcd(lcd, sensor); } }
private static void I2c_Pressure_Lcd(GpioDriver driver) { const int registerSelectPinNumber = 0; const int enablePinNumber = 5; int[] dataPinNumbers = { 6, 16, 20, 21 }; using (var controller = new GpioController(driver, PinNumberingScheme.Bcm)) { Pin registerSelectPin = controller.OpenPin(registerSelectPinNumber); Pin enablePin = controller.OpenPin(enablePinNumber); Pin[] dataPins = controller.OpenPins(dataPinNumbers); var lcd = new LcdController(registerSelectPin, enablePin, dataPins); lcd.Begin(16, 2); var settings = new I2cConnectionSettings(1, PressureTemperatureHumiditySensor.DefaultI2cAddress); var sensor = new PressureTemperatureHumiditySensor(settings); Pressure_Lcd(lcd, sensor); } }
private static void Spi_Pressure_Lcd(GpioDriver driver) { const int registerSelectPinNumber = 0; const int enablePinNumber = 5; const int chipSelectLinePinNumber = 8; int[] dataPinNumbers = { 6, 16, 20, 21 }; using (var controller = new GpioController(driver)) { GpioPin registerSelectPin = controller.OpenPin(registerSelectPinNumber); GpioPin enablePin = controller.OpenPin(enablePinNumber); GpioPin[] dataPins = controller.OpenPins(dataPinNumbers); var lcd = new LcdController(registerSelectPin, enablePin, dataPins); lcd.Begin(16, 2); GpioPin chipSelectLinePin = controller.OpenPin(chipSelectLinePinNumber); var settings = new SpiConnectionSettings(s_spiBusId, 0); var sensor = new PressureTemperatureHumiditySensor(chipSelectLinePin, settings); Pressure_Lcd(lcd, sensor); } }