/// <summary> /// Construct a new HD44780-compatible display /// </summary> /// <param name="iface">The writable parallel interface to use</param> /// <param name="Columns">The number of columns in the display</param> /// <param name="Rows">The number of rows of the display</param> /// <param name="Backlight">The active-high pin to use for the backlight</param> /// <param name="font">The font mode to use</param> public Hd44780(WriteOnlyParallelInterface iface, int Columns, int Rows, DigitalOut Backlight = null, FontMode font = FontMode.Font_5x8) : base(Columns, Rows) { if (iface.Width == 8) { bits = BitMode.EightBit; } else if (iface.Width == 4) { bits = BitMode.FourBit; } else { throw new ArgumentException("The IParallelInterface bus must be either 4 or 8 bits wide.", "iface"); } if (Rows == 1) { lines = LinesMode.OneLine; } else { lines = LinesMode.TwoOrMoreLines; } this.font = font; this.iface = iface; iface.DelayMicroseconds = 50; iface.Enabled = true; byte cmd; if (bits == BitMode.FourBit) { Task.Run(() => iface.WriteCommandAsync(new uint[] { 0x03 })).Wait(); Task.Run(() => Task.Delay(10)).Wait(); Task.Run(() => iface.WriteCommandAsync(new uint[] { 0x03 })).Wait(); Task.Run(() => Task.Delay(10)).Wait(); Task.Run(() => iface.WriteCommandAsync(new uint[] { 0x03 })).Wait(); Task.Run(() => Task.Delay(10)).Wait(); Task.Run(() => iface.WriteCommandAsync(new uint[] { 0x02 })).Wait(); } cmd = (byte)((byte)Command.FunctionSet | (byte)bits | (byte)lines | (byte)font); Task.Run(() => writeCommand(cmd)).Wait(); Display = true; Task.Run(Clear).Wait(); if (Backlight != null) { backlight = Backlight; Task.Run(backlight.MakeDigitalPushPullOutAsync).Wait(); } this.Backlight = true; }
public static PrintableBuilder SetFont(this PrintableBuilder builder, FontMode fontMode = FontMode.FontA) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.Add(new SetFont(fontMode))); }
public static void SetFont(this IPrinter printer, FontMode fontMode = FontMode.FontA) { if (printer == null) { throw new ArgumentNullException(nameof(printer)); } printer.Print(new SetFont(fontMode)); }
public ESCPosDocumentFragment SetFont(FontMode fontMode) { return(Add(new SetFont(fontMode))); }
public SetFont(FontMode mode = FontMode.FontA) { _mode = mode; }
/// <summary> /// Construct a new HD44780-compatible display /// </summary> /// <param name="iface">The writable parallel interface to use</param> /// <param name="Columns">The number of columns in the display</param> /// <param name="Rows">The number of rows of the display</param> /// <param name="Backlight">The active-high pin to use for the backlight</param> /// <param name="font">The font mode to use</param> public Hd44780(WriteOnlyParallelInterface iface, int Columns, int Rows, DigitalOutPin Backlight = null, FontMode font = FontMode.Font_5x8) : base(Columns, Rows) { if (iface.Width == 8) this.bits = BitMode.EightBit; else if (iface.Width == 4) this.bits = BitMode.FourBit; else throw new ArgumentException("The IParallelInterface bus must be either 4 or 8 bits wide.", "iface"); if (Rows == 1) this.lines = LinesMode.OneLine; else this.lines = LinesMode.TwoOrMoreLines; this.font = font; this.iface = iface; iface.DelayMicroseconds = 50; iface.Enabled = true; byte cmd; if (bits == BitMode.FourBit) { iface.WriteCommand(new uint[] { 0x03 }).Wait(); Task.Delay(10).Wait(); iface.WriteCommand(new uint[] { 0x03 }).Wait(); Task.Delay(10).Wait(); iface.WriteCommand(new uint[] { 0x03 }).Wait(); Task.Delay(10).Wait(); iface.WriteCommand(new uint[] { 0x02 }).Wait(); } cmd = (byte)((byte)Command.FunctionSet | (byte)bits | (byte)lines | (byte)font); writeCommand(cmd).Wait(); Display = true; Clear().Wait(); if (Backlight != null) { this.backlight = Backlight; backlight.MakeDigitalPushPullOut(); } this.Backlight = true; }
public SetFont(FontMode mode) { _mode = mode; }