예제 #1
0
        /// <summary>
        /// Main entry point
        /// </summary>
        /// <param name="args">Unused</param>
        public static void Main(string[] args)
        {
            // Initialize display (busId = 1 for Raspberry Pi 2 & 3)
            using var display = new Large4Digit7SegmentDisplay(I2cDevice.Create(new I2cConnectionSettings(busId: 1, Ht16k33.DefaultI2cAddress)))
                  {
                      // Set max brightness
                      Brightness = Ht16k33.MaxBrightness
                  };

            // Write "Iot" on the display
            display.Write("Iot");

            // Wait 2 seconds
            Thread.Sleep(2000);

            // Change 'o' to '°' in "IoT"
            display[1] = (Segment)FontHelper.GetCharacter('°');

            // Wait .5 seconds
            Thread.Sleep(500);

            // Write 42 to the left side of the display
            display.Write(42, Alignment.Left);

            // Set blinkrate to once per second
            display.BlinkRate = BlinkRate.Blink1Hz;

            // Wait 5 seconds
            Thread.Sleep(5000);

            // Set blinkrate to twice per second
            display.BlinkRate = BlinkRate.Blink2Hz;

            // Write 42 to the right side of the display
            display.Write(42, Alignment.Right);

            // Set brightness to half max
            display.Brightness = Ht16k33.MaxBrightness / 2;

            // Wait 2 seconds
            Thread.Sleep(2000);

            // Turn off blinking
            display.BlinkRate = BlinkRate.Off;

            // Write time to the display
            display.Write(DateTime.Now.ToString("H:mm").PadLeft(5));

            // Wait 3 seconds
            Thread.Sleep(3000);

            // Turn on buffering
            display.BufferingEnabled = true;

            // Write -42°C to display using "decimal point" between 3rd and 4th digit as the ° character
            display.Write("-42C");
            display.Dots = Dot.DecimalPoint;

            // Turn off buffering
            display.BufferingEnabled = false;

            // Wait 3 seconds
            Thread.Sleep(3000);

            var stringSamples = new[]