Exemple #1
0
        public static void TestSevenSegmentDisplay(NusbioSevenSegmentDisplay sevenSegmentDisplay)
        {
            Console.Clear();
            ConsoleEx.TitleBar(0, "Test Seven Segments Display");
            ConsoleEx.WriteMenu(0, 1, " Q)uit");

            sevenSegmentDisplay.Clear(0, refresh: true);
            for (var i = 0; i < sevenSegmentDisplay.SevenSegmentCount; i++)
            {
                Console.WriteLine("7-Segment:{0}, Digit:{1}", i, i);
                sevenSegmentDisplay.SetDigit(0, i, i, false);
                TimePeriod.Sleep(250);
            }

            var pwrs = new List <int>()
            {
                1, 2, 4, 8, 16, 32, 64, 128
            };

            foreach (var pwr in pwrs)
            {
                sevenSegmentDisplay.Clear(0, refresh: true);
                Console.WriteLine("Bit set:{0}", pwr);
                for (var i = 0; i < sevenSegmentDisplay.SevenSegmentCount; i++)
                {
                    sevenSegmentDisplay.SetDigitDataByte(0, i, pwr, !true);
                    TimePeriod.Sleep(100);
                }
            }
        }
Exemple #2
0
        public static void LetterDemo(NusbioSevenSegmentDisplay sevenSegmentDisplay)
        {
            Console.Clear();
            ConsoleEx.TitleBar(0, "Letters Demo");
            ConsoleEx.WriteMenu(0, 1, " Q)uit");

            int  wait = 300;
            bool go   = true;

            sevenSegmentDisplay.Clear(0, refresh: true);
            sevenSegmentDisplay.WriteLetter(0, 7, "HELLO");
            TimePeriod.Sleep(1000);

            while (go)
            {
                sevenSegmentDisplay.Clear(0, refresh: true);
                foreach (var d in NusbioSevenSegmentDisplay.Letters)
                {
                    if (d.Value > 0)
                    {
                        ConsoleEx.WriteLine(0, 3, string.Format("Letter:{0}", d.Key), ConsoleColor.Cyan);
                        SetAllSegmentWithValue(sevenSegmentDisplay, d.Value, wait);
                        TimePeriod.Sleep(600);
                    }
                    if (Console.KeyAvailable)
                    {
                        if (Console.ReadKey().Key == ConsoleKey.Q)
                        {
                            go = false;
                            break;
                        }
                    }
                }
            }
        }
Exemple #3
0
        public static void CounterDemo(NusbioSevenSegmentDisplay sevenSegmentDisplay)
        {
            Console.Clear();
            ConsoleEx.TitleBar(0, "Counter Demo");
            ConsoleEx.WriteMenu(0, 1, " Q)uit");

            sevenSegmentDisplay.Clear(0, refresh: true);

            var counter1 = 000.0;
            var counter2 = 1000.0;
            var format   = "0.0";

            while (counter1 < 200.0)
            {
                ConsoleEx.WriteLine(0, 3, string.Format("{0} {1}", counter2.ToString(format), counter1.ToString(format)).PadRight(16), ConsoleColor.White);
                sevenSegmentDisplay.DisplayNumber(0, counter1, format, 0);
                sevenSegmentDisplay.DisplayNumber(0, counter2, format, 4);
                TimePeriod.Sleep(150);
                counter1 = counter1 + 0.1;
                counter2 = counter2 - 0.1;
                if (Console.KeyAvailable)
                {
                    if (Console.ReadKey().Key == ConsoleKey.Q)
                    {
                        break;
                    }
                }
            }
        }
Exemple #4
0
        public static void PlayWithSegment1(NusbioSevenSegmentDisplay sevenSegmentDisplay)
        {
            Console.Clear();
            ConsoleEx.TitleBar(0, "Play With Segments 1");
            ConsoleEx.WriteMenu(0, 1, " Q)uit");

            int wait = 300;

            while (true)
            {
                sevenSegmentDisplay.Clear(0, refresh: true);
                // Define sequence of bit or segment in the seven segment to light up
                // Bit Definition
                //   64
                //   _
                // 2| |32
                // 1 -
                // 4| |16
                //   -
                //   8
                var values = new List <int>();
                values.Add(1 + 2 + 4 + 8 + 16 + 32 + 64);
                values.Add(values[values.Count - 1] & ~1);

                SetAllSegmentWithValues(sevenSegmentDisplay, values, wait);

                if (Console.KeyAvailable)
                {
                    if (Console.ReadKey().Key == ConsoleKey.Q)
                    {
                        break;
                    }
                }
            }
        }