Skip to content

Commit

Permalink
include library.json for platfomio release, bump to 0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
DefProc committed Nov 10, 2020
1 parent 2ac17d3 commit 5be61e9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ Lewis can be used either as a set of blocking functions (pulsing out will stop a
Using Lewis
-----------

However you use Lewis, after installing the library (e.g. using the [library manager](https://www.arduino.cc/en/Guide/Libraries#toc2) to import it), you will have to included the library header file at the top of your sketch:
However you use Lewis, after installing the library (e.g. using the [library manager](https://www.arduino.cc/en/Guide/Libraries#toc2) to import it), you will have to include the library header file at the top of your sketch:

```
```cpp
#include "Lewis.h"
```

And instantiate the Lewis class of functions with a name that you use later. I use `Morse` but you can choose whatever name you like, as long as you are consistent through the sketch:

```
```cpp
Lewis Morse;
```

Using Lewis requires calling the begin function in `setup()`, to choose the input and output pins, the pulse rate, and if you will be using the interrupt function:

```
```cpp
Morse.begin(rx_pin, tx_pin, words_per_minute, use_interrupts);
// e.g.
Morse.begin(2, 9, 20, false);
Expand All @@ -42,19 +42,19 @@ Sending morse code

Lewis uses the same function types as the [Serial library](https://www.arduino.cc/en/Reference/Serial) so data can be sent using the `print` and `write` commands:

```
```cpp
// from the message_out example
Morse.print("ok"); // will send: ---/-.-
Morse.write('s'); // will send: ...
```

in the default initiation, the output code will be “blocking” — that is, it will stop at the print line while until it has finished sending the full code. This is fine for small implementations, but for more complex code, you'll want to keep running your main code, and have the morse code sent in the background.

If you call `begin` with `use_interrupts` set as `true`, then you will need to call `Morse.timerISR()` frequently enough that it can check if any dots or dashes need sending out, without the listener hearing any inaccuracy in the tone length. 100Hz seems to work nicely for me.
If you call `begin` with `use_interrupts` set as `true`, then you will need to call `Morse.timerISR()` frequently enough that it can check if any dots or dashes need sending out, without the listener hearing any inaccuracy in the tone length. 100Hz seems to work nicely.

Lewis does not attach a timer interrupt when initialised (so as not to clash with anything you're already doing), so you will need to include one in your sketch. The examples use the [TimerOne](https://github.com/PaulStoffregen/TimerOne) library for the interrupt.

```
```cpp
// from the non_blocking_out example:

// additionally include the TimerOne library
Expand All @@ -80,11 +80,11 @@ void myISR()
Receiving morse
---------------

Lewis needs to watch the receiving pin of your choice for it's LOWHIGH changes often enough that it can see every change and accurately time the duration between each one to decode the dots, dashes, inter-letter spaces and inter-word spaces. To do so, your script will have do call the `checkIncoming` function rapidly enough (ideally 100 times or more per second) to pass decode the morse stream and pass them into the receiving buffer.
Lewis needs to watch the receiving pin of your choice for it's `LOWHIGH` changes often enough that it can see every change and accurately time the duration between each one to decode the dots, dashes, inter-letter spaces and inter-word spaces. To do so, your script will have do call the `checkIncoming` function rapidly enough (ideally 100 times or more per second) to pass decode the morse stream and pass them into the receiving buffer.

If you're using the interrupt initialisation of Lewis, then `checkIncoming` is already included in the `timerISR` function, so Lewis will already be watching your receive pin for button presses. If you're using the standard, non-interrupting initialisation then just putting `Morse.checkIncoming()` in a fast loop will be enough.

```
```cpp
//from the read_respond example
void loop() {
// call checkIncoming often enough to catch the incoming presses
Expand All @@ -104,7 +104,7 @@ With such a small loop, the checking function is not likely to miss any button p

To process data that's in the receive buffer, you can check if there is data, and process that as you normally would with Serial input:

```
```cpp
// first check if there's anything to process:
if (Morse.available();) { // available returns the number of characters available
// read grabs the next character from the buffer:
Expand Down
23 changes: 23 additions & 0 deletions library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "Lewis",
"version": "0.1.4",
"description": "A Serial-style morse code interpreter: making your Morse easier to use and process.",
"keywords": "Communication, Serial, Morse, Code, dit, dah",
"repository":
{
"type": "git",
"url": "https://github.com/DefProc/lewis.git"
},
"authors":
[
{
"name": "Patrick Fenner",
"email": "[email protected]",
"url": "https://defproc.co.uk/",
"maintainer": true
}
],
"license": "MIT",
"frameworks": "*",
"platforms": "*"
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Lewis
version=0.1.3
version=0.1.4
author=Patrick Fenner <[email protected]>
maintainer=Patrick Fenner <[email protected]>
sentence=A morse code stream/print interpreter
Expand Down

0 comments on commit 5be61e9

Please sign in to comment.