Skip to content

Instantly share code, notes, and snippets.

@junwatu
Forked from janjongboom/gist:94d575526a689687a6b8
Last active September 19, 2015 04:14

Revisions

  1. @janjongboom janjongboom revised this gist Feb 24, 2015. No changes.
  2. @janjongboom janjongboom revised this gist Feb 24, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    **This does NOT work on Raspberry Pi 2!**

    0. Obtain a 8GB (or bigger) SD Card
    1. Download disk image from http://janos.com/builds/fxos-pi-gpio.img.zip and unzip
    1. Download disk image from http://janos.io/builds/fxos-pi-gpio.img.zip and unzip
    2. Put SD card in your computer
    3. Find out where your SD card is mounted (**BE REALLY SURE ITS THE RIGHT DEVICE, IT WILL BE WIPED COMPLETELY!!!**), f.e. /dev/disk5 on OSX
    4. On Linux, run: `sudo dd bs=4M if=fxos-pi-gpio.img of=/path/to/your/disk`
  3. @janjongboom janjongboom revised this gist Feb 24, 2015. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -32,4 +32,8 @@ navigator.gpio.setPinMode(3, 'output')
    });
    ```

    Only does digital pins at the moment.
    Only does digital pins at the moment.

    ## Attribution

    Porting Firefox OS to Rpi is all done by Chris Jones. I just wrote the Gecko APIs that make GPIO possible.
  4. @janjongboom janjongboom revised this gist Feb 24, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    **This does NOT work on Raspberry Pi 2!**

    0. Obtain a 8GB (or bigger) SD Card
    1. Download disk image from http://janos.com/downloads/fxos-pi-gpio.img
    1. Download disk image from http://janos.com/builds/fxos-pi-gpio.img.zip and unzip
    2. Put SD card in your computer
    3. Find out where your SD card is mounted (**BE REALLY SURE ITS THE RIGHT DEVICE, IT WILL BE WIPED COMPLETELY!!!**), f.e. /dev/disk5 on OSX
    4. On Linux, run: `sudo dd bs=4M if=fxos-pi-gpio.img of=/path/to/your/disk`
  5. @janjongboom janjongboom revised this gist Feb 24, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    **This does NOT work on Raspberry Pi 2!**

    0. Obtain a 8GB SD Card
    0. Obtain a 8GB (or bigger) SD Card
    1. Download disk image from http://janos.com/downloads/fxos-pi-gpio.img
    2. Put SD card in your computer
    3. Find out where your SD card is mounted (**BE REALLY SURE ITS THE RIGHT DEVICE, IT WILL BE WIPED COMPLETELY!!!**), f.e. /dev/disk5 on OSX
  6. @janjongboom janjongboom revised this gist Feb 24, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    **This does NOT work on Raspberry Pi 2!**

    0. Obtain a 8GB SD Card
    1. Download disk image from http://janos.com/downloads/fxos-pi-gpio.img
    2. Put SD card in your computer
    3. Find out where your SD card is mounted (**BE REALLY SURE ITS THE RIGHT DEVICE, IT WILL BE WIPED COMPLETELY!!!**), f.e. /dev/disk5 on OSX
  7. @janjongboom janjongboom created this gist Feb 24, 2015.
    34 changes: 34 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    **This does NOT work on Raspberry Pi 2!**

    1. Download disk image from http://janos.com/downloads/fxos-pi-gpio.img
    2. Put SD card in your computer
    3. Find out where your SD card is mounted (**BE REALLY SURE ITS THE RIGHT DEVICE, IT WILL BE WIPED COMPLETELY!!!**), f.e. /dev/disk5 on OSX
    4. On Linux, run: `sudo dd bs=4M if=fxos-pi-gpio.img of=/path/to/your/disk`
    5. On OSX, run: `sudo dd bs=4m if=fxos-pi-gpio.img of=/dev/rdisk5` (do rdisk, not disk here!)
    6. When it's done put it in your Pi and start up
    7. The demo's are wired like this: yellow LED on GPIO2, red LED on GPIO3, button (wire it as pulldown) on GPIO26.

    ## Write your own apps

    1. Grab this repo: https://github.com/jan-os/janos/tree/gpio
    2. Check out `apps/system/js/my-app.js` for examples
    3. Go on the same network as the device and run `nmap --open -p 5555 192.168.2.*` (if 192.168.2 is your IP range of course) and use the IP in next step
    4. Connect to the device via `adb`: `adb connect 192.168.2.100`
    5. Verify that it works by running `adb logcat`, should see a lot of stuff going on
    6. Run `make install-phone` to update
    7. To debug, use [WebIDE](http://janos.io/articles/first-app.html#debugger)

    ## Example of the API

    Highly experimental, but to open pin 3 for output, set it to HIGH and then release it again:

    ```js
    navigator.gpio.setPinMode(3, 'output')
    .then(pin => {
    pin.writeDigital(true)
    .then(() => console.log('OK!'))
    .catch(ex => console.error('NOK!', ex));
    });
    ```

    Only does digital pins at the moment.