Skip to content

Commit

Permalink
callback tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Feb 19, 2021
1 parent 2f4c750 commit 8ca56d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions devices/SX127x.js
Expand Up @@ -304,6 +304,8 @@ function SX(options) {
setTimeout(this.init.bind(this), 7);
this.options = {};
this.state = "";
if (options.callback)
setTimeout(options.callback, 10);
}

SX.prototype.w = function(a,v) {
Expand Down
11 changes: 8 additions & 3 deletions devices/SX127x.md
Expand Up @@ -34,12 +34,17 @@ You set the `SX127x` module up like many others:

```
SPI1.setup({ sck:B3, miso:B4, mosi:B5 });
var sx = require("SX127x").connect({spi: SPI1, cs: B6, rst : B7 });
var sx = require("SX127x").connect({spi: SPI1, cs: B6, rst : B7, callback:function() {
// callback when SX127x is initialised
// Until DIO0 line irqs are implemented we need this:
setInterval(function() { sx.onIRQ(); }, 100);
// Until DIO0 line irqs are implemented we need this:
setInterval(function() { sx.onIRQ(); }, 100);
} });
```

**Note:** `require("SX127x").connect` doesn't complete immediately, so it is important that you
only use the returned module either >10ms after calling it, or ideally when the `callback` function is called.

You should then define some options. Sensible defaults are set, so realistically you need only:

```
Expand Down

0 comments on commit 8ca56d2

Please sign in to comment.