Skip to content

Commit 13da8fc

Browse files
committed
improved volume control
1 parent 1aa1aa3 commit 13da8fc

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

www/scripts/sepiaFW.client.controls.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
function sepiaFW_build_client_controls(){
55
var Controls = {};
66

7+
function parseAction(action){
8+
var req;
9+
if (typeof action === "string"){
10+
req = JSON.parse(action);
11+
}else{
12+
req = action;
13+
}
14+
return req;
15+
}
16+
717
//Open/close settings menu
818
Controls.settings = function(controlData){
919
if (controlData && controlData.action){
@@ -50,10 +60,15 @@ function sepiaFW_build_client_controls(){
5060
//volumeDown
5161
volumeDown();
5262
return true;
53-
}else if (controlData.action == "set"){
63+
}else if (controlData.action.match(/volume;;\d/gi).length == 1){
5464
//volumeSet
55-
volumeSet(controlData.volume); //TODO: untested and not fully implemented yet
56-
return true;
65+
var vol = parseInt(controlData.action.split(";;")[1]); //no data, we have the shortcut here ;-)
66+
if (vol){
67+
volumeSet(vol); //TODO: untested and not fully implemented yet
68+
return true;
69+
}else{
70+
return false;
71+
}
5772
}else{
5873
SepiaFW.debug.error("Client controls - Unsupported action in 'settings': " + controlData.action);
5974
}
@@ -89,16 +104,21 @@ function sepiaFW_build_client_controls(){
89104
}
90105
}
91106

107+
//CLEXI send
108+
Controls.clexi = function(controlData){
109+
if (SepiaFW.clexi && controlData.action){
110+
var req = parseAction(controlData.action);
111+
//console.log(req);
112+
SepiaFW.clexi.send(req.xtension, req.data);
113+
return true;
114+
}
115+
return false;
116+
}
117+
92118
//Mesh-Node call
93119
Controls.meshNode = function(controlData){
94-
//TODO
95120
if (controlData.action){
96-
var req;
97-
if (typeof controlData.action === "string"){
98-
req = JSON.parse(controlData.action);
99-
}else{
100-
req = controlData.action;
101-
}
121+
var req = parseAction(controlData.action);
102122
//console.log(req);
103123
return callMeshNode(req.url, req.pin, req.plugin, req.data);
104124
}

www/scripts/sepiaFW.teach.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function sepiaFW_build_teach(){
128128
name : "Action (e.g.: <on> or <increase>): "
129129
},{
130130
value : "client_fun",
131-
name : "Function (e.g.: settings, volume, meshNode): "
131+
name : "Function (e.g.: settings, volume, meshNode, ...): " //alwaysOn, clexi
132132
},{
133133
value : "data",
134134
name : "Additional data (e.g. JSON)",

0 commit comments

Comments
 (0)