From cfcc1a34063fc36c58e674cc239520ce63df60c0 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Wed, 2 Jan 2019 14:47:18 +1100 Subject: [PATCH] Working firmware details retrieve --- index.html | 47 ++++++++--------------------------------------- main.js | 9 ++++----- package-lock.json | 5 +++++ package.json | 1 + renderer.js | 33 ++++++++++++++++++++++++++++----- 5 files changed, 46 insertions(+), 49 deletions(-) diff --git a/index.html b/index.html index 915fd7f..49a91b7 100644 --- a/index.html +++ b/index.html @@ -41,10 +41,10 @@

Available Firmwares: - +

@@ -57,9 +57,8 @@
-

Firmware Details

-

Work In Progress

- +

Firmware Notes

+
@@ -83,42 +82,12 @@

Progress

-

Phasellus convallis elit id ullamcorper pulvinar. Duis aliquam turpis mauris, eu ultricies erat malesuada quis. Aliquam dapibus, lacus eget hendrerit bibendum, urna est aliquam sem, sit amet imperdiet est velit quis lorem.

- -

Lorem ipsum amet

-

Phasellus convallis elit id ullam corper amet et pulvinar. Duis aliquam turpis mauris, sed ultricies erat dapibus.

+ +

Current Action:

+

-
- -

Aliquam sed nullam

-

Phasellus convallis elit id ullam corper amet et pulvinar. Duis aliquam turpis mauris, sed ultricies erat dapibus.

-
-
- -

Sed erat ullam corper

-

Phasellus convallis elit id ullam corper amet et pulvinar. Duis aliquam turpis mauris, sed ultricies erat dapibus.

-
-
- -

Veroeros quis lorem

-

Phasellus convallis elit id ullam corper amet et pulvinar. Duis aliquam turpis mauris, sed ultricies erat dapibus.

-
-
- -

Urna quis bibendum

-

Phasellus convallis elit id ullam corper amet et pulvinar. Duis aliquam turpis mauris, sed ultricies erat dapibus.

-
-
- -

Aliquam urna dapibus

-

Phasellus convallis elit id ullam corper amet et pulvinar. Duis aliquam turpis mauris, sed ultricies erat dapibus.

-
-
-
diff --git a/main.js b/main.js index 4e21108..a5c32b7 100644 --- a/main.js +++ b/main.js @@ -57,18 +57,17 @@ ipcMain.on('download', (e, args) => { ipcMain.on('uploadFW', (e, args) => { var platform; - if(args.os == "win32") { platform = "avrdude-windows"; } - else if(args.os == "darwin") { platform = "avrdude-darwin-x86"; } - else if(args.os == "linux") { platform = "avrdude-linux_i686"; } + if(process.platform == "win32") { platform = "avrdude-windows"; } + else if(process.platform == "darwin") { platform = "avrdude-darwin-x86"; } + else if(process.platform == "linux") { platform = "avrdude-linux_i686"; } var executableName = "./bin/" + platform + "/avrdude"; var configName = executableName + ".conf"; - if(args.os == "win32") { executableName = executableName + '.exe'; } //This must come after the configName line above + if(process.platform == "win32") { executableName = executableName + '.exe'; } //This must come after the configName line above var hexFile = 'flash:w:' + args.firmwareFile + ':i'; var execArgs = ['-v', '-patmega2560', '-C', configName, '-cwiring', '-b 115200', '-P', args.port, '-D', '-U', hexFile]; - console.log(process.platform); /* exec("./bin/avrdude-darwin-x86/avrdude -v -p atmega2560 -C ./bin/avrdude-darwin-x86/avrdude.conf -c wiring -b 115200 -P /dev/cu.usbmodem14201 -D -U flash:w:/Users/josh/Downloads/201810.hex:i", (err, stdout, stderr) => { diff --git a/package-lock.json b/package-lock.json index 55e652e..220404c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1507,6 +1507,11 @@ "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", "dev": true }, + "marked": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.6.0.tgz", + "integrity": "sha512-HduzIW2xApSXKXJSpCipSxKyvMbwRRa/TwMbepmlZziKdH8548WSoDP4SxzulEKjlo8BE39l+2fwJZuRKOln6g==" + }, "meow": { "version": "3.7.0", "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz", diff --git a/package.json b/package.json index 5b4b1f9..a643ec8 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ }, "dependencies": { "electron-dl": "^1.12.0", + "marked": "^0.6.0", "request": "^2.88.0", "serialport": "^7.1.1" } diff --git a/renderer.js b/renderer.js index 5a16bc8..c58b300 100644 --- a/renderer.js +++ b/renderer.js @@ -36,13 +36,34 @@ function refreshSerialPorts() }) } -function refreshDetailsLink() +function refreshDetails() { var selectElement = document.getElementById('versionsSelect'); - var url = "https://github.com/noisymime/speeduino/releases/tag/" + selectElement.options[selectElement.selectedIndex].value + var url = "https://api.github.com/repos/noisymime/speeduino/releases/tags/" + selectElement.options[selectElement.selectedIndex].value; - var frameElement = document.getElementById('detailsFrame'); - frameElement.setAttribute("src", url); + + var request = require('request'); + const options = { + url: url, + headers: { + 'User-Agent': 'request' + } + }; + + request.get(options, function (error, response, body) { + if (!error ) { + + console.log(body); + var result = JSON.parse(body); + + // Continue with your processing here. + textField = document.getElementById('detailsText'); + + //Need to convert the Markdown that comes from Github to HTML + var myMarked = require('marked'); + textField.innerHTML = myMarked(result.body); + } + }); } function refreshAvailableFirmwares() @@ -88,7 +109,9 @@ function downloadFW() function uploadFW() { - //"avrdude -v -p atmega2560 -C ./bin/avrdude-darwin-x86/avrdude.conf -c wiring -b 115200 -P /dev/cu.usbmodem14201 -D -U flash:w:/Users/josh/Downloads/201810.hex:i" + var statusText = document.getElementById('statusText'); + statusText.innerHTML = "Beginning Download" + //Download the Hex file ipcRenderer.send("uploadFW", { port: "/dev/cu.usbmodem14201",