Add ability to download base tunes
This commit is contained in:
parent
6a56aacca2
commit
27880653a9
|
@ -2370,6 +2370,11 @@ input, select, textarea {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
select4 option {
|
||||||
|
color: #ffffff;
|
||||||
|
background: #022b3a;
|
||||||
|
}
|
||||||
|
|
||||||
input[type="text"],
|
input[type="text"],
|
||||||
input[type="password"],
|
input[type="password"],
|
||||||
input[type="email"],
|
input[type="email"],
|
||||||
|
@ -3252,6 +3257,14 @@ input, select, textarea {
|
||||||
background-color: #953d75;
|
background-color: #953d75;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wrapper.style4 {
|
||||||
|
background-color: #022b3a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wrapper.style4-alt {
|
||||||
|
background-color: #022b3a;
|
||||||
|
}
|
||||||
|
|
||||||
.wrapper.fullscreen {
|
.wrapper.fullscreen {
|
||||||
display: -moz-flex;
|
display: -moz-flex;
|
||||||
display: -webkit-flex;
|
display: -webkit-flex;
|
||||||
|
|
49
index.html
49
index.html
|
@ -26,6 +26,7 @@
|
||||||
<li><a href="#details">Firmware Details</a></li>
|
<li><a href="#details">Firmware Details</a></li>
|
||||||
<li><a href="#port">Choose Port</a></li>
|
<li><a href="#port">Choose Port</a></li>
|
||||||
<li><a href="#progress">Progress</a></li>
|
<li><a href="#progress">Progress</a></li>
|
||||||
|
<li><a href="#basetunes">Base Tunes</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
@ -39,12 +40,17 @@
|
||||||
<div style="display: none; text-align: center;" id="update_text"><a href="" id="update_url" target="_blank">A new version is available. Click here to download</a></div>
|
<div style="display: none; text-align: center;" id="update_text"><a href="" id="update_url" target="_blank">A new version is available. Click here to download</a></div>
|
||||||
<div class="inner">
|
<div class="inner">
|
||||||
<center><img src="assets/speeduino logo_white.png" width="235"/></center>
|
<center><img src="assets/speeduino logo_white.png" width="235"/></center>
|
||||||
|
|
||||||
<!--<h1>Firmware Loader</h1>-->
|
<!--<h1>Firmware Loader</h1>-->
|
||||||
<p>Available Firmwares:
|
<p>Available Firmwares:
|
||||||
<select name="firmwares" class="select" id="versionsSelect" size="10" width="20" ></select>
|
<select name="firmwares" class="select" id="versionsSelect" size="10" width="20" onClick="refreshBasetunes();"></select>
|
||||||
|
<ul class="actions">
|
||||||
|
<li><input type='button' id="btnChoosePort" value="Choose Port" onclick="window.location.href='#port';" /></li>
|
||||||
|
</ul>
|
||||||
|
<p>Other actions:</p>
|
||||||
<ul class="actions">
|
<ul class="actions">
|
||||||
<li><input type='button' id="btnDetails" value="View Firmware Notes" onclick="refreshDetails();" /></li>
|
<li><input type='button' id="btnDetails" value="View Firmware Notes" onclick="refreshDetails();" /></li>
|
||||||
<li><input type='button' id="btnChoosePort" value="Choose Port" onclick="window.location.href='#port';" /></li>
|
<li><input type='button' value="Get Base Tune" id="btnBasetune" onclick="window.location.href='#basetunes';" /></li>
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
<div id="error"></div>
|
<div id="error"></div>
|
||||||
|
@ -62,7 +68,7 @@
|
||||||
<div id="detailsText" style="padding-left: 0.9em; padding-right: 0.9em; overflow-y: auto; height: 50vh;"></div>
|
<div id="detailsText" style="padding-left: 0.9em; padding-right: 0.9em; overflow-y: auto; height: 50vh;"></div>
|
||||||
</div>
|
</div>
|
||||||
<ul class="actions">
|
<ul class="actions">
|
||||||
<li><input type='button' value="Download Base Tune" id="btnBasetune" onclick="downloadTune();" /></li>
|
<li><input type='button' value="Get Base Tune" id="btnBasetune" onclick="window.location.href='#basetunes';" /></li>
|
||||||
<li><input type='button' id="btnDetails" value="Change Version" onclick="window.location.href='#loader';" /></li>
|
<li><input type='button' id="btnDetails" value="Change Version" onclick="window.location.href='#loader';" /></li>
|
||||||
<li><input type='button' id="btnChoosePort" value="Install" onclick="window.location.href='#port';" /></li>
|
<li><input type='button' id="btnChoosePort" value="Install" onclick="window.location.href='#port';" /></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -106,13 +112,48 @@
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
<ul class="actions">
|
<ul class="actions">
|
||||||
|
<li><input type='button' id="btnChoosePort" value="Choose Port" onclick="window.location.href='#port';" /></li>
|
||||||
<li><input type='button' value="Burn again" id="btnReinstall" onclick="uploadFW();" /></li>
|
<li><input type='button' value="Burn again" id="btnReinstall" onclick="uploadFW();" /></li>
|
||||||
<li><input type='button' value="Download Base Tune" id="btnBasetune" onclick="downloadTune();" /></li>
|
<li><input type='button' value="Get Base Tune" id="btnBasetune" onclick="window.location.href='#basetunes';" /></li>
|
||||||
|
</ul>
|
||||||
|
<ul class="actions">
|
||||||
<li><input type='button' value="Exit" id="btnExit" onclick="quit();" /></li>
|
<li><input type='button' value="Exit" id="btnExit" onclick="quit();" /></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- Firmware details -->
|
||||||
|
<section id="details" class="wrapper style1-alt spotlights" style="display: none; height: 100vh;">
|
||||||
|
<div class="inner">
|
||||||
|
<h1>Firmware Notes</h1>
|
||||||
|
|
||||||
|
<div class="features major" >
|
||||||
|
<h2><div id="detailsHeading" style="padding-left: 0.55em;" ></div></h2>
|
||||||
|
<div id="detailsText" style="padding-left: 0.9em; padding-right: 0.9em; overflow-y: auto; height: 50vh;"></div>
|
||||||
|
</div>
|
||||||
|
<ul class="actions">
|
||||||
|
<li><input type='button' id="btnDetails" value="Change Version" onclick="window.location.href='#loader';" /></li>
|
||||||
|
<li><input type='button' id="btnChoosePort" value="Install" onclick="window.location.href='#port';" /></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- Base Tune download -->
|
||||||
|
<section id="basetunes" class="wrapper style4 fullscreen fade-up" style="height: 100vh;">
|
||||||
|
<div class="inner">
|
||||||
|
<h1>Base Tunes</h1>
|
||||||
|
<p>
|
||||||
|
Selected firmware: <span id="basetunesSelectedFW"></span><br />
|
||||||
|
Available Base Tunes:
|
||||||
|
<select name="basetunes" class="select4" id="basetunesSelect" size="10" width="20" ></select>
|
||||||
|
<ul class="actions">
|
||||||
|
<li><input type='button' value="Change firmware version" onclick="window.location.href='#loader';" /></li>
|
||||||
|
<li><input type='button' id="btnDownloadBasetune" value="Download tune" onclick="downloadBasetune();" /></li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Footer -->
|
<!-- Footer -->
|
||||||
|
|
2
main.js
2
main.js
|
@ -71,7 +71,7 @@ ipcMain.on('download', (e, args) => {
|
||||||
|
|
||||||
//console.log("Filename: " + fullFile );
|
//console.log("Filename: " + fullFile );
|
||||||
options = {};
|
options = {};
|
||||||
if(filename == "Speeduino%20base%20tune.msq")
|
if(filename.split('.').pop() == "msq")
|
||||||
{
|
{
|
||||||
options = { saveAs: true };
|
options = { saveAs: true };
|
||||||
}
|
}
|
||||||
|
|
104
renderer.js
104
renderer.js
|
@ -3,6 +3,8 @@ const {ipcRenderer} = require("electron")
|
||||||
const {remote} = require('electron')
|
const {remote} = require('electron')
|
||||||
const { shell } = require('electron')
|
const { shell } = require('electron')
|
||||||
|
|
||||||
|
var basetuneList = [];
|
||||||
|
|
||||||
function refreshSerialPorts()
|
function refreshSerialPorts()
|
||||||
{
|
{
|
||||||
serialport.list((err, ports) => {
|
serialport.list((err, ports) => {
|
||||||
|
@ -87,8 +89,10 @@ function refreshAvailableFirmwares()
|
||||||
//Disable the buttons. These are only re-enabled if the retrieve is successful
|
//Disable the buttons. These are only re-enabled if the retrieve is successful
|
||||||
var DetailsButton = document.getElementById("btnDetails");
|
var DetailsButton = document.getElementById("btnDetails");
|
||||||
var ChoosePortButton = document.getElementById("btnChoosePort");
|
var ChoosePortButton = document.getElementById("btnChoosePort");
|
||||||
|
var basetuneButton = document.getElementById("btnBasetune");
|
||||||
DetailsButton.disabled = true;
|
DetailsButton.disabled = true;
|
||||||
ChoosePortButton.disabled = true;
|
ChoosePortButton.disabled = true;
|
||||||
|
basetuneButton.disabled = true;
|
||||||
|
|
||||||
var request = require('request');
|
var request = require('request');
|
||||||
request.get('http://speeduino.com/fw/versions', {timeout: 10000}, function (error, response, body)
|
request.get('http://speeduino.com/fw/versions', {timeout: 10000}, function (error, response, body)
|
||||||
|
@ -107,10 +111,12 @@ function refreshAvailableFirmwares()
|
||||||
select.appendChild(newOption);
|
select.appendChild(newOption);
|
||||||
}
|
}
|
||||||
select.selectedIndex = 0;
|
select.selectedIndex = 0;
|
||||||
|
refreshBasetunes();
|
||||||
|
|
||||||
//Re-enable the buttons
|
//Re-enable the buttons
|
||||||
DetailsButton.disabled = false;
|
DetailsButton.disabled = false;
|
||||||
ChoosePortButton.disabled = false;
|
ChoosePortButton.disabled = false;
|
||||||
|
basetuneButton.disabled = false;
|
||||||
}
|
}
|
||||||
else if(error)
|
else if(error)
|
||||||
{
|
{
|
||||||
|
@ -136,6 +142,71 @@ function refreshAvailableFirmwares()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function refreshBasetunes()
|
||||||
|
{
|
||||||
|
//Check whether the base tunes list has been populated yet
|
||||||
|
if(basetuneList === undefined || basetuneList.length == 0)
|
||||||
|
{
|
||||||
|
console.log("No tunes loaded. Retrieving from server");
|
||||||
|
//Load the json
|
||||||
|
var url = "https://speeduino.com/fw/basetunes.json";
|
||||||
|
|
||||||
|
var request = require('request');
|
||||||
|
const options = {
|
||||||
|
url: url,
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'request'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
request.get(options, function (error, response, body) {
|
||||||
|
if (!error )
|
||||||
|
{
|
||||||
|
basetuneList = JSON.parse(body);
|
||||||
|
refreshBasetunes();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//JSON list of base tunes has been downloaded
|
||||||
|
|
||||||
|
//Get the display list object
|
||||||
|
var select = document.getElementById('basetunesSelect');
|
||||||
|
|
||||||
|
//Get the currently selected version
|
||||||
|
selectElement = document.getElementById('versionsSelect');
|
||||||
|
if(selectElement.selectedIndex == -1) { return; } //Check for no value being selected
|
||||||
|
var selectedFW = selectElement.options[selectElement.selectedIndex].value;
|
||||||
|
|
||||||
|
//Clear the current options from the list
|
||||||
|
while(select.options.length)
|
||||||
|
{
|
||||||
|
select.remove(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var tune in basetuneList)
|
||||||
|
{
|
||||||
|
//Check whether the current tune was available for the selected firmware
|
||||||
|
if(parseInt(basetuneList[tune].introduced) <= parseInt(selectedFW))
|
||||||
|
{
|
||||||
|
var url = basetuneList[tune].baseURL.replace("$VERSION", selectedFW) + basetuneList[tune].filename;
|
||||||
|
//console.log("Tune url: " + url);
|
||||||
|
//console.log("Found a valid tune: " + basetuneList[tune].displayName);
|
||||||
|
var newOption = document.createElement('option');
|
||||||
|
newOption.style.background = "#022b3a";
|
||||||
|
newOption.value = url;
|
||||||
|
newOption.innerHTML = basetuneList[tune].displayName;
|
||||||
|
select.appendChild(newOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Finally update the selected firmware label on the basetunes page
|
||||||
|
document.getElementById('basetunesSelectedFW').innerHTML = selectedFW;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function downloadHex()
|
function downloadHex()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -155,7 +226,7 @@ function downloadIni()
|
||||||
{
|
{
|
||||||
|
|
||||||
var e = document.getElementById('versionsSelect');
|
var e = document.getElementById('versionsSelect');
|
||||||
var DLurl = "http://speeduino.com/fw/" + e.options[e.selectedIndex].value + ".ini";
|
var DLurl = "https://speeduino.com/fw/" + e.options[e.selectedIndex].value + ".ini";
|
||||||
console.log("Downloading: " + DLurl);
|
console.log("Downloading: " + DLurl);
|
||||||
|
|
||||||
//Download the ini file
|
//Download the ini file
|
||||||
|
@ -166,6 +237,21 @@ function downloadIni()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function downloadBasetune()
|
||||||
|
{
|
||||||
|
var basetuneSelect = document.getElementById('basetunesSelect');
|
||||||
|
var version = document.getElementById('versionsSelect');
|
||||||
|
//var DLurl = "https://github.com/noisymime/speeduino/raw/" + version + "/reference/Base%20Tunes/" + e.options[e.selectedIndex].value;
|
||||||
|
var DLurl = basetuneSelect.options[basetuneSelect.selectedIndex].value;
|
||||||
|
console.log("Downloading: " + DLurl);
|
||||||
|
|
||||||
|
//Download the ini file
|
||||||
|
ipcRenderer.send("download", {
|
||||||
|
url: DLurl,
|
||||||
|
properties: {directory: "downloads"}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//Installing the Windows drivers
|
//Installing the Windows drivers
|
||||||
function installDrivers()
|
function installDrivers()
|
||||||
{
|
{
|
||||||
|
@ -174,21 +260,6 @@ function installDrivers()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadTune()
|
|
||||||
{
|
|
||||||
|
|
||||||
var e = document.getElementById('versionsSelect');
|
|
||||||
var DLurl = "https://raw.githubusercontent.com/noisymime/speeduino/" + e.options[e.selectedIndex].value + "/reference/Base%20Tunes/Speeduino%20base%20tune.msq";
|
|
||||||
console.log("Downloading: " + DLurl);
|
|
||||||
|
|
||||||
//Download the ini file
|
|
||||||
ipcRenderer.send("download", {
|
|
||||||
url: DLurl,
|
|
||||||
properties: {directory: "downloads"}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function uploadFW()
|
function uploadFW()
|
||||||
{
|
{
|
||||||
//Jump to the progress section
|
//Jump to the progress section
|
||||||
|
@ -330,6 +401,7 @@ window.onload = function () {
|
||||||
document.getElementById('title').innerHTML = "Speeduino Universal Firmware Loader (v" + remote.app.getVersion() + ")"
|
document.getElementById('title').innerHTML = "Speeduino Universal Firmware Loader (v" + remote.app.getVersion() + ")"
|
||||||
|
|
||||||
refreshAvailableFirmwares();
|
refreshAvailableFirmwares();
|
||||||
|
refreshBasetunes();
|
||||||
refreshSerialPorts();
|
refreshSerialPorts();
|
||||||
checkForUpdates();
|
checkForUpdates();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue