Пример #1
0
 /// <summary>
 /// Applies the configuration for the current text display
 /// </summary>
 /// <returns>A notification of when the task completes</returns>
 private void ConfigureTextDisplay()
 {
     if (isConfigured)
     {
         SendInstruction(InstructionDefinitions.FUNCTION_SET(is8BitMode, isDoubleLines, !isFont5x8));
     }
 }
Пример #2
0
 /// <summary>
 /// Applies the configuration for the display
 /// </summary>
 /// <returns>A notification of when the task completes</returns>
 private void ConfigureDisplay()
 {
     if (isConfigured)
     {
         SendInstruction(InstructionDefinitions.DISPLAY_ONOFF_CONTROL(isDisplayOn, isCursorOn, isCursorBlinking));
     }
 }
Пример #3
0
 /// <summary>
 /// Writes a string of text to the display
 /// </summary>
 /// <param name="text">The text to display</param>
 /// <returns>A notification of when the task completes</returns>
 public void Write(string text)
 {
     foreach (var c in text)
     {
         BitArray character = new BitArray(new byte[] { Convert.ToByte(c) });
         SendInstruction(InstructionDefinitions.WRITE_DATA(character[7], character[6], character[5], character[4], character[3], character[2], character[1], character[0]));
     }
 }
Пример #4
0
        /// <summary>
        /// Sets the position of the cursor
        /// </summary>
        /// <param name="row">The row to move the cursor to</param>
        /// <param name="column">The column to move the cursor to</param>
        /// <returns>A notification of when the task completes</returns>
        public void SetCursorPosition(int row, int column)
        {
            if (!isDoubleLines)
            {
                row = 0;
            }

            if (row > 1)
            {
                row = 1;
            }

            if (column > 40)
            {
                column = 40;
            }

            BitArray pos = new BitArray(new int[] { ((40 * row) + column) });

            SendInstruction(InstructionDefinitions.SET_DDRAM_ADDRESS(pos[6], pos[5], pos[4], pos[3], pos[2], pos[1], pos[0]));
        }
Пример #5
0
        /// <summary>
        /// The initialisation method, this needs to be called before the screen is ready for use.
        /// </summary>
        /// <param name="rs">The number of the GPIO pin assigned to the RS pin on the display</param>
        /// <param name="rw">The number of the GPIO pin assigned to the RW pin on the display</param>
        /// <param name="enable">The number of the GPIO pin assigned to the Enable pin on the display</param>
        /// <param name="d7">The number of the GPIO pin assigned to the D7 pin on the display</param>
        /// <param name="d6">The number of the GPIO pin assigned to the D6 pin on the display</param>
        /// <param name="d5">The number of the GPIO pin assigned to the D5 pin on the display</param>
        /// <param name="d4">The number of the GPIO pin assigned to the D4 pin on the display</param>
        /// <param name="d3">The number of the GPIO pin assigned to the D3 pin on the display</param>
        /// <param name="d2">The number of the GPIO pin assigned to the D2 pin on the display</param>
        /// <param name="d1">The number of the GPIO pin assigned to the D1 pin on the display</param>
        /// <param name="d0">The number of the GPIO pin assigned to the D0 pin on the display</param>
        /// <returns>A notification of when the task completes</returns>
        public void Init(int rs, int rw, int enable, int d7, int d6, int d5, int d4, int d3, int d2, int d1, int d0)
        {
            var gpio = GpioController.GetDefault();

            rsPin = gpio.OpenPin(rs);
            rsPin.SetDriveMode(GpioPinDriveMode.Output);
            rwPin = gpio.OpenPin(rw);
            rwPin.SetDriveMode(GpioPinDriveMode.Output);
            enablePin = gpio.OpenPin(enable);
            enablePin.SetDriveMode(GpioPinDriveMode.Output);
            enablePin.Write(GpioPinValue.Low);
            d0Pin = gpio.OpenPin(d0);
            d0Pin.SetDriveMode(GpioPinDriveMode.Output);
            d1Pin = gpio.OpenPin(d1);
            d1Pin.SetDriveMode(GpioPinDriveMode.Output);
            d2Pin = gpio.OpenPin(d2);
            d2Pin.SetDriveMode(GpioPinDriveMode.Output);
            d3Pin = gpio.OpenPin(d3);
            d3Pin.SetDriveMode(GpioPinDriveMode.Output);
            d4Pin = gpio.OpenPin(d4);
            d4Pin.SetDriveMode(GpioPinDriveMode.Output);
            d5Pin = gpio.OpenPin(d5);
            d5Pin.SetDriveMode(GpioPinDriveMode.Output);
            d6Pin = gpio.OpenPin(d6);
            d6Pin.SetDriveMode(GpioPinDriveMode.Output);
            d7Pin = gpio.OpenPin(d7);
            d7Pin.SetDriveMode(GpioPinDriveMode.Output);

            isConfigured = true;

            TurnDisplayOff();
            TurnDisplayOn();
            ClearDisplay();
            ConfigureTextDisplay();
            ConfigureDisplay();
            SendInstruction(InstructionDefinitions.ENTRY_MODE_SET(true, false));
            SetCursorPosition(0, 0);
        }
Пример #6
0
 /// <summary>
 /// Clears the display and returns the cursor to the origin (first row, first column)
 /// </summary>
 /// <returns>A notification of when the task completes</returns>
 public void ClearDisplay()
 {
     SendInstruction(InstructionDefinitions.CLEAR_DISPLAY());
     SetCursorPosition(0, 0);
 }