private void Blinker_DoBlink(object sender, BlinkRate e) { lsOperator.Blink(e); Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { Color c; switch (e) { case BlinkRate.High: c = Colors.Red; break; case BlinkRate.Medium: c = Colors.Green; break; default: c = Colors.Blue; break; } BlinkCircle.Fill = new SolidColorBrush(c); await Task.Delay(200); BlinkCircle.Fill = new SolidColorBrush(Colors.Gray); }); }
int CalculateBlinkRate(BlinkRate rate) { int br = 500; switch (rate) { case BlinkRate.VerySlow: br = 1000; break; case BlinkRate.Slow: br = 500; break; case BlinkRate.Medium: br = 250; break; case BlinkRate.Fast: br = 75; break; case BlinkRate.VeryFast: br = 25; break; } return(br); }
public void BlinkOn(uint Milliseconds, BlinkRate blinkRate) { if (ts.running) { return; } ts.running = true; ts.blinkMilliseconds = Milliseconds; ts.BlinkMillisecondsToDate = 0; ts.blinkRateMilliseconds = CalculateBlinkRate(blinkRate); ts.MyTimer.Change(0, ts.blinkRateMilliseconds); }
/// <summary> /// Initializes a new instance of the Ht16K33 I2C controller as found on the Adafriut Mini LED Matrix. /// </summary> /// <param name="display">On or Off - defaults to On</param> /// <param name="brightness">Between 0 and 15</param> /// <param name="blinkrate">Defaults to Off. Blink rates Fast = 2hz, Medium = 1hz, slow = 0.5hz</param> public Ht16K33(Display display = Display.On, byte brightness = 2, BlinkRate blinkrate = BlinkRate.Off) { this.display = display; this.brightness = brightness; this.blinkrate = blinkrate; Task.Run(() => I2cConnect()).Wait(); InitController(); }
public void BlinkOn(uint Milliseconds, BlinkRate blinkRate) { if (ts.running) { return; } ts.running = true; ts.blinkMilliseconds = Milliseconds; ts.BlinkMillisecondsToDate = 0; ts.blinkRateMilliseconds = (int)blinkRate; ts.tmr.Change(0, ts.blinkRateMilliseconds); }
public void BlinkOn(uint Milliseconds, BlinkRate blinkRate) { if (_ts.running) { return; } _ts.running = true; _ts.blinkMilliseconds = Milliseconds; _ts.BlinkMillisecondsToDate = 0; _ts.blinkRateMilliseconds = (int)blinkRate; _ts.tmr.Change(0, _ts.blinkRateMilliseconds); }
public async Task Blink(BlinkRate rate) { if (gpioCtrl != null) { var pin = GetPin(rate); pin.Write(GpioPinValue.High); SoundPin.Write(GpioPinValue.High); await Task.Delay(200); pin.Write(GpioPinValue.Low); SoundPin.Write(GpioPinValue.Low); } }
private GpioPin GetPin(BlinkRate rate) { switch (rate) { case BlinkRate.High: return(RedPin); case BlinkRate.Medium: return(GreenPin); default: return(BluePin); } }
public void Blink(Led l, int Milliseconds, BlinkRate blinkRate) { //lazy start thread ondemand if (ls[(int)l].ledThread == null) { ls[(int)l].ledThread = new Thread(new ThreadStart(ls[(int)l].Start)); ls[(int)l].ledThread.Start(); } ls[(int)l].blinkMilliseconds = Milliseconds; ls[(int)l].blinkRateMilliseconds = CalculateBlinkRate(blinkRate); ls[(int)l].blink.Set(); }
/// <summary> /// Blink an LED /// </summary> /// <param name="l"></param> /// <param name="levelPercentage">as a percentage 0 = off, 100 = max on</param> /// <param name="blinkRate"></param> /// <param name="milliseconds">the time the blink sequence will run for</param> public void Blink(Led l, byte levelPercentage, BlinkRate blinkRate, uint milliseconds) { levelPercentage = (byte)(levelPercentage % 101); if (!StartRunThread(l)) { return; } ((pwmledState)ls[(int)l]).cmd = pwmledState.CmdType.Blink; ((pwmledState)ls[(int)l]).led.Duration = (uint)(levelPercentage * 10); // scale duration to PulsePeriodInMicroseconds ((pwmledState)ls[(int)l]).blinkRate = blinkRate; ((pwmledState)ls[(int)l]).milliseconds = milliseconds; ls[(int)l].blink.Set(); }
private void BlinkerDoBlink(object sender, BlinkRate e) { Color c; switch (e) { case BlinkRate.High: c = Colors.Red; break; case BlinkRate.Medium: c = Colors.Green; break; default: c = Colors.Blue; break; } FlashCircle(HeartRateCirlce, c, 200); }
/// <summary> /// Initializes a new instance of the Ht16K33 I2C controller as found on the Adafriut Mini LED Matrix. /// </summary> /// <param name="frame">On or Off - defaults to On</param> /// <param name="brightness">Between 0 and 15</param> /// <param name="blinkrate">Defaults to Off. Blink rates Fast = 2hz, Medium = 1hz, slow = 0.5hz</param> public Ht16K33(byte[] I2CAddress = null, Rotate rotate = Rotate.None, Display frame = LedDriver.Display.On, byte brightness = 2, BlinkRate blinkrate = BlinkRate.Off, string I2cControllerName = "I2C1") { Columns = 8; Rows = 8; this.rotate = rotate; this.brightness = brightness; this.I2cControllerName = I2cControllerName; if (I2CAddress == null) { this.I2CAddress = new byte[] { 0x70 }; } else { this.I2CAddress = I2CAddress; } this.PanelsPerFrame = this.I2CAddress.Length; this.i2cDevice = new I2cDevice[PanelsPerFrame]; currentFrameState = frameStates[(byte)frame]; currentBlinkrate = blinkRates[(byte)blinkrate]; Initialize(); }
/// <summary> /// Initializes a new instance of the Ht16K33 I2C controller as found on the Adafriut Mini LED Matrix. /// </summary> /// <param name="frame">On or Off - defaults to On</param> /// <param name="brightness">Between 0 and 15</param> /// <param name="blinkrate">Defaults to Off. Blink rates Fast = 2hz, Medium = 1hz, slow = 0.5hz</param> public Ht16K33BiColor(byte[] I2CAddress, Rotate rotate = Rotate.None, Display frame = LedDriver.Display.On, byte brightness = 0, BlinkRate blinkrate = BlinkRate.Off, string I2cControllerName="I2C1") : base(I2CAddress, rotate, frame, brightness, blinkrate, I2cControllerName) { }
public void SetBlinkRate(BlinkRate blinkrate) { this.blinkrate = blinkrate; SetDisplayState(); }
/// <summary> /// Initializes a new instance of the Ht16K33 I2C controller as found on the Adafriut Mini LED Matrix. /// </summary> /// <param name="frame">On or Off - defaults to On</param> /// <param name="brightness">Between 0 and 15</param> /// <param name="blinkrate">Defaults to Off. Blink rates Fast = 2hz, Medium = 1hz, slow = 0.5hz</param> public Ht16K33BiColor(byte[] I2CAddress, Rotate rotate = Rotate.None, Display frame = LedDriver.Display.On, byte brightness = 0, BlinkRate blinkrate = BlinkRate.Off, string I2cControllerName = "I2C1") : base(I2CAddress, rotate, frame, brightness, blinkrate, I2cControllerName) { }
public void FrameSetBlinkRate(BlinkRate br) { i2Cdriver.FrameSetBlinkRate((byte)br); }
public override void Blink(Led l, int Milliseconds, BlinkRate blinkRate) { Blink(l, 100, blinkRate, (uint)Milliseconds); }
public void SetBlinkRate(BlinkRate blinkrate) { currentBlinkrate = blinkRates[(byte)blinkrate]; UpdateFrameState(); }
int CalculateBlinkRate(BlinkRate rate) { int br = 500; switch (rate) { case BlinkRate.VerySlow: br = 1000; break; case BlinkRate.Slow: br = 500; break; case BlinkRate.Medium: br = 250; break; case BlinkRate.Fast: br = 75; break; case BlinkRate.VeryFast: br = 25; break; } return br; }
/// <summary> /// Initializes a new instance of the Ht16K33 I2C controller as found on the Adafriut Mini LED Matrix. /// </summary> /// <param name="frame">On or Off - defaults to On</param> /// <param name="brightness">Between 0 and 15</param> /// <param name="blinkrate">Defaults to Off. Blink rates Fast = 2hz, Medium = 1hz, slow = 0.5hz</param> public Ht16K33(byte[] I2CAddress = null, Rotate[] rotate = null, Display frame = LedDriver.Display.On, byte brightness = 2, BlinkRate blinkrate = BlinkRate.Off, string I2cControllerName = "I2C1", bool doubleWide = false) { this.panelsPerDevice = doubleWide ? 2 : 1; Columns = 8; Rows = 8; this.brightness = brightness; this.I2cControllerName = I2cControllerName; if (I2CAddress == null) { this.I2CAddress = new byte[] { 0x70 }; } else { this.I2CAddress = I2CAddress; } if (rotate != null && rotate.Length != 1 && rotate.Length != I2CAddress.Length) { throw new ArgumentException("You must specify a rotation for each i2c device"); } if (rotate == null) { rotate = Enumerable.Repeat(Rotate.None, I2CAddress.Length).ToArray(); } else if (rotate.Length == 1 && I2CAddress.Length > 1) { rotate = Enumerable.Repeat(rotate[1], I2CAddress.Length).ToArray(); } else { this.rotate = rotate; } this.PanelsPerFrame = this.I2CAddress.Length * (doubleWide ? 2 : 1); this.i2cDevice = new I2cDevice[this.I2CAddress.Length]; currentFrameState = frameStates[(byte)frame]; currentBlinkrate = blinkRates[(byte)blinkrate]; Initialize(); }
/// <summary> /// Initializes a new instance of the Ht16K33 I2C controller as found on the Adafriut Mini LED Matrix. /// </summary> /// <param name="frame">On or Off - defaults to On</param> /// <param name="brightness">Between 0 and 15</param> /// <param name="blinkrate">Defaults to Off. Blink rates Fast = 2hz, Medium = 1hz, slow = 0.5hz</param> public Ht16K33(byte[] I2CAddress = null, Rotate rotate = Rotate.None, Display frame = LedDriver.Display.On, byte brightness = 2, BlinkRate blinkrate = BlinkRate.Off, string I2cControllerName = "I2C1", bool doubleWide = false) : this(I2CAddress, new[] { rotate }, frame, brightness, blinkrate, I2cControllerName, doubleWide) { }
public void SetBlinkRate(BlinkRate blinkRate) { byte value = (byte)(HT16K33_DSP | (byte)blinkRate); i2cPeripheral.WriteByte(value); }
public virtual void Blink(Led l, int Milliseconds, BlinkRate blinkRate) { //lazy start thread ondemand if (ls[(int)l].ledThread == null) { ls[(int)l].ledThread = new Thread(new ThreadStart(ls[(int)l].Start)); ls[(int)l].ledThread.Start(); } ls[(int)l].blinkMilliseconds = Milliseconds; ls[(int)l].blinkRateMilliseconds = CalculateBlinkRate(blinkRate); ls[(int)l].blink.Set(); }
public void SetBlinkRate(BlinkRate blinkRate) { byte value = (byte)(HT16K33_DSP | (byte)blinkRate); _I2cPeripheral.Write(new byte[] { value }); }
/// <summary> /// Initializes a new instance of the Ht16K33 I2C controller as found on the Adafriut Mini LED Matrix. /// </summary> /// <param name="frame">On or Off - defaults to On</param> /// <param name="brightness">Between 0 and 15</param> /// <param name="blinkrate">Defaults to Off. Blink rates Fast = 2hz, Medium = 1hz, slow = 0.5hz</param> public Ht16K33BiColor(byte[] I2CAddress, Rotate rotate = Rotate.None, Display frame = LedDriver.Display.On, byte brightness = 0, BlinkRate blinkrate = BlinkRate.Off) : base(I2CAddress, rotate, frame, brightness, blinkrate) { }
public void SetBlinkRate(BlinkRate blinkRate) { byte value = (byte)(HT16K33_DSP | (byte)blinkRate); _I2CBus.WriteByte(value); }