public static async Task ScrollString(this DisplayDriver driver, string str, int duration) { var displayString = DisplayFrame.GetString(str).ToArray(); int scrollInterval = duration / (displayString.Length + 6); // Start with a blank frame var frame = DisplayFrame.Empty; driver.WriteFrame(frame); await Task.Delay(scrollInterval); // Push each character in from the right, one at a time foreach (var c in displayString) { frame = frame.WithPushedCharacter(c); driver.WriteFrame(frame); await Task.Delay(scrollInterval); } // Push three more blank characters to end off with a blank screen for (int i = 0; i < 3; i++) { frame = frame.WithPushedCharacter(DisplayCharacter.Empty); driver.WriteFrame(frame); await Task.Delay(scrollInterval); } }
public static async Task BusyLoop(this DisplayDriver driver, int interval, int duration) { using (var controller = new DisplayLoopController()) { await controller.StartNewLoop(new BusyDisplayLoop(driver, interval)); await Task.Delay(duration); } }
public BusyDisplayLoop(DisplayDriver driver, int delay) { driver.ThrowIfNull(nameof(driver)); if (delay < 1) { throw new ArgumentOutOfRangeException(nameof(delay)); } Driver = driver; Delay = delay; }
public static void Clear(this DisplayDriver driver) { driver.WriteFrame(DisplayFrame.Empty); }
public static void WriteDecimal(this DisplayDriver driver, decimal value, StatusLed signLed = StatusLed.Blue) { driver.WriteFrame(DisplayFrame.FromDecimal(value, signLed)); }
public static void WriteString(this DisplayDriver driver, string str) { driver.WriteFrame(DisplayFrame.FromString(str)); }