public MeadowApp() { Console.WriteLine("Initialize..."); ht16k33 = new Ht16K33(Device.CreateI2cBus()); TestHT16K33(); }
BackgroundTaskDeferral _deferral; // for a headless Windows 10 for IoT projects you need to hold a deferral to keep the app active in the background public void Run(IBackgroundTaskInstance taskInstance) { _deferral = taskInstance.GetDeferral(); // get the deferral handle Ht16K33 driver = new Ht16K33(4, Ht16K33.Rotate.None, Ht16K33.Transform.HorizontalFlip, MAX7219.ChipSelect.CE0); // 4 panels, rotate 90 degrees, SPI CE0 LED8x8Matrix matrix = new LED8x8Matrix(driver); // pass the driver to the LED8x8Matrix Graphics Library while (true) { matrix.ScrollStringInFromRight("Hello World 2015 ", 100); } }
private void ScrollText(string message, int repeatCount) { // update UI UpdateUi(message, repeatCount); //var driver = new Ht16K33(new byte[] { 0x70 }, Ht16K33.Rotate.None, LedDriver.Display.On, 2, LedDriver.BlinkRate.Off, "I2C1"); var driver = new Ht16K33(); LED8x8Matrix matrix = new LED8x8Matrix(driver); matrix.SetBrightness(1); // override default brightness // We'll repeat the message here for (int i = 0; i < repeatCount; i++) { matrix.FrameClear(); matrix.ScrollStringInFromRight(message + " ", 100); matrix.FrameClear(); } }
public async void Start() { //var driver = new Ht16K33(new byte[] { 0x73, 0x74 }, new[] { Ht16K33.Rotate.None, Ht16K33.Rotate.D180 }, doubleWide: true); var driver = new Ht16K33(new byte[] { 0x70, 0x71 }, Ht16K33.Rotate.None); LED8x8Matrix matrix = new LED8x8Matrix(driver); matrix.SetBrightness(2); while (true) { matrix.FrameClear(); for (int i = 0; i < matrix.fontSimple.Length; i = i + matrix.PanelsPerFrame) { for (int p = 0; p < matrix.PanelsPerFrame; p++) { if (p + i >= matrix.fontSimple.Length) { break; } matrix.DrawBitmap(matrix.fontSimple[p + i], Led.On, (p + i) % matrix.PanelsPerFrame); } matrix.FrameDraw(); await Task.Delay(100 *matrix.PanelsPerFrame); } foreach (Grid8x8.Symbols sym in Enum.GetValues(typeof(Grid8x8.Symbols))) { for (int p = 0; p < matrix.PanelsPerFrame; p++) { matrix.DrawSymbol(sym, p); } matrix.FrameDraw(); await Task.Delay(100 *matrix.PanelsPerFrame); } matrix.FrameClear(); matrix.ScrollStringInFromRight("Hello World 2015", 100); matrix.FrameClear(); matrix.ScrollStringInFromLeft("Hello World 2015", 100); //continue; for (ushort p = 0; p < matrix.PanelsPerFrame; p++) { matrix.DrawSymbol(Grid8x8.Symbols.Block, p); matrix.FrameDraw(); await Task.Delay(100); } for (int p = 0; p < matrix.Length; p++) { matrix.FrameSet(Led.On, p); matrix.FrameSet(Led.On, matrix.Length - 1 - p); matrix.FrameDraw(); await Task.Delay(2); matrix.FrameSet(Led.Off, p); matrix.FrameSet(Led.Off, matrix.Length - 1 - p); matrix.FrameDraw(); await Task.Delay(2); } for (int c = 0; c < matrix.ColumnsPerFrame; c = c + 2) { matrix.ColumnDrawLine(c); matrix.FrameDraw(); await Task.Delay(100); } for (int r = 0; r < matrix.RowsPerPanel; r = r + 2) { matrix.RowDrawLine(r); matrix.FrameDraw(); await Task.Delay(100); } await Task.Delay(1000); for (ushort i = 0; i < matrix.PanelsPerFrame; i++) { matrix.DrawLetter(i.ToString()[0], i); } matrix.FrameDraw(); await Task.Delay(1000); for (int r = 0; r < matrix.RowsPerPanel * 2; r++) { matrix.FrameRollDown(); matrix.FrameDraw(); await Task.Delay(100); } for (int r = 0; r < matrix.RowsPerPanel * 2; r++) { matrix.FrameRollUp(); matrix.FrameDraw(); await Task.Delay(100); } for (int c = 0; c < matrix.ColumnsPerFrame * 1; c++) { matrix.FrameRollRight(); matrix.FrameDraw(); await Task.Delay(100); } for (int c = 0; c < matrix.ColumnsPerFrame * 1; c++) { matrix.FrameRollLeft(); matrix.FrameDraw(); await Task.Delay(100); } //await Task.Delay(1000); //continue; matrix.DrawString("ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890", 100, 0); matrix.FrameClear(); for (int i = 0; i < matrix.RowsPerPanel; i++) { matrix.DrawBox(i, i, matrix.ColumnsPerFrame - (i * 2), matrix.RowsPerPanel - (i * 2)); matrix.FrameDraw(); await Task.Delay(100); } for (byte l = 0; l < 2; l++) { matrix.SetFrameState(LedDriver.Display.Off); await Task.Delay(250); matrix.SetFrameState(LedDriver.Display.On); await Task.Delay(250); } matrix.FrameClear(); for (int r = 0; r < 2; r++) { for (int i = 0; i < matrix.RowsPerPanel; i++) { matrix.RowDrawLine(i, i - 0, matrix.ColumnsPerFrame - i - 1); matrix.FrameDraw(); await Task.Delay(50); } //for (byte l = 0; l < 6; l++) { // matrix.SetBrightness(l); // await Task.Delay(250); //} //matrix.SetBrightness(1); for (int i = 0; i < matrix.RowsPerPanel; i++) { matrix.RowDrawLine(i, i - 0, matrix.ColumnsPerFrame - i - 1, Led.Off); matrix.FrameDraw(); await Task.Delay(50); } } await Task.Delay(500); matrix.FrameClear(); matrix.ScrollStringInFromRight("Hello World ", 100); matrix.FrameClear(); matrix.ScrollStringInFromLeft("Happy Birthday ", 100); } }
public LedMatrix8x16Wing(II2cBus i2cBus, byte address = 0x70) { ht16k33 = new Ht16K33(i2cBus, address); }