Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ArgumentParser pp = new ArgumentParser(args);
            pp.AddExpanded("-l", "--light");
            pp.AddExpanded("-nl", "--no-light");
            pp.Parse();

            var lcdProvider = new RaspPiGPIOMemLcdTransferProvider(GPIOPins.GPIO_07, GPIOPins.GPIO_08, GPIOPins.GPIO_25, GPIOPins.GPIO_24, GPIOPins.GPIO_23, GPIOPins.GPIO_18);
            var lcd = new Lcd(lcdProvider);

            GPIOMem backlit = new GPIOMem(GPIOPins.GPIO_15, GPIODirection.Out);
            //backlit.Write(false);

            lcd.Begin(16, 2);
            lcd.Clear();
            lcd.SetCursorPosition(0, 0);

            if (pp.SwitchExists("--light"))
            {
                backlit.Write(true);
            }

            if (pp.SwitchExists("--no-light"))
            {
                backlit.Write(false);
            }

            string text = String.Empty;
            try
            {
                var isKey = System.Console.KeyAvailable;
                text = Console.ReadLine();
            }
            catch (InvalidOperationException)
            {
                // when we're in piped output, InvalidOperationException is thrown for KeyAvaliable
                // and we're using it here to check... dirty, dirty hack!
                text = Console.In.ReadToEnd();
            }

            //Console.WriteLine(text);

            text = text.Replace("\r\n", "\n");
            if (text.Length > 32) text = text.Substring(0, 32);
            if (text.Length > 16) text = text.Insert(16, "\n");

            if (text.IndexOf('\n') > -1)
            {
                lcd.Write(text.Substring(0, text.IndexOf('\n')));
                lcd.SetCursorPosition(0, 1);
                lcd.Write(text.Substring(text.IndexOf('\n') +1));
            }
            else
                lcd.Write(text);
        }
Exemplo n.º 2
0
 static void SetHeatingPin(PinState state)
 {
     GPIOMem heatingPin = new GPIOMem(GPIOPins.GPIO_14);
     heatingPin.PinDirection = GPIODirection.Out;
     heatingPin.Write(state);
 }