private const string RowPadding = " "; // 20 chars #endregion Fields #region Methods /// <summary> /// 20x4 LCDs wrap rows in order 0->2->1->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); }