Exemple #1
0
        private static string Backlight(string data, List <string> _)
        {
            string ret = "ok";

            Lcd1602 lcd = new Lcd1602();

            lcd.OpenDevice("/dev/i2c-1", LCD1602_ADDRESS);
            lcd.Init();

            switch (data.ToLower())
            {
            case "on":
                lcd.DisplayOn();
                break;

            case "off":
                lcd.DisplayOff();
                break;

            default:
                ret = "Usage: backlight on|off";
                break;
            }

            lcd.CloseDevice();

            return(ret);
        }
Exemple #2
0
        private static string Display(string data, List <string> _)
        {
            int numQuotes = data.Count(c => c == '\"');

            if (data.First() != '\"' || data.Last() != '\"' && (numQuotes != 2 && numQuotes != 4))
            {
                return("bad format");
            }

            Lcd1602 lcd = new Lcd1602();

            lcd.OpenDevice("/dev/i2c-1", LCD1602_ADDRESS);
            lcd.Init();
            lcd.Clear();

            if (numQuotes == 2)
            {
                lcd.Write(0, 0, data.Between("\"", "\""));
            }
            else
            {
                // two lines
                lcd.Write(0, 0, data.Between("\"", "\""));
                lcd.Write(0, 1, data.RightOf("\"").RightOf("\"").Between("\"", "\""));
            }

            lcd.CloseDevice();

            return("ok");
        }