Skip to content

Commit

Permalink
Just pushing this because it works
Browse files Browse the repository at this point in the history
  • Loading branch information
KonradIT committed Aug 10, 2016
1 parent de746d5 commit 8e35b0c
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 45 deletions.
2 changes: 1 addition & 1 deletion appinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
]
},
"sdkVersion": "3",
"shortName": "GoPro",
"shortName": "CamControl GP",
"targetPlatforms": [
"aplite",
"basalt",
Expand Down
165 changes: 121 additions & 44 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,29 @@ var main = new UI.Card({
title: 'Hello People!'
});
function main_cam(){
var model ="";
var xhr_model = new XMLHttpRequest();
xhr_model.open("GET", "http://10.5.5.9/gp/gpControl", true);
xhr_model.timeout = 800;
xhr_model.onload = function () {
if (xhr_model.readyState === xhr_model.DONE) {
if (xhr_model.status === 200) {

var model_obj = JSON.parse(xhr_model.responseText);
model = model_obj.info['model name'];
}
}
};

//code goes here that will be run every 5 seconds.

var xhr = new XMLHttpRequest();
xhr.open("GET", "http://10.5.5.9/gp/gpControl/status", true);
xhr.timeout = 800;
xhr.onload = function () {
if (xhr.readyState === xhr.DONE) {
if (xhr.status === 200) {

var obj = JSON.parse(xhr.responseText);
var batt_percent;
var mode;
Expand All @@ -26,6 +43,7 @@ function main_cam(){

//get camera details
switch(obj.status[2]){

case 3:
batt_percent = "FULL";
break;
Expand Down Expand Up @@ -166,10 +184,10 @@ function main_cam(){
bodyColor: 'white',
backgroundColor: 'black'
});

main.show();
main.on('click', 'up', function(e) {
var menu = new UI.Menu({
title: 'modes',
backgroundColor: 'black',
textColor: 'white',
highlightBackgroundColor: 'blue',
Expand Down Expand Up @@ -209,15 +227,23 @@ main.show();
switch(video_menu_selection.itemIndex){
case 0:
command_h4_modes('0','0');
video_menu.hide();
menu.hide();
break;
case 1:
command_h4_modes('0','1');
video_menu.hide();
menu.hide();
break;
case 2:
command_h4_modes('0','2');
video_menu.hide();
menu.hide();
break;
case 3:
command_h4_modes('0','3');
video_menu.hide();
menu.hide();
break;
}
});
Expand Down Expand Up @@ -245,12 +271,18 @@ main.show();
switch(photo_menu_selection.itemIndex){
case 0:
command_h4_modes('1','0');
photo_menu.hide();
menu.hide();
break;
case 1:
command_h4_modes('1','1');
photo_menu.hide();
menu.hide();
break;
case 2:
command_h4_modes('1','2');
photo_menu.hide();
menu.hide();
break;
}
});
Expand All @@ -277,12 +309,18 @@ main.show();
switch(photo_menu_selection.itemIndex){
case 0:
command_h4_modes('2','0');
ms_menu.hide();
menu.hide();
break;
case 1:
command_h4_modes('2','1');
ms_menu.hide();
menu.hide();
break;
case 2:
command_h4_modes('2','2');
ms_menu.hide();
menu.hide();
break;
}
});
Expand All @@ -308,7 +346,9 @@ main.on('click', 'select', function(e) {
xhr2.open("GET", "http://10.5.5.9/gp/gpControl/command/shutter?p=1", true);
xhr2.send(null);
Vibe.vibrate('double');
main.backgroundColor('red');
if(obj.status[43] === 0){
main.backgroundColor('red');
}
break;
case 1:
//stop
Expand All @@ -324,81 +364,118 @@ main.on('click', 'select', function(e) {
xhr.send(null);
});
main.on('click', 'down', function(e){
var menu = new UI.Menu({
var settings_menu = new UI.Menu({
title: 'settings',
backgroundColor: 'black',
textColor: 'white',
highlightBackgroundColor: 'blue',
highlightTextColor: 'white',
sections: [{
title: 'settings',
items: [{
title: 'Turn On/Off',
title: 'VIDEO',
},{
title: 'Video Resolution',
}, {
title: 'Video Framerate',
title: 'PHOTO',
}, {
title: 'Video Protune',
title: 'MULTISHOT',
}, {
title: 'Photo Resolution',
},{
title: 'Photo Protune',
},{
title: 'Continuous photo rate',
},{
title: 'NightPhoto Exposure',
},{
title: 'MultiShot resolution',
},{
title: 'Burst Rate',
},{
title: 'Timelapse Interval',
},{
title: 'NightLapse exposure',
},{
title: 'NightLapse Interval',
},{
title: 'LEDs',
},{
title: 'Beeping',
},{
title: 'Auto off',
title: 'MISC',
}]
}]
});
menu.on('select', function(e) {
settings_menu.on('select', function(e) {
console.log('Selected item #' + e.itemIndex + ' of section #' + e.sectionIndex);
console.log('The item is titled "' + e.item.title + '"');
if(e.itemIndex === 0){
var menu = new UI.Menu({
var video_mode_menu = new UI.Menu({
backgroundColor: 'black',
textColor: 'white',
highlightBackgroundColor: 'blue',
highlightTextColor: 'red',
highlightTextColor: 'white',
sections: [{
title: 'First section',
title: 'Video modes',
items: [{
title: 'ON',
title: 'Video',
}, {
title: 'OFF'
}]
title: 'TL Video'
},{
title: 'Video+Photo'
}, {
title: 'Looping'
}]
}]
});
menu.show();
video_mode_menu.on('select', function(e) {
console.log('Selected item #' + e.itemIndex + ' of section #' + e.sectionIndex);
console.log('The item is titled "' + e.item.title + '"');
switch(e.itemIndex){
case 0:
var video_single_menu = new UI.Menu({
backgroundColor: 'black',
textColor: 'white',
highlightBackgroundColor: 'blue',
highlightTextColor: 'red',
sections: [{
title: 'Single Video settings',
items: [{
title: 'Resolution',
}, {
title: 'Framerate'
},{
title: 'FOV'
}, {
title: 'SpotMeter'
}, {
title: 'Low Light'
}, {
title: 'Protune'
}]
}]
});
//
video_mode_menu.on('select', function(e) {
console.log('Selected item #' + e.itemIndex + ' of section #' + e.sectionIndex);
console.log('The item is titled "' + e.item.title + '"');
switch(e.itemIndex){
case 0:
//Video resolution
var video_res_menu = new UI.Menu();
video_res_menu.items(0, [ { title: model }, { title: 'new item2' } ]);
video_res_menu.show();
break;
case 1:
//Video framerate
case 2:
//Video FOV
case 3:
//Video SM
case 4:
//Video Low light
case 5:
//Video protune
}
});
video_single_menu.show();
}
});
video_mode_menu.show();
}
});
menu.show();
settings_menu.show();
});
}

}
};
xhr.send(null);

}

//command function for HERO4 (/settings!)
function command_h4(param, value) {
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://10.5.5.9/gp/gpControl/setting/" + param + "/" + value, true);
xhr.send(null);
xhr.send(null);
}
//command function for HERO4 (modes, etc...)
function command_h4_modes(main_mode, sub_mode){
Expand All @@ -407,7 +484,6 @@ function command_h4_modes(main_mode, sub_mode){
xhr.send(null);

}

var main_nc = new UI.Card({
title: 'NOT CONNECTED',
body: 'Please connect the GoPro WiFi to phone!',
Expand All @@ -416,6 +492,7 @@ var main_nc = new UI.Card({
titleColor: 'white',
backgroundColor: 'black'
});
Light.trigger();
main_nc.show();
main_cam();

main_cam();

0 comments on commit 8e35b0c

Please sign in to comment.