public static void Main() { // create shift register provider var lcdProvider = new Shifter74Hc595LcdTransferProvider(SPI_Devices.SPI1, Pins.GPIO_PIN_D10, Shifter74Hc595LcdTransferProvider.BitOrder.LSBFirst); // construct the LCD object _lcd = new Lcd(lcdProvider); // set up the LCD's number of columns and rows: _lcd.Begin(16, 2); _modeSwitch = new InterruptPort(Pins.ONBOARD_SW1, false, ResistorModes.Disabled, Port.InterruptMode.InterruptEdgeLow); _modeSwitch.OnInterrupt += OnModeSwitchInterrupt; // run test ChangeMode(); Thread.Sleep(Timeout.Infinite); }
public LCD() { //Switched to shift register solution on 5/31/2011 //var lcdProvider = new GpioLcdTransferProvider( // Pins.GPIO_PIN_D12, // RS // Pins.GPIO_NONE, // RW // Pins.GPIO_PIN_D11, // enable // Pins.GPIO_PIN_D9, // d0 // Pins.GPIO_PIN_D8, // d1 // Pins.GPIO_PIN_D7, // d2 // Pins.GPIO_PIN_D6, // d3 // Pins.GPIO_PIN_D5, // d4 // Pins.GPIO_PIN_D4, // d5 // Pins.GPIO_PIN_D3, // d6 // Pins.GPIO_PIN_D2); // d7 var lcdProvider = new Shifter74Hc595LcdTransferProvider(SPI_Devices.SPI1, SecretLabs.NETMF.Hardware.NetduinoPlus.Pins.GPIO_PIN_D10); // create the LCD interface lcd = new Lcd(lcdProvider); // set up the number of columns and rows: lcd.Begin(16, 2); }
public static void Main() { // create the transfer provider /* // Option 1: Use direct GPIO provider // Initialize the library with the numbers of the interface pins // Use wiring shown here http://arduino.cc/en/uploads/Tutorial/lcd_schem.png var lcdProvider = new GPIO_LCD_TransferProvider(Pins.GPIO_PIN_D12, Pins.GPIO_PIN_D11, //Pins.GPIO_PIN_D10, //Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D8, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D5, Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D3, Pins.GPIO_PIN_D2); */ // Option 2: Use shift register provider var lcdProvider = new Shifter74Hc595LcdTransferProvider(SPI_Devices.SPI1, Pins.GPIO_PIN_D10, Shifter74Hc595LcdTransferProvider.BitOrder.LSBFirst); // create the LCD interface var lcd = new Lcd(lcdProvider); // set up the LCD's number of columns and rows: lcd.Begin(16, 2); // Print a message to the LCD. lcd.Write("hello, world!"); while (true) { // set the cursor to column 0, line 1 lcd.SetCursorPosition(0, 1); // print the number of seconds since reset: lcd.Write((Utility.GetMachineTime().Ticks / 10000).ToString()); Thread.Sleep(100); } }
// Demo from http://bansky.net/blog/2008/10/interfacing-lcd-with-3-wires-from-net-micro-framework public static void Main() { // create the transfer provider var lcdProvider = new Shifter74Hc595LcdTransferProvider(SPI_Devices.SPI1, Pins.GPIO_PIN_D10, Shifter74Hc595LcdTransferProvider.BitOrder.LSBFirst); // create the LCD interface var lcd = new Lcd(lcdProvider); // set up the LCD's number of columns and rows: lcd.Begin(16, 2); // Creating custom characters (Smiley face and gimp) byte[] buffer = new byte[] { 0x07, 0x08, 0x10, 0x10, 0x13, 0x13, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x1C, 0x02, 0x01, 0x01, 0x19, 0x19, 0x01, 0x01, 0x10, 0x10, 0x12, 0x11, 0x10, 0x10, 0x08, 0x07, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x01, 0x01, 0x09, 0x11, 0x01, 0x01, 0x02, 0x1C, 0x15, 0x15, 0x0E, 0x04, 0x04, 0x0A, 0x11, 0x11, 0x04, 0x04, 0x0E, 0x15, 0x04, 0x0A, 0x11, 0x11 }; // Load custom characters to display CGRAM for (int i = 0; i < 8; i++) { lcd.CreateChar(i, buffer, i * 8); } // Turn displat on, turn back light on, hide small cursor, show big blinking cursor lcd.BlinkCursor = true; lcd.Clear(); lcd.Write("Start me up!"); Thread.Sleep(3000); lcd.Clear(); lcd.BlinkCursor = false; // Print the special characters with the face lcd.Write(new byte[] { 0x00, 0x01, 0x02 }, 0, 3); lcd.Write(" .NET Micro"); // Move to second line lcd.SetCursorPosition(0, 1); // Print the special characters with the face lcd.Write(new byte[] { 0x03, 0x04, 0x05 }, 0, 3); lcd.Write(" Framework"); Thread.Sleep(2000); // Blink with back light for (int i = 0; i < 4; i++) { lcd.Backlight = (i % 2) != 0; Thread.Sleep(400); } lcd.Clear(); const string message = "* Hello World! *"; // Let gimp write the message for (int i = 0; i < message.Length; i++) { lcd.SetCursorPosition(i, 1); lcd.WriteByte((byte)(((i % 2) == 0) ? 0x06 : 0x07)); lcd.SetCursorPosition(i, 0); lcd.Write(message[i].ToString()); Thread.Sleep(200); lcd.SetCursorPosition(i, 1); lcd.Write(" "); } Thread.Sleep(1500); lcd.Clear(); lcd.SetCursorPosition(16, 0); lcd.Write("http://bansky.net/blog"); // Scroll the page url while (true) { lcd.ScrollDisplayLeft(); Thread.Sleep(400); } }