Skip to content

Pc update readme and licenses on examples #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
44f33cb
quick attempt to test on Tessel, still hits https://github.com/tessel…
natevw Dec 22, 2013
d05aa3e
Removed deprecated GPIO/SPI commands to get it running again
johnnyman727 May 3, 2014
b593c1f
moved to gpio interripts
johnnyman727 May 3, 2014
c22c2a3
adding example code to work with RF24 lib
May 8, 2014
943d955
removed most workarounds
May 21, 2014
c08477b
removed all workarounds
May 22, 2014
4699eb1
new proposed API
May 22, 2014
0997270
making callback optional
May 22, 2014
c559b27
fixing RPi example to work with new API
May 22, 2014
fa7c2f3
fixing example in readme
May 22, 2014
f2405ee
Merge pull request #1 from tessel/jh-tessel
jiahuang May 22, 2014
ea8271b
tessel to tessel example
May 23, 2014
edf8494
ping pong whatever
May 23, 2014
a97b369
Adds elementary test case.
tcr May 23, 2014
62d2a1d
Replaces tests with tinytap.
tcr May 24, 2014
7a7e2a8
Merge pull request #3 from tessel/jh-tessel
jiahuang May 28, 2014
10c9bff
new pin api
May 27, 2014
8586d8d
Release 0.8.2
tcr May 28, 2014
c118c76
Merge pull request #2 from tessel/jh-pin-api
tcr May 28, 2014
195100c
udpates to new pin api
johnnyman727 May 28, 2014
04caf46
npm version bump
johnnyman727 May 28, 2014
8fb13cb
Merge pull request #5 from tessel/jon-new-pin
johnnyman727 May 28, 2014
7514684
Updates readme to current style specs, adds licencing and pretty code…
pmcote Jun 5, 2014
121d64d
updates links that were not as expected
pmcote Jun 5, 2014
35716cd
the readme is slightly more in order
pmcote Jun 5, 2014
79210b7
tryout newline marktype in readme
pmcote Jun 6, 2014
ee28d9d
fix the weird commit
pmcote Jun 6, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 113 additions & 46 deletions README.md

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions examples/RF24-pingpair.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/

/*********************************************
These are settings for Tessel to work out of
the box with maniacbug's RF24 pingpair example
(https://github.com/maniacbug/RF24/blob/
07a4bcf425d91c99105dbdbad0226296c7cd3a93/
examples/pingpair/pingpair.pde) Useful for
bridging an Arduino + nRF24 to Tessel + nRF24.
*********************************************/

var tessel = require('tessel'),
NRF24 = require("../"),
pipes = [0xF0F0F0F0E1, 0xF0F0F0F0D2],
role = 'pong'; // swap this to pong if you want to wait for receive

var nrf = NRF24.channel(0x4c) // set the RF channel to 76. Frequency = 2400 + RF_CH [MHz] = 2476MHz
.transmitPower('PA_MAX') // set the transmit power to max
.dataRate('1Mbps')
.crcBytes(2) // 2 byte CRC
.autoRetransmit({count:15, delay:4000})
.use(tessel.port['A']);

nrf._debug = false;

nrf.on('ready', function () {
if (role === 'ping') {
console.log("PING out");
/*
* The Arduino pong code needs to have its timeout changed. On line #205
* https://github.com/maniacbug/RF24/blob/07a4bcf425d91c99105dbdbad0226296c7cd3a93/examples/pingpair/pingpair.pde#L205
* the delay(20) needs to be swapped out with delay(2000)
*/

var tx = nrf.openPipe('tx', pipes[1]), // transmit address F0F0F0F0D2
rx = nrf.openPipe('rx', pipes[1], {size: 8}); // receive address F0F0F0F0D2
tx.on('ready', function () { // NOTE: hoping to get rid of need to wait for "ready"
var n = 0;
setInterval(function () {
var b = new Buffer(8); // set buff len of 8 for compat with maniac bug's RF24 lib
b.fill(0);
b.writeUInt32BE(n++, 4); // offset by 4 because our buffer length is 8 bytes
console.log("Sending", n);
tx.write(b);
}, 5e3); // transmit every 5 seconds
});
rx.on('data', function (d) {
console.log("Got response back:", d.readUInt32BE(4)); //offset by 4 again
});
} else {
console.log("PONG back");
/*
* The Arduino ping code needs to have its timeout changed. On line #161
* https://github.com/maniacbug/RF24/blob/07a4bcf425d91c99105dbdbad0226296c7cd3a93/examples/pingpair/pingpair.pde#L161
* instead of "if (millis() - started_waiting_at > 200 )"
* change to "if (millis() - started_waiting_at > 2000 )"
*/

var rx = nrf.openPipe('rx', pipes[0], {size: 8});
tx = nrf.openPipe('tx', pipes[0], {autoAck: false});
rx.on('data', function (d) {
console.log("Got data, will respond", d);
tx.write(d);
});
tx.on('error', function (e) {
console.warn("Error sending reply.", e);
});
}
});

// hold this process open
process.ref();
62 changes: 62 additions & 0 deletions examples/nrf24.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/

/*********************************************
Tessel to tessel requires 2 nrf24 modules
(and ideally two tessels) put one tessel+nrf
on "ping" mode and another one on "pong" mode.
*********************************************/

var tessel = require('tessel'),
NRF24 = require("../"),
pipes = [0xF0F0F0F0E1, 0xF0F0F0F0D2],
role = 'pong'; // swap this to pong if you want to wait for receive

var nrf = NRF24.channel(0x4c) // set the RF channel to 76. Frequency = 2400 + RF_CH [MHz] = 2476MHz
.transmitPower('PA_MAX') // set the transmit power to max
.dataRate('1Mbps')
.crcBytes(2) // 2 byte CRC
.autoRetransmit({count:15, delay:4000})
.use(tessel.port['A']);

nrf._debug = false;

nrf.on('ready', function () {
setTimeout(function(){
nrf.printDetails();
}, 5000);

if (role === 'ping') {
console.log("PING out");

var tx = nrf.openPipe('tx', pipes[0], {autoAck: false}), // transmit address F0F0F0F0D2
rx = nrf.openPipe('rx', pipes[1], {size: 4}); // receive address F0F0F0F0D2
tx.on('ready', function () {
var n = 0;
setInterval(function () {
var b = new Buffer(4); // set buff len of 8 for compat with maniac bug's RF24 lib
b.fill(0);
b.writeUInt32BE(n++);
console.log("Sending", n);
tx.write(b);
}, 5e3); // transmit every 5 seconds
});
rx.on('data', function (d) {
console.log("Got response back:", d);
});
} else {
console.log("PONG back");
var rx = nrf.openPipe('rx', pipes[0], {size: 4});
tx = nrf.openPipe('tx', pipes[1], {autoAck: false});
rx.on('data', function (d) {
console.log("Got data, will respond", d);
tx.write(d);
});
tx.on('error', function (e) {
console.warn("Error sending reply.", e);
});
}
});

// hold this process open
process.ref();
Loading