Esempio n. 1
0
        private void StatusUpdateTimer_Tick(object sender, object e)
        {
            var elapsed = (DateTime.Now - gameStart).TotalSeconds;

            ssd.DrawString(elapsed.ToString("0.0"));
            ssd.FrameDraw();
            //timerDisplay.Send(SegmentEncoding.Integer, (int)elapsed.TotalSeconds);
        }
Esempio n. 2
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            _deferral = taskInstance.GetDeferral();  // get the deferral handle

            int count = 0;

            MAX7219             driver = new MAX7219(2);
            SevenSegmentDisplay ssd    = new SevenSegmentDisplay(driver);
            BMP180 bmp = new BMP180(BMP180.Mode.HIGHRES);

            ssd.FrameClear();
            ssd.FrameDraw();
            ssd.SetBrightness(4);

            while (true)
            {
                temperature = bmp.Temperature.DegreesCelsius;

                data.Clear();

                // is temperature less than 3 digits and there is a decimal part too then right pad to 5 places as decimal point does not take up a digit space on the display
                if (temperature < 100 && temperature != (int)temperature)
                {
                    data.Append($"{Math.Round(temperature, 1)}C".PadRight(5));
                }
                else
                {
                    data.Append($"{Math.Round(temperature, 0)}C".PadRight(4));
                }

                data.Append(Math.Round(bmp.Pressure.Hectopascals, 0));

                if (blink = !blink)
                {
                    data.Append(".");
                }                                          // add a blinking dot on bottom right as an I'm alive indicator

                ssd.DrawString(data.ToString());

                ssd.DrawString(count++, 1);

                ssd.FrameDraw();

                Task.Delay(2000).Wait();
            }
        }
Esempio n. 3
0
    protected override void OnPaint(PaintEventArgs pea)
    {
        SevenSegmentDisplay ssd = new SevenSegmentDisplay(pea.Graphics);

        string strTime = dt.ToString("T",
                                     DateTimeFormatInfo.InvariantInfo);
        SizeF sizef  = ssd.MeasureString(strTime, Font);
        float fScale = Math.Min(ClientSize.Width / sizef.Width,
                                ClientSize.Height / sizef.Height);
        Font font = new Font(Font.FontFamily,
                             fScale * Font.SizeInPoints);

        sizef = ssd.MeasureString(strTime, font);

        ssd.DrawString(strTime, font, Brushes.Red,
                       (ClientSize.Width - sizef.Width) / 2,
                       (ClientSize.Height - sizef.Height) / 2);
    }