void CharacterDisplayClock() { display.ClearLines(); display.WriteLine($"Meadow RTC is now", 0); display.WriteLine($"available in b3.9", 1); while (true) { DateTime clock = DateTime.Now; display.WriteLine($"{clock:MM}/{clock:dd}/{clock:yyyy}", 2); display.WriteLine($"{clock:hh}:{clock:mm}:{clock:ss} {clock:tt}", 3); Thread.Sleep(1000); } }
void TestCharacterDisplay() { Console.WriteLine("TestCharacterDisplay..."); display.WriteLine("Hello", 0); display.WriteLine("Display", 1); Thread.Sleep(1000); display.WriteLine("Will delete in", 0); int count = 5; while (count > 0) { display.WriteLine($"{count--}", 1); Thread.Sleep(500); } display.ClearLines(); Thread.Sleep(2000); display.WriteLine("Cursor test", 0); for (int i = 0; i < display.DisplayConfig.Width; i++) { display.SetCursorPosition((byte)i, 1); display.Write("*"); Thread.Sleep(100); display.SetCursorPosition((byte)i, 1); display.Write(" "); } display.ClearLines(); display.WriteLine("Complete!", 0); }
private void Port_MessageReceived(object sender, SerialMessageData e) { string msg = Encoding.UTF8.GetString(e.Message); foreach (byte b in msg) { Console.WriteLine(b); } Console.WriteLine(msg); display.ClearLines(); display.Write(msg); onboardLed.SetColor(Color.Red); //So i knew it was receiving data before I connected display Thread.Sleep(500); onboardLed.SetColor(Color.Blue); port.Write(Encoding.UTF8.GetBytes($"Received and acknowledging! Msg: {msg}")); //There is small issue that messages contain LF at the end and it's sent back too //but nah, in target use it won't matter }
public void ShowText(string text) { Text = text; display.ClearLines(); display.WriteLine(text, 0); }
private void CharacterDisplayClock() { int lastSecond = -1; int lastDay = -1; bool swapWriteOrder = false; try { display.ClearLines(); display.WriteLine($"", 1); string pad = new string(' ', 2 * DISPLAY_CHAR_COUNT - 5); marqueeText = "abcde" + pad; while (true) { string line0 = this.marqueeText.Substring(0, DISPLAY_CHAR_COUNT); string line1 = this.marqueeText.Substring(DISPLAY_CHAR_COUNT, DISPLAY_CHAR_COUNT); if (swapWriteOrder) { this.WriteLine(line1, 1); this.WriteLine(line0, 0); } else { this.WriteLine(line0, 0); this.WriteLine(line1, 1); } DateTime currentTime = DateTime.Now; if (currentTime.Second != lastSecond) { this.UpdateTime(currentTime); lastSecond = currentTime.Second; } if (currentTime.Day != lastDay) { string date = $"{currentTime:MM}/{currentTime:dd}/{currentTime:yyyy}"; int padCount = (int)((DISPLAY_CHAR_COUNT - date.Length) / 2); string paddedDate = new string(' ', padCount) + date; new Thread(() => { display.WriteLine($"{paddedDate}", 2); }).Start(); lastDay = currentTime.Day; } char c = marqueeText[2 * DISPLAY_CHAR_COUNT - 1]; swapWriteOrder = c != ' '; this.marqueeText = $"{c}{marqueeText.Substring(0, 2 * DISPLAY_CHAR_COUNT - 1)}"; Thread.Sleep(80); } } catch (Exception e) { Console.WriteLine($"caught exception {e}"); } }