public void Visualize() { if (this.stopwatch.ElapsedMilliseconds <= 250) { return; } this.stopwatch.Restart(); this.state = (this.state + 1) % 2; if (this.state == 0) { for (int i = 0; i < LEDDomeOutput.GetNumStruts(); i++) { Strut strut = Strut.FromIndex(this.config, i); for (int j = 0; j < strut.Length; j++) { this.dome.SetPixel(i, j, 0x000000); } } this.dome.Flush(); return; } byte brightnessByte = (byte)( 0xFF * this.config.domeMaxBrightness * this.config.domeBrightness ); int color = brightnessByte << 16 | brightnessByte << 8 | brightnessByte; for (int teensy = 0; teensy < 5; teensy++) { for (int localIndex = 0; localIndex < 38; localIndex++) { var strutIndex = LEDDomeOutput.FindStrutIndex(teensy, localIndex); Strut strut = Strut.FromIndex(this.config, strutIndex); if (this.state == 2) { for (int j = 1; j < strut.Length - 1; j++) { this.dome.SetPixel(strutIndex, j, 0x000000); } this.dome.SetPixel(strutIndex, 0, color); this.dome.SetPixel(strutIndex, strut.Length - 1, color); } else { for (int j = 0; j < strut.Length; j++) { this.dome.SetPixel(strutIndex, j, color); } } } } this.dome.Flush(); }
public void Visualize() { if (this.stopwatch.ElapsedMilliseconds <= 1000) { return; } this.stopwatch.Restart(); this.lastIndex++; byte brightnessByte = (byte)( 0xFF * this.config.domeMaxBrightness * this.config.domeBrightness ); int whiteColor = brightnessByte << 16 | brightnessByte << 8 | brightnessByte; if (this.lastIndex == 38) { this.lastIndex = 0; this.lastTeensy = (this.lastTeensy + 1) % 5; // Reset every LED to blue for (int i = 0; i < LEDDomeOutput.GetNumStruts(); i++) { Strut blueStrut = Strut.FromIndex(this.config, i); for (int j = 0; j < blueStrut.Length; j++) { this.dome.SetPixel(i, j, 0x0000FF); } } if (this.lastTeensy == 0) { if (this.color == 0xFF0000) { this.color = 0x00FF00; } else if (this.color == 0x00FF00) { this.color = 0x0000FF; } else if (this.color == 0x0000FF) { this.color = 0xFFFFFF; } else if (this.color == 0xFFFFFF) { this.color = 0xFF0000; } } } var strutIndex = LEDDomeOutput.FindStrutIndex( this.lastTeensy, this.lastIndex ); Strut strut = Strut.FromIndex(this.config, strutIndex); for (int i = 0; i < strut.Length; i++) { this.dome.SetPixel(strutIndex, i, this.color & whiteColor); } this.dome.Flush(); }
public void Visualize() { if (this.stopwatch.ElapsedMilliseconds <= 1000) { return; } this.stopwatch.Restart(); this.state = (this.state + 1) % 4; if (this.state == 0) { for (int i = 0; i < LEDDomeOutput.GetNumStruts(); i++) { Strut strut = Strut.FromIndex(this.config, i); for (int j = 0; j < strut.Length; j++) { this.dome.SetPixel(i, j, 0x000000); } } this.dome.Flush(); return; } byte brightnessByte = (byte)( 0xFF * this.config.domeMaxBrightness * this.config.domeBrightness ); int whiteColor = brightnessByte << 16 | brightnessByte << 8 | brightnessByte; int[] colors = { whiteColor& 0xFF0000, whiteColor& 0x00FF00, whiteColor& 0x0000FF, whiteColor& 0xFFFF00, whiteColor& 0xFF00FF, whiteColor& 0x00FFFF, }; for (int controlBox = 0; controlBox < 5; controlBox++) { int colorIndex = 0; for (int localIndex = 0; localIndex < 38; localIndex++) { var strutIndex = LEDDomeOutput.FindStrutIndex(controlBox, localIndex); Strut strut = Strut.FromIndex(this.config, strutIndex); if (this.state == 2) { for (int j = 1; j < strut.Length - 1; j++) { this.dome.SetPixel(strutIndex, j, 0x000000); } this.dome.SetPixel(strutIndex, 0, colors[colorIndex]); this.dome.SetPixel(strutIndex, strut.Length - 1, colors[colorIndex]); } else { for (int j = 0; j < strut.Length; j++) { this.dome.SetPixel(strutIndex, j, colors[colorIndex]); } } colorIndex = (colorIndex + 1) % colors.Length; } } this.dome.Flush(); }