Commit acf59a84 by Sebastián Katzer

Allow led option to be a hash as well

parent bc2c02cc
...@@ -170,6 +170,9 @@ public class Options { ...@@ -170,6 +170,9 @@ public class Options {
} else } else
if (cfg instanceof JSONArray) { if (cfg instanceof JSONArray) {
hex = options.optJSONArray("led").optString(0); hex = options.optJSONArray("led").optString(0);
} else
if (cfg instanceof JSONObject) {
hex = options.optJSONObject("led").optString("color");
} }
if (hex == null) if (hex == null)
...@@ -192,11 +195,15 @@ public class Options { ...@@ -192,11 +195,15 @@ public class Options {
*/ */
int getLedOn() { int getLedOn() {
Object cfg = options.opt("led"); Object cfg = options.opt("led");
int defVal = 1000;
if (cfg instanceof JSONArray) if (cfg instanceof JSONArray)
return options.optJSONArray("led").optInt(1); return options.optJSONArray("led").optInt(1, defVal);
if (cfg instanceof JSONObject)
return options.optJSONObject("led").optInt("on", defVal);
return 1000; return defVal;
} }
/** /**
...@@ -204,11 +211,15 @@ public class Options { ...@@ -204,11 +211,15 @@ public class Options {
*/ */
int getLedOff() { int getLedOff() {
Object cfg = options.opt("led"); Object cfg = options.opt("led");
int defVal = 1000;
if (cfg instanceof JSONArray) if (cfg instanceof JSONArray)
return options.optJSONArray("led").optInt(2); return options.optJSONArray("led").optInt(2, defVal);
if (cfg instanceof JSONObject)
return options.optJSONObject("led").optInt("off", defVal);
return 1000; return defVal;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment