├── .gitignore ├── avrgirl-128.png ├── avrgirl-16.png ├── window.html ├── package.json ├── lib └── flash.js ├── manifest.json ├── background.js ├── README.md └── test.html /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.bundle.js 3 | -------------------------------------------------------------------------------- /avrgirl-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noopkat/avrgirl-chrome-app/HEAD/avrgirl-128.png -------------------------------------------------------------------------------- /avrgirl-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noopkat/avrgirl-chrome-app/HEAD/avrgirl-16.png -------------------------------------------------------------------------------- /window.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 9 | 10 | 11 |This window doesn't have to be left open. I'm just popping up to assure you I have successfully started up :)
13 | 14 | 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "avrgirl-chrome-app", 3 | "version": "1.0.0", 4 | "description": "An example app, showing how to use avrgirl in a Chrome browser.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Suz Hinton", 10 | "license": "MIT", 11 | "dependencies": { 12 | "avrgirl-arduino": "^1.9.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/flash.js: -------------------------------------------------------------------------------- 1 | var Avrgirl = require('avrgirl-arduino'); 2 | 3 | module.exports.flash = function(board, file, callback) { 4 | var avrgirl = new Avrgirl({ 5 | board: board, 6 | debug: true 7 | }); 8 | 9 | // convert the file contents to a buffer, as avrgirl is expecting 10 | var hex = new Buffer(file); 11 | 12 | // call flash method 13 | avrgirl.flash(hex, function(error) { 14 | return callback(error); 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "avrgirl-arduino chrome app", 3 | "description": "An example app, showing how to use avrgirl in a Chrome browser.", 4 | "version": "0.1", 5 | "manifest_version": 2, 6 | "app": { 7 | "background": { 8 | "scripts": ["background.bundle.js"] 9 | } 10 | }, 11 | "externally_connectable": { 12 | "matches": ["http://127.0.0.1:*/*"] 13 | }, 14 | "permissions": ["serial"], 15 | "icons": { "16": "avrgirl-16.png", "128": "avrgirl-128.png" } 16 | } 17 | -------------------------------------------------------------------------------- /background.js: -------------------------------------------------------------------------------- 1 | var uploader = require('./lib/flash'); 2 | 3 | // no need to open this window at all if you don't want, I left this in for dev purposes. 4 | chrome.app.runtime.onLaunched.addListener(function() { 5 | chrome.app.window.create('window.html', { 6 | 'outerBounds': { 7 | 'width': 400, 8 | 'height': 200 9 | } 10 | }); 11 | }); 12 | 13 | // when the webpage sends a message and we receive it, pass on the info to the uploader and request a flash to the device. 14 | chrome.runtime.onConnectExternal.addListener(function(port) { 15 | port.onMessage.addListener(function(msg) { 16 | // call flash process 17 | uploader.flash(msg.board, msg.file, function(error) { 18 | // prepare the response object 19 | var message = error ? {error: error.message} : {success: true}; 20 | // send back the status of the flash to the webpage so it knows when it's done/errored. 21 | port.postMessage(message); 22 | }); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # avrgirl-arduino chrome app 2 | 3 | Use avrgirl-arduino in the browser! An example chrome app that you can fork and make your own. 4 | 5 | ## Instructions 6 | 7 | Install the following tools globally: 8 | 9 | 1. `npm install -g browserify` 10 | 2. `npm install -g http-server` 11 | 12 | To run the demo: 13 | 14 | 1. Fork and clone this repo 15 | 2. Run `npm install` within the newly cloned local repo 16 | 3. Run `browserify background.js -o background.bundle.js` 17 | 4. In your Chrome browser, visit `chrome://extensions` 18 | 5. Click `Load unpacked extension` 19 | 6. Navigate to this cloned repo, and click `Select` 20 | 7. Click `Launch` when you see the extension appear at the top of the extensions list 21 | 8. Copy the `id` value of the extension, and update `var extensionid = '...';` line in `test.html` 22 | 9. Run the command `http-server -a 127.0.0.1 -p 8080` back in your terminal and visit `127.0.0.1:8080/test.html` in your Chrome browser. Also open the dev tools for logs! 23 | 10. Plug in an Arduino Uno, and upload a compatible .hex file to it using the test.html form 24 | 11. :tada: 25 | 26 | To develop this further or make changes: 27 | 28 | 1. Edit `background.js` (not `background.bundle.js`) 29 | 2. Always run `browserify background.js -o background.bundle.js` each time you change `background.js` or `lib/flash.js`, and then manually reload the chrome app. 30 | 3. When you reload the chrome app, you'll also need to refresh `test.html` so the page can reconnect to the reloaded chrome app. 31 | 4. Using `watchify` instead of `browserify` is totes cool and will work as expected. 32 | 33 | Please open an issue if you can't figure something out :two_hearts: -------------------------------------------------------------------------------- /test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Choose a file to upload to an arduino
18 | 19 | 34 | 35 | 83 | 84 | 85 | --------------------------------------------------------------------------------