/// <summary> /// Pass 1: work on the first Blink(1) device found, synchronously /// </summary> private static void TestCase1() { Console.WriteLine("####################################################################"); Console.WriteLine("## Pass 1: work on the first Blink(1) device found, synchronously ##"); Console.WriteLine("####################################################################"); // Note, the first past goes so fast, Blink(1) does not have the time to, well, blink. Blink1 blink1 = new Blink1(); Console.WriteLine("Pass 1: Opening the first Blink(1) found."); blink1.Open(); int versionNumber = blink1.GetVersion(); Console.WriteLine("Pass 1: Blink(1) device is at version: {0}.", versionNumber.ToString()); Console.WriteLine("Pass 1: Set Blink(1) to be RED."); blink1.SetColor(255, 0, 0); Console.WriteLine("Pass 1: Set Blink(1) to fade to BLUE over 10 seconds."); blink1.FadeToColor(10000, 0, 0, 255, false); Thread.Sleep(10000); Console.WriteLine("Pass 1: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); }
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Sets the color. /// </summary> /// <param name="iR">The i r.</param> /// <param name="iG">The i g.</param> /// <param name="iB">The i b.</param> private static void SetColor(int iR, int iG, int iB) { using (Blink1 blink = new Blink1()) { blink.Open(); blink.SetColor(( ushort )iR, ( ushort )iG, ( ushort )iB); } }
private void RedButton_Click(object sender, RoutedEventArgs e) { try { if ((bool)FadeCheckBox.IsChecked) { m_blink1?.FadeToColor((Convert.ToUInt16(ComboBox.SelectionBoxItem)), 255, 0, 0, false); } else { m_blink1?.SetColor(255, 0, 0); } } catch (Exception exc) { MessageBox.Show("Something went wrong: \n" + exc.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
/// <summary> /// Pass 2: work on the last Blink(1) device found, asynchronously /// </summary> private static void TestCase2() { Console.WriteLine("####################################################################"); Console.WriteLine("## Pass 2: work on the last Blink(1) device found, asynchronously ##"); Console.WriteLine("####################################################################"); List <string> devicePaths = Blink1Info.GetDevicePath(); Blink1 blink1 = new Blink1(); Console.WriteLine("Pass 2: Opening the last Blink(1) found via its HID path."); blink1.Open(devicePaths.Last()); Console.WriteLine("Pass 2: Set Blink(1) to blink 8 times PURPLE."); blink1.Blink(8, 500, 200, 128, 0, 128); Console.WriteLine("Pass 2: Set Blink(1) to be RED, using RGB(255, 0, 0)."); blink1.SetColor(new Rgb(255, 0, 0)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be GREEN, using CYMK(100, 0, 100, 0)."); blink1.SetColor(new Cmyk(100, 0, 100, 0)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be BLUE, using HSB(240, 100, 100)."); blink1.SetColor(new Hsb(240, 100, 100)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be YELLOW, using HSL(60, 100, 50)."); blink1.SetColor(new Hsl(60, 100, 50)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be CYAN, using HtmlHexadecimal(\"#00FFFF\")."); blink1.SetColor(new HtmlHexadecimal("#00FFFF")); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be MAGENTA, using HtmlColorName and HtmlHexadecimal."); blink1.SetColor(new HtmlHexadecimal(HtmlColorName.Magenta)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be BLACK."); blink1.SetColor(0, 0, 0); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to fade to ORANGE over 10 seconds."); blink1.FadeToColor(10000, 251, 61, 4, true); Console.WriteLine("Pass 2: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); }
//public void StartupLights() //{ // blink1 = new Blink1(); // blink1.Open(); // blink1.SetColor(150, 0, 0); // Red // blink1.FadeToColor(500, 0, 150, 0, true); // green // blink1.FadeToColor(500, 0, 0, 150, true); // blue // blink1.FadeToColor(500, 150, 0, 0, true); // red // blink1.FadeToColor(500, 0, 150, 0, true); // green // blink1.FadeToColor(500, 0, 0, 150, true); // blue // blink1.SetColor(0, 30, 0); // blink1.Close(false); //} public void RunChecks() { _blink1 = new Blink1(); _blink1.Open(); Color color = new Color(); int numberOfFailedTests = CheckAllStatusCakeTestsOK(); if (numberOfFailedTests == 0) { // OK color = Color.FromArgb(0, 50, 0); Log("No failed tests"); // If there are no error conditions, then check SSL expirations: var numberOfSslFails = CheckSSLExpirations(_settings.CertificateExpirationDays); Log("SSL fails: " + numberOfSslFails); if (numberOfSslFails > 0) { color = ColorHelper.ChangeBrightness(Color.DarkOrange, -0.6F); } } else { // NOT ok Log("Test fails: " + numberOfFailedTests); int brightness = numberOfFailedTests * 50; if (brightness >= MAX_BRIGHTNESS) { brightness = MAX_BRIGHTNESS; } color = Color.FromArgb(brightness, 0, 0); } // Don't update LED unless color has changed. if (lastColor != color) { Log($"Changing LED color to: {color.R},{color.G},{color.B}"); _blink1.SetColor(color.R, color.G, color.B); } _blink1.Close(false); _blink1 = null; }
void SetBlink1State(Rgb color) { bool setColorResult = false; if (blink1.IsConnected) { setColorResult = blink1.SetColor(color); if (setColorResult) { Debug.WriteLine("Successful set blink1 to {0},{1},{2}", color.Red, color.Green, color.Blue); } else { Debug.WriteLine("Error setting blink1 to {0},{1},{2}", color.Red, color.Green, color.Blue); } } }
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Tests this instance. /// </summary> public static void Test() { using (Blink1 blink = new Blink1()) { blink.Open(); void SetColor(Color c) { blink.SetColor(c.R, c.G, c.B); Thread.Sleep(1000); } SetColor(Colors.Red); SetColor(Colors.Green); SetColor(Colors.Blue); blink.Close(); } }
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Fades the white to black. /// </summary> public static void FadeWhiteToBlack() { using (Blink1 blink = new Blink1()) { blink.Open(); void SetColor(int r, int g, int b) { blink.SetColor(( ushort )r, ( ushort )g, ( ushort )b); Thread.Sleep(20); } for (int iCounter = 255; iCounter > 0; iCounter--) { SetColor(iCounter, iCounter, iCounter); } blink.Close(); } }
/// <summary> /// Pass 2: work on the last Blink(1) device found, asynchronously /// </summary> private static void TestCase2() { Console.WriteLine("####################################################################"); Console.WriteLine("## Pass 2: work on the last Blink(1) device found, asynchronously ##"); Console.WriteLine("####################################################################"); List<string> devicePaths = Blink1Info.GetDevicePath(); Blink1 blink1 = new Blink1(); Console.WriteLine("Pass 2: Opening the last Blink(1) found via its HID path."); blink1.Open(devicePaths.Last()); Console.WriteLine("Pass 2: Set Blink(1) to blink 8 times PURPLE."); blink1.Blink(8, 500, 200, 128, 0, 128); Console.WriteLine("Pass 2: Set Blink(1) to be RED, using RGB(255, 0, 0)."); blink1.SetColor(new Rgb(255, 0, 0)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be GREEN, using CYMK(100, 0, 100, 0)."); blink1.SetColor(new Cmyk(100, 0, 100, 0)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be BLUE, using HSB(240, 100, 100)."); blink1.SetColor(new Hsb(240, 100, 100)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be YELLOW, using HSL(60, 100, 50)."); blink1.SetColor(new Hsl(60, 100, 50)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be CYAN, using HtmlHexadecimal(\"#00FFFF\")."); blink1.SetColor(new HtmlHexadecimal("#00FFFF")); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be MAGENTA, using HtmlColorName and HtmlHexadecimal."); blink1.SetColor(new HtmlHexadecimal(HtmlColorName.Magenta)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be BLACK."); blink1.SetColor(0, 0, 0); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to fade to ORANGE over 10 seconds."); blink1.FadeToColor(10000, 251, 61, 4, true); Console.WriteLine("Pass 2: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); }
/// <summary> /// The main program. /// </summary> /// <param name="args"> /// The arguments. /// </param> public static void Main(string[] args) { Console.WriteLine("####################################################################"); Console.WriteLine("## Pass 1: work on the first Blink(1) device found, synchronously ##"); Console.WriteLine("####################################################################"); // Note, the first past goes so fast, Blink(1) does not have the time to, well, blink. Blink1 blink1 = new Blink1(); Console.WriteLine("Pass 1: Opening the first Blink(1) found."); blink1.Open(); int versionNumber = blink1.GetVersion(); Console.WriteLine("Pass 1: Blink(1) device is at version: {0}.", versionNumber.ToString()); Console.WriteLine("Pass 1: Set Blink(1) to be RED."); blink1.SetColor(255, 0, 0); Console.WriteLine("Pass 1: Set Blink(1) to fade to BLUE over 10 seconds."); blink1.FadeToColor(3000, 0, 0, 255, false); Console.WriteLine("Pass 1: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("####################################################################"); Console.WriteLine("## Pass 2: work on the last Blink(1) device found, asynchronously ##"); Console.WriteLine("####################################################################"); List <string> devicePaths = Blink1Info.GetDevicePath(); blink1 = new Blink1(); Console.WriteLine("Pass 2: Opening the last Blink(1) found via its HID path."); blink1.Open(devicePaths.Last()); Console.WriteLine("Pass 2: Set Blink(1) to blink 8 times PURPLE."); blink1.Blink(8, 500, 200, 128, 0, 128); Console.WriteLine("Pass 2: Set Blink(1) to be RED, using RGB(255, 0, 0)."); blink1.SetColor(new Rgb(255, 0, 0)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be GREEN, using CYMK(100, 0, 100, 0)."); blink1.SetColor(new Cmyk(100, 0, 100, 0)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be BLUE, using HSB(240, 100, 100)."); blink1.SetColor(new Hsb(240, 100, 100)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be YELLOW, using HSL(60, 100, 50)."); blink1.SetColor(new Hsl(60, 100, 50)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be CYAN, using HtmlHexadecimal(\"#00FFFF\")."); blink1.SetColor(new HtmlHexadecimal("#00FFFF")); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be MAGENTA, using HtmlColorName and HtmlHexadecimal."); blink1.SetColor(new HtmlHexadecimal(HtmlColorName.Magenta)); Thread.Sleep(1000); Console.WriteLine("Pass 1: Set Blink(1) to be BLACK."); blink1.SetColor(0, 0, 0); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to fade to ORANGE over 10 seconds."); blink1.FadeToColor(10000, 251, 61, 4, true); Console.WriteLine("Pass 2: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("#########################################"); Console.WriteLine("## Pass 3: reading the current presets ##"); Console.WriteLine("#########################################"); // Note, any dealing with presets is done asynchronously. blink1 = new Blink1(); Console.WriteLine("Pass 3: Opening the first Blink(1) found."); blink1.Open(); for (ushort position = 0; position < Blink1Constant.NumberOfPreset; position++) { Blink1Preset blink1Preset = blink1.ReadPreset(position); Console.WriteLine( "Pass 3: Position:{0}, Millisecond:{1}, Red:{2}, Green:{3}, Blue:{4}", position, blink1Preset.Millisecond, blink1Preset.Rgb.Red, blink1Preset.Rgb.Green, blink1Preset.Rgb.Blue); } Console.WriteLine("Pass 3: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("#########################################"); Console.WriteLine("## Pass 4: playing the current presets ##"); Console.WriteLine("#########################################"); blink1 = new Blink1(); Console.WriteLine("Pass 4: Opening the first Blink(1) found."); blink1.Open(); Console.WriteLine("Pass 4: Playing the presets for 20 seconds..."); blink1.PlayPreset(0); Thread.Sleep(20000); Console.WriteLine("Pass 4: Stopping playing presets."); blink1.StopPlayingPreset(); Console.WriteLine("Pass 4: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("#######################################"); Console.WriteLine("## Pass 5: saving new random presets ##"); Console.WriteLine("#######################################"); blink1 = new Blink1(); Console.WriteLine("Pass 5: Opening the first Blink(1) found."); blink1.Open(); for (ushort position = 0; position < Blink1Constant.NumberOfPreset; position++) { Blink1Preset blink1Preset = new Blink1Preset(Convert.ToUInt16(1000 + (position * 10)), GetRandomRgbColor()); Console.WriteLine( "Pass 5: Position:{0}, Millisecond:{1}, Red:{2}, Green:{3}, Blue:{4}", position, blink1Preset.Millisecond, blink1Preset.Rgb.Red, blink1Preset.Rgb.Green, blink1Preset.Rgb.Blue); blink1.SavePreset(blink1Preset, position); } Console.WriteLine("Pass 5: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("############################################"); Console.WriteLine("## Pass 6: reading the new random presets ##"); Console.WriteLine("############################################"); blink1 = new Blink1(); Console.WriteLine("Pass 6: Opening the first Blink(1) found."); blink1.Open(); for (ushort position = 0; position < Blink1Constant.NumberOfPreset; position++) { Blink1Preset blink1Preset = blink1.ReadPreset(position); Console.WriteLine( "Pass 6: Position:{0}, Millisecond:{1}, Red:{2}, Green:{3}, Blue:{4}", position, blink1Preset.Millisecond, blink1Preset.Rgb.Red, blink1Preset.Rgb.Green, blink1Preset.Rgb.Blue); } Console.WriteLine("Pass 6: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("############################################"); Console.WriteLine("## Pass 7: playing the new random presets ##"); Console.WriteLine("############################################"); blink1 = new Blink1(); Console.WriteLine("Pass 7: Opening the first Blink(1) found."); blink1.Open(); Console.WriteLine("Pass 7: Playing the presets for 20 seconds..."); blink1.PlayPreset(0); Thread.Sleep(20000); Console.WriteLine("Pass 7: Stopping playing presets."); blink1.StopPlayingPreset(); Console.WriteLine("Pass 7: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("###########################################"); Console.WriteLine("## Pass 8: work with the inactivity mode ##"); Console.WriteLine("###########################################"); blink1 = new Blink1(); Console.WriteLine("Pass 8: Opening the first Blink(1) found."); blink1.Open(); Console.WriteLine("Pass 8: Writing inactivity mode presets"); blink1.SavePreset(new Blink1Preset(500, new HtmlHexadecimal(HtmlColorName.Red)), 0); blink1.SavePreset(new Blink1Preset(250, new HtmlHexadecimal(HtmlColorName.Black)), 1); blink1.SavePreset(new Blink1Preset(500, new HtmlHexadecimal(HtmlColorName.White)), 2); blink1.SavePreset(new Blink1Preset(250, new HtmlHexadecimal(HtmlColorName.Black)), 3); blink1.SavePreset(new Blink1Preset(500, new HtmlHexadecimal(HtmlColorName.Green)), 4); blink1.SavePreset(new Blink1Preset(250, new HtmlHexadecimal(HtmlColorName.Black)), 5); blink1.SavePreset(new Blink1Preset(500, new HtmlHexadecimal(HtmlColorName.Blue)), 6); blink1.SavePreset(new Blink1Preset(250, new HtmlHexadecimal(HtmlColorName.Black)), 7); blink1.SavePreset(new Blink1Preset(500, new HtmlHexadecimal(HtmlColorName.Magenta)), 8); blink1.SavePreset(new Blink1Preset(250, new HtmlHexadecimal(HtmlColorName.Black)), 9); blink1.SavePreset(new Blink1Preset(500, new HtmlHexadecimal(HtmlColorName.Cyan)), 10); blink1.SavePreset(new Blink1Preset(250, new HtmlHexadecimal(HtmlColorName.Black)), 11); Console.WriteLine("Pass 8: Activating the inactivity mode for 10 seconds of inactivity."); blink1.ActivateInactivityMode(5000); Console.WriteLine("Pass 8: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine("Pass 8: After the inactivity period, Blink(1) will play its presets."); Thread.Sleep(15000); Console.WriteLine("Pass 8: Opening the first Blink(1) found."); blink1.Open(); Console.WriteLine("Pass 8: Deactivating the inactivity."); blink1.DeactivateInactivityMode(); Console.WriteLine("Pass 8: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("We're done with the demo, press any key to stop the program."); Console.ReadKey(); }
/// <summary> /// The main program. /// </summary> /// <param name="args"> /// The arguments. /// </param> public static void Main(string[] args) { Console.WriteLine("####################################################################"); Console.WriteLine("## Pass 1: work on the first Blink(1) device found, synchronously ##"); Console.WriteLine("####################################################################"); // Note, the first past goes so fast, Blink(1) does not have the time to, well, blink. Blink1 blink1 = new Blink1(); Console.WriteLine("Pass 1: Opening the first Blink(1) found."); blink1.Open(); int versionNumber = blink1.GetVersion(); Console.WriteLine("Pass 1: Blink(1) device is at version: {0}.", versionNumber.ToString()); Console.WriteLine("Pass 1: Set Blink(1) to be RED."); blink1.SetColor(255, 0, 0); Console.WriteLine("Pass 1: Set Blink(1) to fade to BLUE over 10 seconds."); blink1.FadeToColor(3000, 0, 0, 255, false); Console.WriteLine("Pass 1: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("####################################################################"); Console.WriteLine("## Pass 2: work on the last Blink(1) device found, asynchronously ##"); Console.WriteLine("####################################################################"); List<string> devicePaths = Blink1Info.GetDevicePath(); blink1 = new Blink1(); Console.WriteLine("Pass 2: Opening the last Blink(1) found via its HID path."); blink1.Open(devicePaths.Last()); Console.WriteLine("Pass 2: Set Blink(1) to blink 8 times PURPLE."); blink1.Blink(8, 500, 200, 128, 0, 128); Console.WriteLine("Pass 2: Set Blink(1) to be RED, using RGB(255, 0, 0)."); blink1.SetColor(new Rgb(255, 0, 0)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be GREEN, using CYMK(100, 0, 100, 0)."); blink1.SetColor(new Cmyk(100, 0, 100, 0)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be BLUE, using HSB(240, 100, 100)."); blink1.SetColor(new Hsb(240, 100, 100)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be YELLOW, using HSL(60, 100, 50)."); blink1.SetColor(new Hsl(60, 100, 50)); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be CYAN, using HtmlHexadecimal(\"#00FFFF\")."); blink1.SetColor(new HtmlHexadecimal("#00FFFF")); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to be MAGENTA, using HtmlColorName and HtmlHexadecimal."); blink1.SetColor(new HtmlHexadecimal(HtmlColorName.Magenta)); Thread.Sleep(1000); Console.WriteLine("Pass 1: Set Blink(1) to be BLACK."); blink1.SetColor(0, 0, 0); Thread.Sleep(1000); Console.WriteLine("Pass 2: Set Blink(1) to fade to ORANGE over 10 seconds."); blink1.FadeToColor(10000, 251, 61, 4, true); Console.WriteLine("Pass 2: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("#########################################"); Console.WriteLine("## Pass 3: reading the current presets ##"); Console.WriteLine("#########################################"); // Note, any dealing with presets is done asynchronously. blink1 = new Blink1(); Console.WriteLine("Pass 3: Opening the first Blink(1) found."); blink1.Open(); for (ushort position = 0; position < Blink1Constant.NumberOfPreset; position++) { Blink1Preset blink1Preset = blink1.ReadPreset(position); Console.WriteLine( "Pass 3: Position:{0}, Millisecond:{1}, Red:{2}, Green:{3}, Blue:{4}", position, blink1Preset.Millisecond, blink1Preset.Rgb.Red, blink1Preset.Rgb.Green, blink1Preset.Rgb.Blue); } Console.WriteLine("Pass 3: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("#########################################"); Console.WriteLine("## Pass 4: playing the current presets ##"); Console.WriteLine("#########################################"); blink1 = new Blink1(); Console.WriteLine("Pass 4: Opening the first Blink(1) found."); blink1.Open(); Console.WriteLine("Pass 4: Playing the presets for 20 seconds..."); blink1.PlayPreset(0); Thread.Sleep(20000); Console.WriteLine("Pass 4: Stopping playing presets."); blink1.StopPlayingPreset(); Console.WriteLine("Pass 4: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("#######################################"); Console.WriteLine("## Pass 5: saving new random presets ##"); Console.WriteLine("#######################################"); blink1 = new Blink1(); Console.WriteLine("Pass 5: Opening the first Blink(1) found."); blink1.Open(); for (ushort position = 0; position < Blink1Constant.NumberOfPreset; position++) { Blink1Preset blink1Preset = new Blink1Preset(Convert.ToUInt16(1000 + (position * 10)), GetRandomRgbColor()); Console.WriteLine( "Pass 5: Position:{0}, Millisecond:{1}, Red:{2}, Green:{3}, Blue:{4}", position, blink1Preset.Millisecond, blink1Preset.Rgb.Red, blink1Preset.Rgb.Green, blink1Preset.Rgb.Blue); blink1.SavePreset(blink1Preset, position); } Console.WriteLine("Pass 5: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("############################################"); Console.WriteLine("## Pass 6: reading the new random presets ##"); Console.WriteLine("############################################"); blink1 = new Blink1(); Console.WriteLine("Pass 6: Opening the first Blink(1) found."); blink1.Open(); for (ushort position = 0; position < Blink1Constant.NumberOfPreset; position++) { Blink1Preset blink1Preset = blink1.ReadPreset(position); Console.WriteLine( "Pass 6: Position:{0}, Millisecond:{1}, Red:{2}, Green:{3}, Blue:{4}", position, blink1Preset.Millisecond, blink1Preset.Rgb.Red, blink1Preset.Rgb.Green, blink1Preset.Rgb.Blue); } Console.WriteLine("Pass 6: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("############################################"); Console.WriteLine("## Pass 7: playing the new random presets ##"); Console.WriteLine("############################################"); blink1 = new Blink1(); Console.WriteLine("Pass 7: Opening the first Blink(1) found."); blink1.Open(); Console.WriteLine("Pass 7: Playing the presets for 20 seconds..."); blink1.PlayPreset(0); Thread.Sleep(20000); Console.WriteLine("Pass 7: Stopping playing presets."); blink1.StopPlayingPreset(); Console.WriteLine("Pass 7: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("###########################################"); Console.WriteLine("## Pass 8: work with the inactivity mode ##"); Console.WriteLine("###########################################"); blink1 = new Blink1(); Console.WriteLine("Pass 8: Opening the first Blink(1) found."); blink1.Open(); Console.WriteLine("Pass 8: Writing inactivity mode presets"); blink1.SavePreset(new Blink1Preset(500, new HtmlHexadecimal(HtmlColorName.Red)), 0); blink1.SavePreset(new Blink1Preset(250, new HtmlHexadecimal(HtmlColorName.Black)), 1); blink1.SavePreset(new Blink1Preset(500, new HtmlHexadecimal(HtmlColorName.White)), 2); blink1.SavePreset(new Blink1Preset(250, new HtmlHexadecimal(HtmlColorName.Black)), 3); blink1.SavePreset(new Blink1Preset(500, new HtmlHexadecimal(HtmlColorName.Green)), 4); blink1.SavePreset(new Blink1Preset(250, new HtmlHexadecimal(HtmlColorName.Black)), 5); blink1.SavePreset(new Blink1Preset(500, new HtmlHexadecimal(HtmlColorName.Blue)), 6); blink1.SavePreset(new Blink1Preset(250, new HtmlHexadecimal(HtmlColorName.Black)), 7); blink1.SavePreset(new Blink1Preset(500, new HtmlHexadecimal(HtmlColorName.Magenta)), 8); blink1.SavePreset(new Blink1Preset(250, new HtmlHexadecimal(HtmlColorName.Black)), 9); blink1.SavePreset(new Blink1Preset(500, new HtmlHexadecimal(HtmlColorName.Cyan)), 10); blink1.SavePreset(new Blink1Preset(250, new HtmlHexadecimal(HtmlColorName.Black)), 11); Console.WriteLine("Pass 8: Activating the inactivity mode for 10 seconds of inactivity."); blink1.ActivateInactivityMode(5000); Console.WriteLine("Pass 8: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine("Pass 8: After the inactivity period, Blink(1) will play its presets."); Thread.Sleep(15000); Console.WriteLine("Pass 8: Opening the first Blink(1) found."); blink1.Open(); Console.WriteLine("Pass 8: Deactivating the inactivity."); blink1.DeactivateInactivityMode(); Console.WriteLine("Pass 8: Closing Blink(1) connection."); blink1.Close(); Console.WriteLine(Environment.NewLine); Console.WriteLine("We're done with the demo, press any key to stop the program."); Console.ReadKey(); }