示例#1
0
 static void WriteFromEnd(Hd44780Base lcd, string value)
 {
     lcd.Increment = false;
     lcd.SetCursorPosition(lcd.Size.Width - 1, lcd.Size.Height - 1);
     lcd.Write(value);
     lcd.Increment = true;
 }
示例#2
0
        static void ShiftDisplayTest(Hd44780Base lcd, Action <Hd44780Base> action)
        {
            Size size = lcd.Size;

            lcd.Write(Eighty.Substring(0, size.Height * size.Width));
            ShiftTest(lcd, action);
        }
示例#3
0
        static void CharacterSet(Hd44780Base lcd)
        {
            StringBuilder sb = new StringBuilder(256);

            for (int i = 0; i < 256; i++)
            {
                sb.Append((char)i);
            }

            int  character = 0;
            int  line      = 0;
            Size size      = lcd.Size;

            while (character < 256)
            {
                lcd.SetCursorPosition(0, line);
                lcd.Write(sb.ToString(character, Math.Min(size.Width, 256 - character)));
                line++;
                character += size.Width;
                if (line >= size.Height)
                {
                    line = 0;
                    System.Threading.Thread.Sleep(1000);
                }
            }
        }
示例#4
0
        static void AutoShift(Hd44780Base lcd)
        {
            lcd.AutoShift = true;
            Size size = lcd.Size;

            lcd.Write(Eighty.Substring(0, size.Width + size.Width / 2));
            lcd.AutoShift = false;
        }
示例#5
0
        static void ShiftTest(Hd44780Base lcd, Action <Hd44780Base> action)
        {
            Size size = lcd.Size;

            for (int i = 0; i <= size.Width; i++)
            {
                action(lcd);
                System.Threading.Thread.Sleep(250);
            }
        }
示例#6
0
        static void SetCursorTest(Hd44780Base lcd)
        {
            Size size   = lcd.Size;
            int  number = 0;

            for (int i = 0; i < size.Height; i++)
            {
                lcd.SetCursorPosition(0, i);
                lcd.Write($"{number++}");
                lcd.SetCursorPosition(size.Width - 1, i);
                lcd.Write($"{number++}");
            }
        }
示例#7
0
        static void WalkerTest(Hd44780Base lcd)
        {
            CreateWalkCharacters(lcd);
            string walkOne = new string('\x8', lcd.Size.Width);
            string walkTwo = new string('\x9', lcd.Size.Width);

            for (int i = 0; i < 5; i++)
            {
                lcd.SetCursorPosition(0, 0);
                lcd.Write(walkOne);
                System.Threading.Thread.Sleep(500);
                lcd.SetCursorPosition(0, 0);
                lcd.Write(walkTwo);
                System.Threading.Thread.Sleep(500);
            }
        }
示例#8
0
        static void PerfTests(Hd44780Base 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);
        }
示例#9
0
 static void CreateWalkCharacters(Hd44780Base lcd)
 {
     // Walk 1
     lcd.CreateCustomCharacter(0,
                               0b_00110,
                               0b_00110,
                               0b_01100,
                               0b_10111,
                               0b_00100,
                               0b_01110,
                               0b_01010,
                               0b_10001);
     // Walk 2
     lcd.CreateCustomCharacter(1,
                               0b_00110,
                               0b_00110,
                               0b_01100,
                               0b_01100,
                               0b_00110,
                               0b_00110,
                               0b_01010,
                               0b_01010);
 }
示例#10
0
 static void CreateTensCharacters(Hd44780Base lcd)
 {
     // 10
     lcd.CreateCustomCharacter(0,
                               0b_10000,
                               0b_10000,
                               0b_10000,
                               0b_10000,
                               0b_10111,
                               0b_00101,
                               0b_00101,
                               0b_00111);
     // 20
     lcd.CreateCustomCharacter(1,
                               0b_11100,
                               0b_00100,
                               0b_11100,
                               0b_10000,
                               0b_11111,
                               0b_00101,
                               0b_00101,
                               0b_00111);
     // 30
     lcd.CreateCustomCharacter(2,
                               0b_11100,
                               0b_00100,
                               0b_11100,
                               0b_00100,
                               0b_11111,
                               0b_00101,
                               0b_00101,
                               0b_00111);
     // 40
     lcd.CreateCustomCharacter(3,
                               0b_10100,
                               0b_10100,
                               0b_11100,
                               0b_00100,
                               0b_00111,
                               0b_00101,
                               0b_00101,
                               0b_00111);
     // 50
     lcd.CreateCustomCharacter(4,
                               0b_11100,
                               0b_10000,
                               0b_11100,
                               0b_00100,
                               0b_11111,
                               0b_00101,
                               0b_00101,
                               0b_00111);
     // 60
     lcd.CreateCustomCharacter(5,
                               0b_11100,
                               0b_10000,
                               0b_11100,
                               0b_10100,
                               0b_11111,
                               0b_00101,
                               0b_00101,
                               0b_00111);
     // 70
     lcd.CreateCustomCharacter(6,
                               0b_11100,
                               0b_00100,
                               0b_01000,
                               0b_01000,
                               0b_01111,
                               0b_00101,
                               0b_00101,
                               0b_00111);
     // 80
     lcd.CreateCustomCharacter(7,
                               0b_11100,
                               0b_10100,
                               0b_11100,
                               0b_10100,
                               0b_11111,
                               0b_00101,
                               0b_00101,
                               0b_00111);
 }
示例#11
0
 static void ShiftCursorTest(Hd44780Base lcd, Action <Hd44780Base> action)
 {
     lcd.BlinkingCursorVisible = true;
     ShiftTest(lcd, action);
     lcd.BlinkingCursorVisible = false;
 }