private void Write(byte value, byte[] halfAddress) { D4.Write((value & halfAddress[0]) > 0); D5.Write((value & halfAddress[1]) > 0); D6.Write((value & halfAddress[2]) > 0); D7.Write((value & halfAddress[3]) > 0); Enable.Write(true); Enable.Write(false); //Debug.Print("Wrote " + value.ToString()); }
private void Initialize() { //initialize fields isVisible = true; showCursor = false; isBlinking = false; rowAddress = new byte[] { 0x00, 0x40, 0x14, 0x54 }; firstHalfAddress = new byte[] { 0x10, 0x20, 0x40, 0x80 }; secondHalfAddress = new byte[] { 0x01, 0x02, 0x04, 0x08 }; currentRow = 0; dirtyColumns = 0; Thread.Sleep(50); // must wait for a few milliseconds // RS to high = data transfer // RS to low = command/instruction transfer RS.Write(false); // Enable provides a clock function to synchronize data transfer Enable.Write(false); // Set for 4 bit model Write(0x03, secondHalfAddress); Thread.Sleep(4); Write(0x03, secondHalfAddress); Thread.Sleep(4); Write(0x03, secondHalfAddress); Thread.Sleep(150); Write(0x02, secondHalfAddress); // Set the LCD properties byte operationalValue = (byte)((byte)Operational.FourBit | (byte)NumberOfLines | (byte)DotSize); SendCommand((byte)((byte)Command.Operational | operationalValue)); UpdateDisplayOptions(); ClearDisplay(); byte entranceValue = (byte)Entrance.FromLeft | (byte)Entrance.ShiftDecrement; SendCommand((byte)((byte)Command.Entrance | entranceValue)); }