Update app assets and add button to reset to firmware

This commit is contained in:
William Toohey 2016-03-20 18:37:51 +10:00
parent 36a44beb7f
commit 9a6ae6d3c8
10 changed files with 34 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,8 +1,8 @@
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('window.html', {
'innerBounds': {
'width': 466,
'height': 580
'width': 480,
'height': 662
}
});
});

View File

@ -1,7 +1,7 @@
{
"name": "TaTaConfig",
"description": "TaTaCon to USB Configurator",
"version": "0.1",
"version": "0.2",
"manifest_version": 2,
"minimum_chrome_version": "38",
"app": {

View File

@ -53,7 +53,7 @@ body, html {
.tatacon {
position: relative;
width: 450px;
height: 450px;
height: 532px;
background-image: url("tatacon.png");
}
@ -63,7 +63,7 @@ body, html {
}
.donL, .donR {
top: 210px;
top: 130px;
}
.katL, .katR {
top: 50px;
@ -75,10 +75,10 @@ body, html {
right: 70px;
}
.katL {
left: 50px;
left: 40px;
}
.katR {
right: 50px;
right: 40px;
}
.title {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 97 KiB

View File

@ -1,6 +1,5 @@
(function() {
var devices = [];
var waitingMessage = "Waiting for a device, plug one in!";
var debounceOptions = [["Off", 0], ["Low", 15], ["Medium", 30], ["High", 50]];
var configBytes = {
donL : 0,
@ -13,6 +12,8 @@
reset : 7
};
var magicResetNumber = 42;
var newDevice = function(device) {
if(device.vendorId == 0x16D0) { // Config mode
console.log("Added new device with ID " + device.deviceId);
@ -33,7 +34,7 @@
}
var createConfigUI = function(device) {
document.getElementById("waiting").textContent = "";
document.getElementById("waiting").style.display = "none";
var ui = document.createElement("div");
device.ui = ui;
@ -145,9 +146,28 @@
updateUI(device);
}
var firmwareUpdate = document.createElement("button");
device.firmwareUpdate = firmwareUpdate;
firmwareUpdate.type = "button";
firmwareUpdate.textContent = "Firmware update";
// Becomes enabled once config is unchanged
firmwareUpdate.disabled = false;
firmwareUpdate.onclick = function() {
console.log("Rebooting for firmware update");
device.config[configBytes.reset] = magicResetNumber;
chrome.hid.send(device.connId, 0, device.config.buffer, function() {
console.log("Reboot sent, bye bye!");
// Ignore the failure to send
if(chrome.runtime.lastError) {
;
}
});
}
buttons.appendChild(apply);
buttons.appendChild(resetConfig);
buttons.appendChild(resetDefaults);
buttons.appendChild(firmwareUpdate);
config.appendChild(buttons);
ui.appendChild(config);
@ -183,9 +203,11 @@
if(changed) {
device.apply.disabled = false;
device.resetConfig.disabled = false;
device.firmwareUpdate.disabled = true;
} else {
device.apply.disabled = true;
device.resetConfig.disabled = true;
device.firmwareUpdate.disabled = false;
}
}
@ -200,7 +222,7 @@
}
}
if(devices.length == 0) {
document.getElementById("waiting").textContent = waitingMessage;
document.getElementById("waiting").style.display = "flex";
}
if(removed) {
document.getElementById("content").removeChild(removed.ui);
@ -208,7 +230,7 @@
}
window.addEventListener('load', function() {
document.getElementById("waiting").textContent = waitingMessage;
document.getElementById("waiting").style.display = "flex";
chrome.hid.getDevices({}, function(devices) {
if (chrome.runtime.lastError) {
console.error("Unable to enumerate devices: " +

View File

@ -5,7 +5,7 @@
<script type="text/javascript" src="tataconfig.js"></script>
</head>
<body>
<div id="waiting"></div>
<div id="waiting">Waiting for a device, plug one in!</div>
<div id="content"></div>
</body>
</html>