Skip to content

Commit

Permalink
Add updater
Browse files Browse the repository at this point in the history
  • Loading branch information
noisymime committed Jul 19, 2020
1 parent 2600eb4 commit 6ac49e7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions UI/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<div id="main">

<article id="connect" class="panel ">
<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>
<header><h1>Select Serial Port</h1></header>
Available Ports:<br />
<span id="serialDetectError"></span>
Expand Down
2 changes: 1 addition & 1 deletion UI/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Ardu-Stim",
"version": "0.0.1",
"version": "0.0.2",
"description": "Ardu-Stim engine simulator",
"main": "main.js",
"scripts": {
Expand Down
35 changes: 30 additions & 5 deletions UI/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,39 @@ function updateRPM()
console.log("Requesting new RPM");
port.write("R"); //Request next RPM read
document.gauges[0].value = currentRPM;
console.log(`New gauge RPM: ${document.gauges[0].value}`);
//console.log(`New gauge RPM: ${document.gauges[0].value}`);
}


function onRefresh(chart)
function checkForUpdates()
{
if(port.isOpen == false) { return; }
var url = "https://api.github.com/repos/speeduino/Ardu-Stim/releases/latest";

//document.getElementById('detailsHeading').innerHTML = version;

var request = require('request');
const options = {
url: url,
headers: {
'User-Agent': 'request'
}
};

port.write("G1"); //Sends the command to get live data
request.get(options, function (error, response, body) {
if (!error )
{
var result = JSON.parse(body);
latest_version = result.tag_name.substring(1);
console.log("Latest version: " + latest_version);

var semver = require('semver');
if(semver.gt(latest_version, remote.app.getVersion()))
{
//New version has been found
document.getElementById('update_url').setAttribute("href", result.html_url);
document.getElementById('update_text').style.display = "block";
}
}
});

}

Expand All @@ -510,6 +534,7 @@ window.onload = function ()
refreshSerialPorts();
redrawGears(toothPatterns[0]);
window.location.hash = '#connect';
checkForUpdates();
//animateGauges();
};

2 changes: 2 additions & 0 deletions ardustim/src/ardustim.ino
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ void setup() {
//Set RPM mode
mode = EEPROM.read(EEPROM_LAST_MODE);
if(mode > POT_RPM) { mode = POT_RPM; }
mode = LINEAR_SWEPT_RPM;


} // End setup
Expand Down Expand Up @@ -348,6 +349,7 @@ ISR(TIMER2_COMPA_vect) {
}
}
sweep_lock = false;
//wanted_rpm = get_rpm_from_tcnt(&SweepSteps[sweep_stage].beginning_ocr, &SweepSteps[sweep_stage].prescaler_bits);
// PORTD = (0 << 7);
}

Expand Down

0 comments on commit 6ac49e7

Please sign in to comment.