Пример #1
0
        //    /blink1/fadeToRGB -- Send fadeToRGB command to blink(1) with hex color & fade time
        static string Ublink1FadeToRGB(HttpRequest request, Blink1Server blink1Server)
        {
            // FIXME: stop pattern player
            //NameValueCollection query = request.Query;
            string rgbstr  = request.Query.Get("rgb");
            string timestr = request.Query.Get("time");

            Log("rgb: " + rgbstr);
            if (rgbstr == null)
            {
                rgbstr = "#000000";
            }
            if (timestr == null)
            {
                timestr = "0.1";
            }
            Color colr = ColorTranslator.FromHtml(rgbstr);
            float secs = float.Parse(timestr, CultureInfo.InvariantCulture);

            blink1Server.fadeToRGB(secs, colr);

            Dictionary <string, object> result = new Dictionary <string, object>();

            result.Add("status", "fadeToRGB");
            result.Add("rgb", Blink1.colorToHexCode(colr));
            result.Add("time", secs.ToString("F2", CultureInfo.InvariantCulture));
            return(JsonConvert.SerializeObject(result, Formatting.Indented, jsonSerializerSettings));
        }
Пример #2
0
        //    /blink1/off -- Stop pattern playback and send fadeToRGB command to blink(1) with #000000 & 0.1 sec fade time
        static string Ublink1Off(HttpRequest request, Blink1Server blink1Server)
        {
            blink1Server.stopAllPatterns();
            blink1Server.fadeToRGB(0.1, Color.Black);

            Dictionary <string, object> result = new Dictionary <string, object>();

            result.Add("status", "off");
            return(JsonConvert.SerializeObject(result, Formatting.Indented));
        }
Пример #3
0
        //    /blink1/fadeToRGB -- Send fadeToRGB command to blink(1) with hex color & fade time
        static string Ublink1FadeToRGB(HttpRequest request, Blink1Server blink1Server)
        {
            // FIXME: stop pattern player
            //NameValueCollection query = request.Query;
            string rgbstr = request.Query.Get("rgb");
            string timestr = request.Query.Get("time");
            Log("rgb: " + rgbstr);
            if (rgbstr == null) rgbstr = "#000000";
            if (timestr == null) timestr = "0.1";
            Color colr = ColorTranslator.FromHtml(rgbstr);
            float secs = float.Parse(timestr, CultureInfo.InvariantCulture);

            blink1Server.fadeToRGB(secs, colr);

            Dictionary<string, object> result = new Dictionary<string, object>();
            result.Add("status", "fadeToRGB");
            result.Add("rgb", Blink1.colorToHexCode(colr));
            result.Add("time", secs.ToString("F2", CultureInfo.InvariantCulture));
            return JsonConvert.SerializeObject(result, Formatting.Indented, jsonSerializerSettings);
        }
Пример #4
0
        //    /blink1/off -- Stop pattern playback and send fadeToRGB command to blink(1) with #000000 & 0.1 sec fade time
        static string Ublink1Off(HttpRequest request, Blink1Server blink1Server)
        {
            blink1Server.stopAllPatterns();
            blink1Server.fadeToRGB(0.1, Color.Black);

            Dictionary<string, object> result = new Dictionary<string, object>();
            result.Add("status", "off");
            return JsonConvert.SerializeObject(result, Formatting.Indented);
        }
Пример #5
0
        //    /blink1/on -- Stop pattern playback and send fadeToRGB command to blink(1) with #FFFFFF & 0.1 sec fade time
        static string Ublink1On(HttpRequest request, Blink1Server blink1Server)
        {
            blink1Server.fadeToRGB(0.1, Color.White);

            Dictionary<string, object> result = new Dictionary<string, object>();
            result.Add("status", "on");
            return JsonConvert.SerializeObject(result, Formatting.Indented, jsonSerializerSettings);
        }