using System.Threading;
using Microsoft.SPOT.Hardware;

namespace GrFamily.MainBoard
{
    /// <summary>
    /// }CR{[hãÌfobOLED (User LED)
    /// </summary>
    /// <remarks>±ÌCuÅfobOLEDÆÄÔÌÍ}CR{[hãÌÈºÌLEDÌ±Æ<br />
    /// EGR-PEACH : User LED<br />
    /// EGR-SAKURA : LED4</remarks>
    public class DebugLed : Led
    {
        /// <summary>
        /// RXgN^[
        /// </summary>
        /// <param name="pin">fobOLEDªÚ±³ê½s</param>
        public DebugLed(Cpu.Pin pin) : base(pin)
        {
        }

        /// <summary>
        /// fobOLEDð1ñ_Å³¹é
        /// </summary>
        public void PulseDebugLed()
        {
            new Thread(() =>
            {
                SetLed(true);
                Thread.Sleep(100);
                SetLed(false);
            }).Start();
        }

        /// <summary>
        /// fobOLEDðwèñAwèÔuÅ_Å³¹é
        /// </summary>
        /// <param name="length">_ÅÔuiPÊF~bj</param>
        /// <param name="times">_Åñ</param>
        public void PulseDebugLed(int length, int times)
        {
            new Thread(() =>
            {
                for (var i = 0; i < times; i++)
                {
                    SetLed(true);
                    Thread.Sleep(length);
                    SetLed(false);
                    Thread.Sleep(length);
                }
            }).Start();
        }
    }
}
