/// <summary> /// ctor /// </summary> public Display(PiAndBash.Driver PiAndBashDriver) { deviceConnection = PiAndBashDriver.i2cConnection; // turn on LCD backlight deviceConnection.SetDirection(Mcp23017Pin.A0, Mcp23017PinDirection.Output); SetBacklight(true); // light is on, let's write var settings = new Hd44780LcdConnectionSettings { ScreenWidth = 16, ScreenHeight = 2 }; settings.Encoding = Encoding.ASCII; configuration = Hd44780Configuration.LoadGpioConfiguration(); connection = new Hd44780LcdConnection(settings, configuration.Pins); connection.Clear(); Console.WriteLine("Display initialised"); }
public static void WriteToLcd() { Console.WriteLine("writing to the lcd"); const ConnectorPin sdaPin = ConnectorPin.P1Pin03; const ConnectorPin sclPin = ConnectorPin.P1Pin05; using (var driver = new I2cDriver(sdaPin.ToProcessor(), sclPin.ToProcessor())) { var deviceConnection = new Mcp23017I2cConnection(driver.Connect(0x20)); Console.WriteLine("Connected"); // turn on LCD backlight (on/off/on) deviceConnection.SetDirection(Mcp23017Pin.A0, Mcp23017PinDirection.Output); deviceConnection.SetPinStatus(Mcp23017Pin.A0, true); Thread.Sleep(500); // wait deviceConnection.SetPinStatus(Mcp23017Pin.A0, false); Thread.Sleep(500); // wait deviceConnection.SetPinStatus(Mcp23017Pin.A0, true); } // light is on, let's write var settings = new Hd44780LcdConnectionSettings { ScreenWidth = 16, ScreenHeight = 2 }; settings.Encoding = Encoding.ASCII; using (Hd44780Configuration configuration = Hd44780Configuration.LoadGpioConfiguration()) using (var connection = new Hd44780LcdConnection(settings, configuration.Pins)) { // connection.SetCustomCharacter(1, new byte[] { 0x0, 0x0, 0x04, 0xe, 0x1f, 0x0, 0x0 }); // connection.SetCustomCharacter(2, new byte[] { 0x0, 0x0, 0x1f, 0xe, 0x04, 0x0, 0x0 }); connection.Clear(); connection.WriteLine("Pi & Bash>_"); Thread.Sleep(750); connection.WriteLine("Test"); Thread.Sleep(750); connection.WriteLine("Thank You"); Thread.Sleep(750); connection.WriteLine("more text"); Thread.Sleep(750); connection.WriteLine("and another bit"); Thread.Sleep(2000); } }