public static void Main()
        {
            var lcdProvider = new GpioLcdTransferProvider(Stm32F4Discovery.Pins.PD1, Stm32F4Discovery.Pins.PD2,
                                                          Stm32F4Discovery.Pins.PD9, Stm32F4Discovery.Pins.PD11,
                                                          Stm32F4Discovery.Pins.PD10, Stm32F4Discovery.Pins.PD8);

            var lcd = new Lcd(lcdProvider);
            lcd.Begin(16, 2); //columns, rows

            //znaki specjalne
            //http://www.quinapalus.com/hd44780udg.html
            var customCharacters = new[]
                                       {
                                           new byte[] {0x00, 0x0a, 0x15, 0x11, 0x11, 0x0a, 0x04, 0x00}, //serce
                                           new byte[] {0x04, 0x02, 0x01, 0x1f, 0x01, 0x02, 0x04, 0x00} //strzalka
                                       };

            //ladowanie znakow specjalnych
            for (int i = 0; i < customCharacters.Length; i++)
                lcd.CreateChar(i, customCharacters[i]);

            lcd.Clear();
            lcd.Write("* Hello World! *");
            Thread.Sleep(3000);

//            lcd.Clear();
//            lcd.Encoding = Encoding.UTF8;
//            lcd.Write("ĄąĆćĘꣳŃńÓ󌜯ż");
//            Thread.Sleep(3000);

            lcd.Clear();
            lcd.WriteByte(0); //pierwszy znak specjalny
            Thread.Sleep(2000);
            lcd.WriteByte(1); //drugi znak specjalny
            Thread.Sleep(3000);

            //nastepna linia
            lcd.SetCursorPosition(0, 1);
            lcd.Write("#     Bye...   #");
        }
Example #2
0
 private static void initializeLCD(I2CBus bus)
 {
     // Use I2C provider
     // Default configuration coresponds to Adafruit's LCD backpack
     // Initialize provider (multiple devices can be attached to same bus)
     var lcdProvider = new MCP23008LcdTransferProvider(_bus);
     // Create the LCD interface
     LCD = new Lcd(lcdProvider);
     // Set the LCD Color property = Led.  This is for cleaner code only.
     //LCD.Color = Led;
     // Set up the LCD's number of columns and rows:
     LCD.Begin(20, 4);
     // Clear the LCD
     LCD.Clear();
 }
Example #3
0
        public static void Main()
        {
            // initialise the LCD display
            var ledPort = new OutputPort(Pins.ONBOARD_LED, false);
            var backlightPort = new OutputPort(Pins.GPIO_PIN_D3, false);
            var lcdProvider = new MicroLiquidCrystal.GpioLcdTransferProvider(
                Pins.GPIO_PIN_D8,  // RS
                Pins.GPIO_PIN_D9,  // ENABLE
                Pins.GPIO_PIN_D4,  // D4
                Pins.GPIO_PIN_D5,  // D5
                Pins.GPIO_PIN_D6,  // D6
                Pins.GPIO_PIN_D7); // D7
            var lcd = new Lcd(lcdProvider);
            lcd.Begin(16, 2);

            lcd.Clear();
            lcd.SetCursorPosition(2, 0);

            backlightPort.Write(true);

            lcd.Write("Ready ... ");

            const int interval = 10;
            const int reset = 1000;
            int duration = 0;
            while (true)
            {
                // set the cursor to column 0, line 1
                lcd.SetCursorPosition(0, 1);

                // print the number of seconds since reset:
                var time = Utility.GetMachineTime();
                lcd.Write(time.ToString());

                ledPort.Write(duration > reset/2);

                Thread.Sleep(interval);
                duration += interval;
                if (duration >= reset)
                    duration = 0;
            }
        }
Example #4
0
        private const string RowPadding = "                    "; // 20 chars

        #endregion Fields

        #region Methods

        /// <summary>
        /// 20x4 LCDs wrap rows in order 0-&gt;2-&gt;1-&gt;3 due to its memory configuration. This compensates by modifiying the string to write.
        /// </summary>
        /// <param name="lcd">
        /// The lcd module.
        /// </param>
        /// <param name="text">
        /// The text to write to the LCD.
        /// </param>
        public static void Write20X4(Lcd lcd, string text)
        {
            lcd.Clear();
            lcd.Home();

            var memoryMappedText = text.Substring(0, Math.Min(text.Length, 20));
            if (text.Length > 40)
            {
                memoryMappedText += PadRight(text.Substring(40, Math.Min(text.Length - 40, 20)));
                memoryMappedText += PadRight(text.Substring(20, Math.Min(text.Length - 20, 20)));

                if (text.Length > 60)
                {
                    memoryMappedText += text.Substring(60, Math.Min(text.Length - 60, 20));
                }
            }
            else if (text.Length > 20)
            {
                memoryMappedText += RowPadding;
                memoryMappedText += PadRight(text.Substring(20, Math.Min(text.Length - 20, 20)));
            }

            lcd.Write(memoryMappedText);
        }
Example #5
0
        private static void ShowMessage(string message, Lcd display)
        {
            display.Clear();
            var lines = message.Split(';');
            display.SetCursorPosition(0, 0);
            display.Write(lines[0]);

            if (lines.Length != 2) return;

            display.SetCursorPosition(0, 1);
            display.Write(lines[1]);
        }
Example #6
0
        // 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);
            }
        }