コード例 #1
0
        public static Boolean ChangeEffect(NanoleafDevice device, string effect)
        {
            string link    = device.GetLocation() + "/api/v1/" + device.GetAuthToken() + "/effects";
            string request = "{\"select\" : \"" + effect + "\"}";

            return(NanoleafRequest("PUT", link, request));
        }
コード例 #2
0
        public static Boolean ChangeBrightness(NanoleafDevice device, int brightness, int duration)
        {
            string link    = device.GetLocation() + "/api/v1/" + device.GetAuthToken() + "/state";
            string request = "{\"brightness\" : {\"value\": " + brightness + (duration > 0 ? ", \"duration\": " + duration : "") + "} }";

            return(NanoleafRequest("PUT", link, request));
        }
コード例 #3
0
        public static Boolean ChangeState(NanoleafDevice device, Boolean on)
        {
            string link    = device.GetLocation() + "/api/v1/" + device.GetAuthToken() + "/state";
            string request = "{ \"on\": {\"value\": " + on.ToString().ToLower() + "} }";

            return(NanoleafRequest("PUT", link, request));
        }
コード例 #4
0
        public static string[] GetEffectList(NanoleafDevice device)
        {
            string link = device.GetLocation() + "/api/v1/" + device.GetAuthToken() + "/effects/effectsList";

            try {
                string[] list = NanoleafRequest(link).Replace("[", "").Replace("]", "").Replace("\"", "").Split(',');
                return(list);
            } catch {
            }
            return(null);
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: CyberHumi/NI4SLCB
        private void Button224_authtokengenerate_Click(object sender, EventArgs e)
        {
            string token = Nanoleaf.GenerateToken(textBox224_location.Text);

            if (token != null)
            {
                textBox221_authtoken.Text = token;
            }
            if (textBox224_location.Text.Length > 0 && textBox224_authtoken.Text.Length > 0 && !textBox224_authtoken.Text.StartsWith("---"))
            {
                devices[3] = new NanoleafDevice(textBox224_location.Text, textBox224_authtoken.Text);
                UpdateEffectList();
            }
        }
コード例 #6
0
 public static Boolean ChangeBrightness(NanoleafDevice device, int brightness)
 {
     return(ChangeBrightness(device, brightness, -1));
 }
コード例 #7
0
        public static string GetCurrentBrightness(NanoleafDevice device)
        {
            string link = device.GetLocation() + "/api/v1/" + device.GetAuthToken() + "/state/brightness";

            return(NanoleafRequest(link));
        }
コード例 #8
0
        public static string GetCurrentEffect(NanoleafDevice device)
        {
            string link = device.GetLocation() + "/api/v1/" + device.GetAuthToken() + "/effects/select";

            return(NanoleafRequest(link));
        }
コード例 #9
0
        public static string GetState(NanoleafDevice device)
        {
            string link = device.GetLocation() + "/api/v1/" + device.GetAuthToken() + "/state/on";

            return(NanoleafRequest(link));
        }