Exemple #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));
        }