예제 #1
0
        private static void SetBacklightColorTest(Hd44780 lcd)
        {
            var colorLcd = lcd as LcdRgb;

            if (colorLcd == null)
            {
                Console.WriteLine("Color backlight not supported");
                return;
            }

            Color[] colors =
            {
                Color.Red,   Color.Green,     Color.Blue,         Color.Aqua, Color.Azure,
                Color.Brown, Color.Chocolate, Color.LemonChiffon, Color.Lime, Color.Tomato, Color.Yellow
            };

            foreach (var color in colors)
            {
                lcd.Clear();
                lcd.Write(color.Name);

                colorLcd.SetBacklightColor(color);
                System.Threading.Thread.Sleep(1000);
            }

            lcd.Clear();
            colorLcd.SetBacklightColor(Color.White);
        }
예제 #2
0
        static void TestPrompt(string test, Hd44780 lcd, Action <Hd44780> action)
        {
            string prompt = $"Test {test}:";

            lcd.Clear();
            lcd.Write(prompt);
            lcd.BlinkingCursorVisible = true;
            Console.Write(prompt);
            Console.ReadLine();
            lcd.BlinkingCursorVisible = false;
            lcd.Clear();
            action(lcd);
            Console.Write("Test Complete:");
            Console.ReadLine();
            lcd.Clear();
        }
예제 #3
0
        private static void PerfTests(Hd44780 lcd)
        {
            string    stars     = new string('*', 80);
            Stopwatch stopwatch = Stopwatch.StartNew();

            lcd.Clear();
            for (int i = 0; i < 25; i++)
            {
                lcd.Write(Eighty);
                lcd.Write(stars);
            }

            lcd.Clear();
            stopwatch.Stop();
            string result = $"Elapsed ms: {stopwatch.ElapsedMilliseconds}";

            lcd.Write(result);
            Console.WriteLine(result);
        }
예제 #4
0
 static void DisplayAndBackLightOnOff(Hd44780 lcd)
 {
     lcd.Clear();
     lcd.Write("This is some text");
     lcd.DisplayOn = false;
     Thread.Sleep(1000);
     lcd.DisplayOn   = true;
     lcd.BacklightOn = false;
     Thread.Sleep(1000);
     lcd.BacklightOn = true;
 }
예제 #5
0
        public static void Test(Hd44780 lcd)
        {
            Console.WriteLine("Starting...");
            lcd.Clear();
            Console.WriteLine("Initialized");
            Console.ReadLine();
            TestPrompt("SetCursor", lcd, SetCursorTest);
            TestPrompt("Underline", lcd, l => l.UnderlineCursorVisible = true);
            lcd.UnderlineCursorVisible = false;
            TestPrompt("Walker", lcd, WalkerTest);
            CreateTensCharacters(lcd);
            TestPrompt("CharacterSet", lcd, CharacterSet);

            TestPrompt("DisplayEnable", lcd, DisplayAndBackLightOnOff);

            // Shifting
            TestPrompt("Autoshift", lcd, AutoShift);
            TestPrompt("DisplayLeft", lcd, l => ShiftDisplayTest(l, a => a.ShiftDisplayLeft()));
            TestPrompt("DisplayRight", lcd, l => ShiftDisplayTest(l, a => a.ShiftDisplayRight()));
            TestPrompt("CursorLeft", lcd, l => ShiftCursorTest(l, a => a.ShiftCursorLeft()));
            TestPrompt("CursorRight", lcd, l => ShiftCursorTest(l, a => a.ShiftCursorRight()));

            // Long string
            TestPrompt("Twenty", lcd, l => l.Write(Twenty));
            TestPrompt("Fourty", lcd, l => l.Write(Fourty));
            TestPrompt("Eighty", lcd, l => l.Write(Eighty));

            TestPrompt("Twenty-", lcd, l => WriteFromEnd(l, Twenty));
            TestPrompt("Fourty-", lcd, l => WriteFromEnd(l, Fourty));
            TestPrompt("Eighty-", lcd, l => WriteFromEnd(l, Eighty));

            TestPrompt("Wrap", lcd, l => l.Write(new string('*', 80) + ">>>>>"));
            TestPrompt("Perf", lcd, PerfTests);

            TestPrompt("Colors", lcd, SetBacklightColorTest);

            TestPrompt("Time", lcd, TestClock);
            lcd.DisplayOn   = false;
            lcd.BacklightOn = false;
            Console.WriteLine("Done...");
        }