Esempio n. 1
0
        public static void Main(string[] args)
        {
            using (var i2cBus = new I2CBusPI("/dev/i2c-1"))
            {
                var i2cDevice = new I2CDevicePI(i2cBus, Display.DefaultI2CAddress);

                display = new SSD1306.Display(i2cDevice, 128, 32);
                display.Init();

                var Tahmona8       = new Tahmona8();
                var tahmona10      = new Tahmona10();
                var tahmona12      = new Tahmona12();
                var tahmona14      = new Tahmona14();
                var dinerRegular24 = new DinerRegular24();

                display.WriteLineBuffProportional(dinerRegular24, "192.168.0.5");
                display.DisplayUpdate();

                while (true)
                {
                    foreach (var dfont in new IFont[] { dinerRegular24, Tahmona8, tahmona10, tahmona12, tahmona14 })
                    {
                        display.WriteLineBuff(dfont, "Hello World 123456", dfont.GetType().Name);
                        display.DisplayUpdate();
                        Console.ReadLine();
                    }
                }
            }
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            IFont font = null;

            bool flip         = false;
            bool ipwait       = false;
            bool proportional = false;
            var  lines        = new List <string>();

            if (args.Length == 0)
            {
                DisplayHelp();
                return;
            }

            for (int i = 0; i < args.Length; i++)
            {
                var argLow = args[i].ToLower();
                switch (argLow)
                {
                case "--flip":
                    flip = true;
                    break;

                case "--ip":
                case "-i":
                    lines.Add(getIPAddress());
                    break;

                case "--proportional":
                case "-p":
                    proportional = true;
                    break;

                case "-f":
                case "--font":
                    i++;
                    foreach (var fontType in GetFonts())
                    {
                        if (fontType.ToString().ToLower().Contains(args[i]))
                        {
                            font = (IFont)Activator.CreateInstance(fontType);
                            continue;
                        }
                    }
                    break;

                case "--ipwait":
                    ipwait = true;
                    break;

                case "--help":
                case "-h":
                    DisplayHelp();
                    return;

                default:
                    lines.Add(args[i]);
                    break;
                }
            }

            while (ipwait)
            {
                var ip = getIPAddress();
                if (!ip.StartsWith("0.") && !ip.StartsWith("127"))
                {
                    lines.Add(ip);
                    ipwait = false;
                    break;
                }
                Thread.Sleep(500);
            }

            if (lines.Count == 0)
            {
                lines.Add(getIPAddress());
            }

            if (font == null && lines.Count == 1)
            {
                Match match = Regex.Match(lines[0], @"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}");
                if (match.Success)
                {
                    font         = new DinerRegular24();
                    proportional = true;
                }
            }

            if (font == null)
            {
                font = new Tahmona10();
            }


            using (var i2cBus = new I2CBusPI("/dev/i2c-1"))
            {
                var i2cDevice = new I2CDevicePI(i2cBus, Display.DefaultI2CAddress);

                var display = new SSD1306.Display(i2cDevice, 128, 32, flip);
                display.Init();

                if (proportional)
                {
                    display.WriteLineBuffProportional(font, lines[0]);
                }
                else
                {
                    display.WriteLineBuff(font, lines.ToArray());
                }
                display.DisplayUpdate();
            }
        }