winfrom LED时钟

    public sealed class Clock : PictureBox
    {
        public Clock()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.ResizeRedraw, true);
            SetStyle(ControlStyles.Selectable, true);
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            SetStyle(ControlStyles.UserPaint, true);
            BackColor = Color.Black;
            Timer = new Timer {Interval = Interval, Enabled = true};
            Timer.Tick += Timer_Tick;
            InitColors();
            InitNumber();
        }

        /// <summary>
        ///
        /// </summary>
        private void Timer_Tick(object sender, EventArgs e)
        {
            var bmp = new Bitmap(Width, Height);
            var g = Graphics.FromImage(bmp);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            if (Type != TimeType.时分秒)
            {
                var year1 = Convert.ToInt32(DateTime.Now.Year.ToString("0000")[0].ToString(CultureInfo.InvariantCulture));
                var year2 = Convert.ToInt32(DateTime.Now.Year.ToString("0000")[1].ToString(CultureInfo.InvariantCulture));
                var year3 = Convert.ToInt32(DateTime.Now.Year.ToString("0000")[2].ToString(CultureInfo.InvariantCulture));
                var year4 = Convert.ToInt32(DateTime.Now.Year.ToString("0000")[3].ToString(CultureInfo.InvariantCulture));
                DrawNumber(g, 0, year1);
                DrawNumber(g, 1, year2);
                DrawNumber(g, 2, year3);
                DrawNumber(g, 3, year4);
                DrawNumber(g, 4, -1);

                var month1 = Convert.ToInt32(DateTime.Now.Month.ToString("00")[0].ToString(CultureInfo.InvariantCulture));
                var month2 = Convert.ToInt32(DateTime.Now.Month.ToString("00")[1].ToString(CultureInfo.InvariantCulture));
                DrawNumber(g, 5, month1);
                DrawNumber(g, 6, month2);
                DrawNumber(g, 7, -1);

                var day1 = Convert.ToInt32(DateTime.Now.Day.ToString("00")[0].ToString(CultureInfo.InvariantCulture));
                var day2 = Convert.ToInt32(DateTime.Now.Day.ToString("00")[1].ToString(CultureInfo.InvariantCulture));
                DrawNumber(g, 8, day1);
                DrawNumber(g, 9, day2);
            }
            if (Type != TimeType.年月日)
            {
                var hour1 = Convert.ToInt32(DateTime.Now.Hour.ToString("00")[0].ToString(CultureInfo.InvariantCulture));
                var hour2 = Convert.ToInt32(DateTime.Now.Hour.ToString("00")[1].ToString(CultureInfo.InvariantCulture));
                DrawNumber(g, Type == TimeType.时分秒 ? 0 : 10, hour1);
                DrawNumber(g, Type == TimeType.时分秒 ? 1 : 11, hour2);

                DrawColon(g, 0);
                var minute1 =
                    Convert.ToInt32(DateTime.Now.Minute.ToString("00")[0].ToString(CultureInfo.InvariantCulture));
                var minute2 =
                    Convert.ToInt32(DateTime.Now.Minute.ToString("00")[1].ToString(CultureInfo.InvariantCulture));
                DrawNumber(g, Type == TimeType.时分秒 ? 2 : 12, minute1);
                DrawNumber(g, Type == TimeType.时分秒 ? 3 : 13, minute2);

                DrawColon(g, 1);
                var second1 =
                    Convert.ToInt32(DateTime.Now.Second.ToString("00")[0].ToString(CultureInfo.InvariantCulture));
                var second2 =
                    Convert.ToInt32(DateTime.Now.Second.ToString("00")[1].ToString(CultureInfo.InvariantCulture));
                DrawNumber(g, Type == TimeType.时分秒 ? 4 : 14, second1);
                DrawNumber(g, Type == TimeType.时分秒 ? 5 : 15, second2);
            }
            BackgroundImage = bmp;
        }

        /// <summary>
        /// 绘制数字
        /// </summary>
        /// <param name="g">GDI</param>
        /// <param name="index">数字位置</param>
        /// <param name="value">数值</param>
        private void DrawNumber(Graphics g, int index,int value)
        {
            if (_numbers.Length > index && WordColor.ContainsKey(value))
            {
                foreach (var key in _numbers[index].Keys)
                {
                    var colors = WordColor[value].Where(s => s.Type == key).ToList();
                    if (colors.Any())
                    {
                        var c = colors[0].Color;
                        using (var brush = new SolidBrush(c))
                        {
                            g.FillPath(brush, _numbers[index][key]);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 绘制冒号
        /// </summary>
        /// <param name="g">GDI</param>
        /// <param name="index">绘制第几个</param>
        private void DrawColon(Graphics g, int index)
        {
            if (_colons.Length > index)
            {
                using (var brush = new SolidBrush(BrightColor))
                {
                    g.FillRectangles(brush, _colons[index]);
                }
            }
        }

        #region 属性
        private Timer Timer { set; get; }
        private TimeType _type = TimeType.时分秒;
        private int _interval = 1000;
        [Description("时钟显示的时间类型"), DefaultValue(typeof(TimeType)), Browsable(true)]
        public TimeType Type
        {
            set
            {
                Stop();
                _type = value;
                InitNumber();
                Start();
                Invalidate();
            }
            get { return _type; }
        }

        /// <summary>
        /// 数字路径
        /// </summary>
        private Dictionary<WordType, GraphicsPath>[] _numbers = new Dictionary<WordType, GraphicsPath>[0];
        /// <summary>
        /// 冒号
        /// </summary>
        private readonly RectangleF[][] _colons = new RectangleF[2][];

        /// <summary>
        /// 时钟跳动间隔
        /// </summary>
        [Description("时钟的跳动间隔(毫秒)"),DefaultValue(typeof(Int32)),Browsable(true)]
        public int Interval
        {
            set
            {
                _interval = value;
                Invalidate();
            }
            get { return _interval; }
        }

        private readonly Color[] _colors = {Color.FromArgb(0, 255, 1), Color.FromArgb(0, 60, 0)};

        /// <summary>
        /// 亮色
        /// </summary>
        [Description("数字的颜色"), DefaultValue(typeof(Color)), Browsable(true)]
        public Color BrightColor
        {
            set
            {
                _colors[0] = value;
                InitColors();
                Invalidate();
            }
            get { return _colors[0]; }
        }

        /// <summary>
        /// 暗色
        /// </summary>
        [Description("数字的背景颜色"), DefaultValue(typeof(Color)), Browsable(true)]
        public Color DarkColor
        {
            set
            {
                _colors[1] = value;
                InitColors();
                Invalidate();
            }
            get { return _colors[1]; }
        }
        /// <summary>
        /// 绘制路径
        /// </summary>
        private Dictionary<WordType,GraphicsPath> Paths { set; get; }
        /// <summary>
        /// 字体颜色设置
        /// </summary>
        private Dictionary<int, Word[]> WordColor { set; get; }

        /// <summary>
        /// 初始化字体颜色
        /// </summary>
        private void InitColors()
        {
            WordColor = new Dictionary<int, Word[]>
            {
                {
                    -1, new[]
                    {
                        new Word(WordType.TopHor, DarkColor),
                        new Word(WordType.LeftTopVer, DarkColor),
                        new Word(WordType.RightTopVer, DarkColor),
                        new Word(WordType.MiddleHor, BrightColor),
                        new Word(WordType.LeftBottomVer, DarkColor),
                        new Word(WordType.RightBottomVer, DarkColor),
                        new Word(WordType.BottomHor, DarkColor)
                    }
                },
                {
                    0, new[]
                    {
                        new Word(WordType.TopHor, BrightColor),
                        new Word(WordType.LeftTopVer, BrightColor),
                        new Word(WordType.RightTopVer, BrightColor),
                        new Word(WordType.MiddleHor, DarkColor),
                        new Word(WordType.LeftBottomVer, BrightColor),
                        new Word(WordType.RightBottomVer, BrightColor),
                        new Word(WordType.BottomHor, BrightColor)
                    }
                },
                {
                    1, new[]
                    {
                        new Word(WordType.TopHor, DarkColor),
                        new Word(WordType.LeftTopVer, DarkColor),
                        new Word(WordType.RightTopVer, BrightColor),
                        new Word(WordType.MiddleHor, DarkColor),
                        new Word(WordType.LeftBottomVer, DarkColor),
                        new Word(WordType.RightBottomVer, BrightColor),
                        new Word(WordType.BottomHor, DarkColor)
                    }
                },
                {
                    2, new[]
                    {
                        new Word(WordType.TopHor, BrightColor),
                        new Word(WordType.LeftTopVer, DarkColor),
                        new Word(WordType.RightTopVer, BrightColor),
                        new Word(WordType.MiddleHor, BrightColor),
                        new Word(WordType.LeftBottomVer, BrightColor),
                        new Word(WordType.RightBottomVer, DarkColor),
                        new Word(WordType.BottomHor, BrightColor)
                    }
                },
                {
                    3, new[]
                    {
                        new Word(WordType.TopHor, BrightColor),
                        new Word(WordType.LeftTopVer, DarkColor),
                        new Word(WordType.RightTopVer, BrightColor),
                        new Word(WordType.MiddleHor, BrightColor),
                        new Word(WordType.LeftBottomVer, DarkColor),
                        new Word(WordType.RightBottomVer, BrightColor),
                        new Word(WordType.BottomHor, BrightColor)
                    }
                },
                {
                    4, new[]
                    {
                        new Word(WordType.TopHor, DarkColor),
                        new Word(WordType.LeftTopVer, BrightColor),
                        new Word(WordType.RightTopVer, BrightColor),
                        new Word(WordType.MiddleHor, BrightColor),
                        new Word(WordType.LeftBottomVer, DarkColor),
                        new Word(WordType.RightBottomVer, BrightColor),
                        new Word(WordType.BottomHor, DarkColor)
                    }
                },
                {
                    5, new[]
                    {
                        new Word(WordType.TopHor, BrightColor),
                        new Word(WordType.LeftTopVer, BrightColor),
                        new Word(WordType.RightTopVer, DarkColor),
                        new Word(WordType.MiddleHor, BrightColor),
                        new Word(WordType.LeftBottomVer, DarkColor),
                        new Word(WordType.RightBottomVer, BrightColor),
                        new Word(WordType.BottomHor, BrightColor)
                    }
                },
                {
                    6, new[]
                    {
                        new Word(WordType.TopHor, BrightColor),
                        new Word(WordType.LeftTopVer, BrightColor),
                        new Word(WordType.RightTopVer, DarkColor),
                        new Word(WordType.MiddleHor, BrightColor),
                        new Word(WordType.LeftBottomVer, BrightColor),
                        new Word(WordType.RightBottomVer, BrightColor),
                        new Word(WordType.BottomHor, BrightColor)
                    }
                },
                {
                    7, new[]
                    {
                        new Word(WordType.TopHor, BrightColor),
                        new Word(WordType.LeftTopVer, DarkColor),
                        new Word(WordType.RightTopVer, BrightColor),
                        new Word(WordType.MiddleHor, DarkColor),
                        new Word(WordType.LeftBottomVer, DarkColor),
                        new Word(WordType.RightBottomVer, BrightColor),
                        new Word(WordType.BottomHor, DarkColor)
                    }
                },
                {
                    8, new[]
                    {
                        new Word(WordType.TopHor, BrightColor),
                        new Word(WordType.LeftTopVer, BrightColor),
                        new Word(WordType.RightTopVer, BrightColor),
                        new Word(WordType.MiddleHor, BrightColor),
                        new Word(WordType.LeftBottomVer, BrightColor),
                        new Word(WordType.RightBottomVer, BrightColor),
                        new Word(WordType.BottomHor, BrightColor)
                    }
                },
                {
                    9, new[]
                    {
                        new Word(WordType.TopHor, BrightColor),
                        new Word(WordType.LeftTopVer, BrightColor),
                        new Word(WordType.RightTopVer, BrightColor),
                        new Word(WordType.MiddleHor, BrightColor),
                        new Word(WordType.LeftBottomVer, DarkColor),
                        new Word(WordType.RightBottomVer, BrightColor),
                        new Word(WordType.BottomHor, DarkColor)
                    }
                }
            };
        }

        #endregion

        /// <summary>
        /// 启动时钟
        /// </summary>
        public void Start()
        {
            if (Timer != null)
            {
                Timer.Start();
            }
        }

        /// <summary>
        /// 关闭时钟
        /// </summary>
        public void Stop()
        {
            if (Timer != null)
            {
                Timer.Stop();
            }
        }

        /// <summary>
        /// 初始化数字路径
        /// </summary>
        private void InitNumber()
        {
            var length = 16;
            switch (Type)
            {
                case TimeType.年月日:
                    _numbers = new Dictionary<WordType, GraphicsPath>[10];
                    length = 10;
                    break;
                case TimeType.年月日时分秒:
                    _numbers = new Dictionary<WordType, GraphicsPath>[16];
                    length = 18;
                    break;
                case TimeType.时分秒:
                    length = 8;
                    _numbers = new Dictionary<WordType, GraphicsPath>[6];
                    break;
            }
            var w = Height/2;
            int x = 5;
            int index = 0;
            for (int i = 0; i < length; i++)
            {
                switch (Type)
                {
                    case TimeType.时分秒:
                        if (i == 2 || i == 5)
                            _colons[i == 2 ? 0 : 1] = Colon(x, 5, Height - 10);
                        else
                        {
                            _numbers[index] = Number(x, 5, Height - 10);
                            index ++;
                        }
                        x = (i == 2 || i == 5) ? x + 15 : w + x + 5;
                        break;
                    case TimeType.年月日:
                        _numbers[i] = Number(x, 5, Height - 10);
                        x = w + x + 5;
                        break;
                    case TimeType.年月日时分秒:
                        if (i != 12 && i != 15)
                        {
                            _numbers[index] = Number(x, 5, Height - 10);
                            index++;
                        }
                        x = (i == 9) ? w*2 + x : (i == 12 || i == 15) ? x : w + x + 5;
                        if (i == 12 || i == 15)
                        {
                            _colons[i == 12 ? 0 : 1] = Colon(x, 5, Height - 10);
                            x = x + w/2;
                        }
                        break;
                    default:
                        x = w + x + 5;
                        _numbers[i] = Number(x, 5, Height - 10);
                        break;
                }
            }
        }

        #region 绘制图像方法

        /// <summary>
        /// 绘制冒号
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="height"></param>
        /// <returns></returns>
        private RectangleF[] Colon(float x, float y, float height)
        {
            var h = height/20;
            var r1 = new RectangleF(x, y + h*6, h*2, h*2);
            var r2 = new RectangleF(x, y + h*12, h*2, h*2);
            return new[] {r1, r2};
        }

        /// <summary>
        /// 绘制数字
        /// </summary>
        /// <param name="x">左上角X轴坐标</param>
        /// <param name="y">左上角Y轴坐标</param>
        /// <param name="height">数字高度</param>
        private Dictionary<WordType, GraphicsPath> Number(float x, float y, float height)
        {
            Paths = new Dictionary<WordType, GraphicsPath>();
            var h = height/20;
            var w = h;
            var width = w*10;
            var x1 = x;
            var x2 = x + w;
            var x3 = x + w*2;
            var x4 = x + width - w*2;
            var x5 = x + width-w;
            var x6 = x + width;
            var y1 = y;
            var y2 = y + h;
            var y3 = y + h*2;
            var y4 = y + (height/2 - h);
            var y5 = y + (height/2);
            var y6 = y + (height/2 + h);
            var y7 = y + height - h*2;
            var y8 = y + height - h;
            var y9 = y + height;
            const float offset = 0.5f;
            var hor1 = new GraphicsPath();
            hor1.AddLines(new[]
            {
                new PointF(x2 + offset, y2 - offset),
                new PointF(x3 + offset, y1 + offset),
                new PointF(x4 - offset, y1 + offset),
                new PointF(x5 - offset, y2 - offset),
                new PointF(x4 - offset, y3 - offset),
                new PointF(x3 + offset, y3 - offset),
                new PointF(x2 + offset, y2 - offset)
            });
            hor1.CloseFigure();
            Paths.Add(WordType.TopHor, hor1);
            var hor2 = new GraphicsPath();
            hor2.AddLines(new[]
            {
                new PointF(x2 +offset, y5),
                new PointF(x3 + offset, y4 + offset),
                new PointF(x4 - offset, y4 + offset),
                new PointF(x5 - offset, y5),
                new PointF(x4 - offset, y6 - offset),
                new PointF(x3 + offset, y6 - offset),
                new PointF(x2 + offset, y5)
            });
            hor2.CloseFigure();
            Paths.Add(WordType.MiddleHor, hor2);
            var hor3 = new GraphicsPath();
            hor3.AddLines(new[]
            {
                new PointF(x2 + offset, y8),
                new PointF(x3 + offset, y7),
                new PointF(x4 - offset, y7),
                new PointF(x5 - offset, y8),
                new PointF(x4 - offset, y9),
                new PointF(x3 + offset, y9),
                new PointF(x2 + offset, y8)
            });
            hor3.CloseFigure();
            Paths.Add(WordType.BottomHor, hor3);
            var ver1 = new GraphicsPath();
            ver1.AddLines(new[]
            {
                new PointF(x1, y3 + offset),
                new PointF(x2, y2 + offset),
                new PointF(x3, y3 + offset),
                new PointF(x3, y4 - offset),
                new PointF(x2, y5 - offset),
                new PointF(x1, y4 - offset)
            });
            ver1.CloseFigure();
            Paths.Add(WordType.LeftTopVer, ver1);
            var ver2 = new GraphicsPath();
            ver2.AddLines(new[]
            {
                new PointF(x4, y3 + offset),
                new PointF(x5, y2 + offset),
                new PointF(x6, y3 + offset),
                new PointF(x6, y4 - offset),
                new PointF(x5, y5 - offset),
                new PointF(x4, y4 - offset)
            });
            ver2.CloseFigure();
            Paths.Add(WordType.RightTopVer, ver2);
            var ver3 = new GraphicsPath();
            ver3.AddLines(new[]
            {
                new PointF(x1, y6 + offset),
                new PointF(x2, y5 + offset),
                new PointF(x3, y6 + offset),
                new PointF(x3, y7 - offset),
                new PointF(x2, y8 - offset),
                new PointF(x1, y7 - offset)
            });
            ver3.CloseFigure();
            Paths.Add(WordType.LeftBottomVer, ver3);
            var ver4 = new GraphicsPath();
            ver4.AddLines(new[]
            {
                new PointF(x4, y6 + offset),
                new PointF(x5, y5 + offset),
                new PointF(x6, y6 + offset),
                new PointF(x6, y7 - offset),
                new PointF(x5, y8 - offset),
                new PointF(x4, y7 - offset)
            });
            ver4.CloseFigure();
            Paths.Add(WordType.RightBottomVer, ver4);
            return Paths;
        }

        #endregion

        protected override void OnResize(EventArgs e)
        {
            InitNumber();
            base.OnResize(e);
        }

        /// <summary>
        /// 数字线条结构
        /// </summary>
        public struct Word
        {
            public Word(WordType type, Color color)
                : this()
            {
                Type = type;
                Color = color;
            }
            /// <summary>
            /// 线条类型
            /// </summary>
            public WordType Type { set; get; }
            /// <summary>
            /// 线条颜色
            /// </summary>
            public Color Color { set; get; }
        }
        #region 隐藏的属性
        [Description("背景图像"),DefaultValue(null),Browsable(false)]
        public new Image BackgroundImage {get { return base.BackgroundImage; } set { base.BackgroundImage = value; } }
        [Description("背景图像布局"), DefaultValue(typeof(ImageLayout)), Browsable(false)]
        public new ImageLayout BackgroundImageLayout { get { return base.BackgroundImageLayout; } set { base.BackgroundImageLayout = value; } }
        [Description("显示的图像"), DefaultValue(null), Browsable(false)]
        public new Image Image{get { return base.Image; } set { base.Image = value; }}
        [Description("加载错误时显示的图像"), DefaultValue(null), Browsable(false)]
        public new Image ErrorImage{get { return base.ErrorImage; } set { base.ErrorImage = value; }}
        [Description("加初始化时显示的图像"), DefaultValue(null), Browsable(false)]
        public new Image InitialImage{set { base.InitialImage = value; } get { return base.InitialImage; }}
        [Description("只是如何显示图像"), DefaultValue(typeof(PictureBoxSizeMode)), Browsable(false)]
        public new PictureBoxSizeMode SizeMode {set { base.SizeMode = value; } get { return base.SizeMode; } }
        #endregion
    }

    /// <summary>
    /// 数字线条枚举
    /// </summary>
    public enum WordType
    {
        TopHor = 0,
        LeftTopVer = 1,
        RightTopVer = 2,
        MiddleHor = 3,
        LeftBottomVer = 4,
        RightBottomVer = 5,
        BottomHor = 6
    }

    public enum TimeType
    {
        年月日,
        时分秒,
        年月日时分秒
    }

winfrom LED时钟,布布扣,bubuko.com

时间: 2024-10-05 17:23:04

winfrom LED时钟的相关文章

网友纯手工打造摇摆LED时钟 ,牛!

手工打造摇摆LED时钟 ,牛! 摇摆LED 时钟,感觉非常新颖独特,正在玩单片机的我,激起了自己也想DIY 一个的冲动.不就是一个流水灯吗?有什么难的?! 于是,一个单片机项目就这样开始了.然而动手以后才知道问题并非想象那样简单,因没有任何现成的资料,机械的.电子的和编程的问题一大堆,一个一个需要自己来解决.经历二十多天的苦战和无数次的修改与调试,作品终于完成,基本达到预先要求.    现将制作资料整理出来,与广大DIY 爱好者分享. 一. 整体方案    本制作是根据视觉暂留原理, 让一排8

LED时钟|语音同步LED时钟农历计算代码(立显光电)

LED时钟|语音同步LED时钟农历计算代码由深圳市立显光电有限公司技术部提供,欢迎指正,谢谢! void Lunar_Calculation(void){ unsigned char  temp1,temp2,temp3,month_p;    unsigned int temp4,table_addr; unsigned char flag2,flag_y; unsigned char year=time_buf[1];//阳历年 unsigned char month=time_buf[2]

21个挑战题

我时不时地会给我的朋友和同事一些难题.我把这些称为咖啡时间的挑战.题目被设计成很小的,但在短暂休息时要反复考虑的题目. 这些都是典型的不难的题目,并且通常都有多种解决方案.有时,人们用铅笔.纸和数学首要原则来解决这些问题.此外,人们也会通过写正则表达式.LINQ.Perl或Python脚本来解决.解决方式有时优雅,有时用蛮力,这里并没有所谓正确或错误的方法,只要得到的是一个正确的答案. 我尽量选择不涉及聪明"陷阱"或"技巧"的难题.这类型的题目对于那些知晓其中秘密的

嵌入式学习-uboot-lesson6-时钟初始化

1 6410时钟体系 从上图以及原理图可以知道下面的内容: 1.采用12M的晶振 2 有三个分频器 APLL MPLL EPLL 3.产生了四个时钟 ACLK HCLK PCLK SCLK 下面是几个时钟的应用范围: 其中ACLK为系统时钟,HCLK和PCLK为各种外设和内部的时钟,SCLK暂且不考虑 2时钟初始化过程 从上图可以看出,SYSCLK为系统时钟,起初频率为12MHZ,当设置频率之后,系统频率为有一段时间为0,这一时间为lock time ,如果要设置,可以对其进行操作,但是,一般情

嵌入式学习-uboot-lesson7-内存初始化

6410所使用的内存为DDR 210使用的是DDR2 2440使用的是SDRAM,关于他们之间的区别,我在以前的文章中ok6410内存及启动流程简单介绍过,有兴趣的可以看看. 1. 地址空间 S3C6410处理器拥32位地址总线,其寻址空间为4GB.其中高2GB为保留区,低2GB区域又可划分为两部分:主存储区和外设区. 外设区主要是与6410寄存器相关,在核心初始化-外设基地址初始化中,有说明外设的寄存器的基地址为0x70000000 下面则是主存储区的地址分布,在以前的课程中有介绍,现在贴出来

STM32学习之路-SysTick的应用(时间延迟)

开发板:奋斗V5 好~ 菜B要来搞实验了.. 前面已经说了SysTick的工作原理什么的了,这里就不说了.. 先来做第一个实验: 盗自奋斗的样例,嘿嘿, 用SysTick产生1ms的基准时间,产生中断,每秒闪烁一次(LED1 V6) (1)外围时钟初始化(系统时钟初始化这里就不写了,上次说了) (2)LED初始化 (3)SysTick配置 (4)中断优先级 (5)中断处理函数 (6)延迟函数 OK,上代码: (1)外围时钟初始化 void RCC_Config(void) { RCC_APB2P

jquery+html5制作超酷的圆盘时钟表

自己封装的一个用HTML5+jQuery写的时钟表 代码: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

NTP同步时钟系统的实现及局域网授时方法

NTP同步时钟系统的实现及局域网授时方法分析如下:             实现NTP同步时钟系统需要局域网成员:NTP时钟服务器,NTP同步主时钟,NTP同步从时钟. NTP时钟系统实现的方法说明,让我们来举个例子吧.如某机场是某省的重要航空交通枢纽,是一个现代化的大型机场.机场内有电子钟94个,同时建设有离港系统.航显系统.广播系统.指挥调度系统.安检信息系统.楼宇自控系统.安防监控系统.停车场管理系统.呼叫中心系统等多个信息系统,这些系统通过接口互相连接协同工作,时间的一致性非常重要.通过

GPS同步时钟与NTP同步时钟误差分析

深圳市立显电子有限公司,专业LED时钟生产厂家!--------[点击进入] GPS同步时钟与NTP同步时钟误差分析,让客户更好的调整自己的LED时钟产品. 在我们某试验系统方案设计中,由于数据同步性的要求,需要将我们GPS/NTP网络同步的时钟与客户的NTP服务器系统的时钟进行同步,对于测试系统而言,多台分析仪之间可通过同步光纤接口达到严格同步,同步时序达us级.但要求NTP服务器测试系统与其它系统之间保持同步,在同步性要求不是特别高的情况下,可以采用NTP时钟同步或GPS时钟同步的方式进行多