Skip to content

Commit e9482d1

Browse files
committed
Add OLED, LoRa libraries.
1 parent 3bfabf1 commit e9482d1

31 files changed

+5958
-0
lines changed

libraries/LoRa/.travis.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
language: generic
2+
env:
3+
global:
4+
- IDE_VERSION=1.6.12
5+
matrix:
6+
- BOARD="arduino:avr:uno"
7+
- BOARD="arduino:avr:micro"
8+
- BOARD="arduino:avr:mega:cpu=atmega2560"
9+
- BOARD="arduino:samd:arduino_zero_edbg"
10+
- BOARD="arduino:samd:mkr1000"
11+
before_install:
12+
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
13+
- sleep 3
14+
- export DISPLAY=:1.0
15+
- wget http://downloads.arduino.cc/arduino-$IDE_VERSION-linux64.tar.xz
16+
- tar xf arduino-$IDE_VERSION-linux64.tar.xz
17+
- mv arduino-$IDE_VERSION $HOME/arduino-ide
18+
- export PATH=$PATH:$HOME/arduino-ide
19+
- if [[ "$BOARD" =~ "arduino:samd:" ]]; then
20+
arduino --install-boards arduino:samd &> /dev/null;
21+
fi
22+
- buildExampleSketch() { arduino --verbose-build --verify --board $BOARD $PWD/examples/$1/$1.ino; }
23+
install:
24+
- mkdir -p $HOME/Arduino/libraries
25+
- ln -s $PWD $HOME/Arduino/libraries/LoRa
26+
script:
27+
- buildExampleSketch LoRaReceiver
28+
- buildExampleSketch LoRaReceiverCallback
29+
- buildExampleSketch LoRaSender

libraries/LoRa/API.md

Lines changed: 315 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,315 @@
1+
# LoRa API
2+
3+
## Include Library
4+
5+
```arduino
6+
#include <LoRa.h>
7+
```
8+
9+
## Setup
10+
11+
### Begin
12+
13+
Initialize the library with the specified frequency.
14+
15+
```arduino
16+
LoRa.begin(frequency);
17+
```
18+
* `frequency` - frequency in Hz (`433E6`, `866E6`, `915E6`)
19+
20+
Returns `1` on success, `0` on failure.
21+
22+
### Set pins
23+
24+
Override the default `NSS`, `NRESET`, and `DIO0` pins used by the library. **Must** be called before `LoRa.begin()`.
25+
26+
```arduino
27+
LoRa.setPins(ss, reset, dio0);
28+
```
29+
* `ss` - new slave select pin to use, defaults to `10`
30+
* `reset` - new reset pin to use, defaults to `9`
31+
* `dio0` - new DIO0 pin to use, defaults to `2`
32+
33+
This call is optional and only needs to be used if you need to change the default pins used.
34+
35+
### Set SPI Frequency
36+
37+
Override the default SPI frequency of 10 MHz used by the library. **Must** be called before `LoRa.begin()`.
38+
39+
```arduino
40+
LoRa.setSPIFrequency(frequency);
41+
```
42+
* `frequency` - new SPI frequency to use, defaults to `10E6`
43+
44+
This call is optional and only needs to be used if you need to change the default SPI frequency used. Some logic level converters cannot support high speeds such as 10 MHz, so a lower SPI frequency can be selected with `LoRa.setSPIFrequency(frequency)`.
45+
46+
### End
47+
48+
Stop the library
49+
50+
```arduino
51+
LoRa.end()
52+
```
53+
54+
## Sending data
55+
56+
### Begin packet
57+
58+
Start the sequence of sending a packet.
59+
60+
```arduino
61+
LoRa.beginPacket();
62+
63+
LoRa.beginPacket(implicitHeader);
64+
```
65+
66+
* `implicitHeader` - (optional) `true` enables implicit header mode, `false` enables explicit header mode (default)
67+
68+
Returns `1` on success, `0` on failure.
69+
70+
### Writing
71+
72+
Write data to the packet. Each packet can contain up to 255 bytes.
73+
74+
```arduino
75+
LoRa.write(byte);
76+
77+
LoRa.write(buffer, length);
78+
```
79+
* `byte` - single byte to write to packet
80+
81+
or
82+
83+
* `buffer` - data to write to packet
84+
* `length` - size of data to write
85+
86+
Returns the number of bytes written.
87+
88+
**Note:** Other Arduino `Print` API's can also be used to write data into the packet
89+
90+
### End packet
91+
92+
End the sequence of sending a packet.
93+
94+
```arduino
95+
LoRa.endPacket()
96+
```
97+
98+
Returns `1` on success, `0` on failure.
99+
100+
## Receiving data
101+
102+
### Parsing packet
103+
104+
Check if a packet has been received.
105+
106+
```arduino
107+
int packetSize = LoRa.parsePacket();
108+
109+
int packetSize = LoRa.parsePacket(size);
110+
```
111+
112+
* `size` - (optional) if `> 0` implicit header mode is enabled with the expected a packet of `size` bytes, default mode is explicit header mode
113+
114+
115+
Returns the packet size in bytes or `0` if no packet was received.
116+
117+
### Continuous receive mode
118+
119+
#### Register callback
120+
121+
Register a callback function for when a packet is received.
122+
123+
```arduino
124+
LoRa.onReceive(onReceive);
125+
126+
void onReceive(int packetSize) {
127+
// ...
128+
}
129+
```
130+
131+
* `onReceive` - function to call when a packet is received.
132+
133+
#### Receive mode
134+
135+
Puts the radio in continuous receive mode.
136+
137+
```arduino
138+
LoRa.receive();
139+
140+
LoRa.receive(int size);
141+
```
142+
143+
* `size` - (optional) if `> 0` implicit header mode is enabled with the expected a packet of `size` bytes, default mode is explicit header mode
144+
145+
The `onReceive` callback will be called when a packet is received.
146+
147+
### Packet RSSI
148+
149+
```arduino
150+
int rssi = LoRa.packetRssi();
151+
```
152+
153+
Returns the RSSI of the received packet.
154+
155+
### Packet SNR
156+
157+
```arduino
158+
float snr = LoRa.packetSnr();
159+
```
160+
161+
Returns the estimated SNR of the received packet in dB.
162+
163+
### Available
164+
165+
```arduino
166+
int availableBytes = LoRa.available()
167+
```
168+
169+
Returns number of bytes available for reading.
170+
171+
### Peeking
172+
173+
Peek at the next byte in the packet.
174+
175+
```arduino
176+
byte b = LoRa.peek();
177+
```
178+
179+
Returns the next byte in the packet or `-1` if no bytes are available.
180+
181+
### Reading
182+
183+
Read the next byte from the packet.
184+
185+
```arduino
186+
byte b = LoRa.read();
187+
```
188+
189+
Returns the next byte in the packet or `-1` if no bytes are available.
190+
191+
**Note:** Other Arduino [`Stream` API's](https://www.arduino.cc/en/Reference/Stream) can also be used to read data from the packet
192+
193+
## Other radio modes
194+
195+
### Idle mode
196+
197+
Put the radio in idle (standby) mode.
198+
199+
```arduino
200+
LoRa.idle();
201+
```
202+
203+
### Sleep mode
204+
205+
Put the radio in sleep mode.
206+
207+
```arduino
208+
LoRa.sleep();
209+
```
210+
211+
## Radio parameters
212+
213+
### TX Power
214+
215+
Change the TX power of the radio.
216+
217+
```arduino
218+
LoRa.setTxPower(txPower);
219+
220+
LoRa.setTxPower(txPower, outputPin);
221+
```
222+
* `txPower` - TX power in dB, defaults to `17`
223+
* `outputPin` - (optional) PA output pin, supported values are `PA_OUTPUT_RFO_PIN` and `PA_OUTPUT_PA_BOOST_PIN`, defaults to `PA_OUTPUT_PA_BOOST_PIN`.
224+
225+
Supported values are between `2` and `17` for `PA_OUTPUT_PA_BOOST_PIN`, `0` and `14` for `PA_OUTPUT_RFO_PIN`.
226+
227+
Most modules have the PA output pin connected to PA BOOST,
228+
229+
### Frequency
230+
231+
Change the frequency of the radio.
232+
233+
```arduino
234+
LoRa.setFrequency(frequency);
235+
```
236+
* `frequency` - frequency in Hz (`433E6`, `866E6`, `915E6`)
237+
238+
### Spreading Factor
239+
240+
Change the spreading factor of the radio.
241+
242+
```arduino
243+
LoRa.setSpreadingFactor(spreadingFactor);
244+
```
245+
* `spreadingFactor` - spreading factor, defaults to `7`
246+
247+
Supported values are between `6` and `12`. If a spreading factor of `6` is set, implicit header mode must be used to transmit and receive packets.
248+
249+
### Signal Bandwidth
250+
251+
Change the signal bandwidth of the radio.
252+
253+
```arduino
254+
LoRa.setSignalBandwidth(signalBandwidth);
255+
```
256+
257+
* `signalBandwidth` - signal bandwidth in Hz, defaults to `125E3`.
258+
259+
Supported values are `7.8E3`, `10.4E3`, `15.6E3`, `20.8E3`, `31.25E3`, `41.7E3`, `62.5E3`, `125E3`, and `250E3`.
260+
261+
### Coding Rate
262+
263+
Change the coding rate of the radio.
264+
265+
```arduino
266+
LoRa.setCodingRate4(codingRateDenominator);
267+
```
268+
269+
* `codingRateDenominator` - denominator of the coding rate, defaults to `5`
270+
271+
Supported values are between `5` and `8`, these correspond to coding rates of `4/5` and `4/8`. The coding rate numerator is fixed at `4`.
272+
273+
### Preamble Length
274+
275+
Change the preamble length of the radio.
276+
277+
```arduino
278+
LoRa.setPreambleLength(preambleLength);
279+
```
280+
281+
* `preambleLength` - preamble length in symbols, defaults to `8`
282+
283+
Supported values are between `6` and `65535`.
284+
285+
### Sync Word
286+
287+
Change the sync word of the radio.
288+
289+
```arduino
290+
LoRa.setSyncWord(syncWord);
291+
```
292+
293+
* `syncWord` - byte value to use as the sync word, defaults to `0x34`
294+
295+
### CRC
296+
297+
Enable or disable CRC usage, by default a CRC is not used.
298+
299+
```arduino
300+
LoRa.crc();
301+
302+
LoRa.noCrc();
303+
```
304+
305+
## Other functions
306+
307+
### Random
308+
309+
Generate a random byte, based on the Wideband RSSI measurement.
310+
311+
```
312+
byte b = LoRa.random();
313+
```
314+
315+
Returns random byte.

libraries/LoRa/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2016 Sandeep Mistry
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)