mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.0 SWSerialOut
This commit is contained in:
parent
0b132b6976
commit
90da998661
28
libraries/SWSerialOut/.arduino-ci.yml
Normal file
28
libraries/SWSerialOut/.arduino-ci.yml
Normal file
@ -0,0 +1,28 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
- uno
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
- m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
||||
|
4
libraries/SWSerialOut/.github/FUNDING.yml
vendored
Normal file
4
libraries/SWSerialOut/.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: RobTillaart
|
||||
|
13
libraries/SWSerialOut/.github/workflows/arduino-lint.yml
vendored
Normal file
13
libraries/SWSerialOut/.github/workflows/arduino-lint.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
name: Arduino-lint
|
||||
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: arduino/arduino-lint-action@v1
|
||||
with:
|
||||
library-manager: update
|
||||
compliance: strict
|
17
libraries/SWSerialOut/.github/workflows/arduino_test_runner.yml
vendored
Normal file
17
libraries/SWSerialOut/.github/workflows/arduino_test_runner.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
name: Arduino CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
runTest:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
- run: |
|
||||
gem install arduino_ci
|
||||
arduino_ci.rb
|
18
libraries/SWSerialOut/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/SWSerialOut/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
17
libraries/SWSerialOut/CHANGELOG..md
Normal file
17
libraries/SWSerialOut/CHANGELOG..md
Normal file
@ -0,0 +1,17 @@
|
||||
# Change Log SWSerialOut
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.1.0] - 2023-09-02
|
||||
- revitalized as transmit (TX) only SWSerial.
|
||||
- initial release
|
||||
|
||||
----
|
||||
|
||||
## [0.0.0] - 2012-12-21
|
||||
- proof of concept, baud rate by formula
|
||||
- https://forum.arduino.cc/t/softwareserial-magic-numbers/135211
|
||||
|
21
libraries/SWSerialOut/LICENSE
Normal file
21
libraries/SWSerialOut/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023-2023 Rob Tillaart
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
160
libraries/SWSerialOut/README.md
Normal file
160
libraries/SWSerialOut/README.md
Normal file
@ -0,0 +1,160 @@
|
||||
|
||||
[![Arduino CI](https://github.com/RobTillaart/SWSerialOut/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
||||
[![Arduino-lint](https://github.com/RobTillaart/SWSerialOut/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/SWSerialOut/actions/workflows/arduino-lint.yml)
|
||||
[![JSON check](https://github.com/RobTillaart/SWSerialOut/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/SWSerialOut/actions/workflows/jsoncheck.yml)
|
||||
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/SWSerialOut.svg)](https://github.com/RobTillaart/SWSerialOut/issues)
|
||||
|
||||
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/SWSerialOut/blob/master/LICENSE)
|
||||
[![GitHub release](https://img.shields.io/github/release/RobTillaart/SWSerialOut.svg?maxAge=3600)](https://github.com/RobTillaart/SWSerialOut/releases)
|
||||
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/SWSerialOut.svg)](https://registry.platformio.org/libraries/robtillaart/SWSerialOut)
|
||||
|
||||
|
||||
# SWSerialOut
|
||||
|
||||
Arduino library for SWSerialOut, supports only data out (TX).
|
||||
|
||||
|
||||
## Description
|
||||
|
||||
**Experimental**
|
||||
|
||||
SWSerialOut is a library that only implements the transmit function.
|
||||
There are devices that do not send back information, or in some cases
|
||||
you do not use the "returned" information.
|
||||
In those cases there is no need for the receive function, interrupt
|
||||
handling, buffers etc.
|
||||
|
||||
This is where SWSerialOut comes in, it can only transmit data and does
|
||||
that by implementing the **public Stream** interface.
|
||||
So its interface is similar to any Stream like Serial or SoftwareSerial,
|
||||
as the user can use **print()** and **println()** for al the output.
|
||||
|
||||
The input side of the Stream interface, **available()**, **peek()**,
|
||||
and **read()** are stubs returning 0.
|
||||
|
||||
The library does not need to buffer incoming data, and it does not buffer outgoing data either. Therefore it can be blocking.
|
||||
So use the library with care.
|
||||
|
||||
|
||||
#### Test
|
||||
|
||||
Test are done with example sketch **SWSO_test.ino** et al which
|
||||
reads the send data back via hardware Serial.
|
||||
The serial pulses, especially baud rates above 19200, will improve
|
||||
with a proper pull up resistor e.g. 4K7.
|
||||
|
||||
| baud | UNO | ESP32 | other |
|
||||
|---------:|:-----:|:-------:|:-------:|
|
||||
| 300 | Y | Y |
|
||||
| 600 | Y | Y |
|
||||
| 1200 | Y | Y |
|
||||
| 2400 | Y | Y |
|
||||
| 4800 | Y | Y |
|
||||
| 7200 | Y | Y |
|
||||
| 9600 | Y | Y |
|
||||
| 19200 | Y | Y |
|
||||
| 38400 | - | Y |
|
||||
| 57600 | - | Y |
|
||||
| 76800 | - | Y |
|
||||
| 100000 | - | Y |
|
||||
|
||||
|
||||
Note: the code is not really optimized for any platform (yet).
|
||||
So the library will not match the top speed of other software serial implementations.
|
||||
|
||||
If you have tested this library with another platform, please let me know by
|
||||
opening an issue with the relevant data.
|
||||
|
||||
|
||||
#### Related
|
||||
|
||||
- https://github.com/RobTillaart/MiniMP3 - minimal version only needs serial out.
|
||||
|
||||
|
||||
## Interface
|
||||
|
||||
```cpp
|
||||
#include "SWSerialOut.h"
|
||||
```
|
||||
|
||||
#### Constructor
|
||||
|
||||
- **SWSerialOut(uint8_t TXpin)** constructor.
|
||||
- **void begin(uint32_t baudRate)** set baud rate (see table above)
|
||||
- **void begin(uint32_t baudRate, char \* params)** params implemented.
|
||||
however not tested yet.
|
||||
The params are range checked.
|
||||
|
||||
params is e.g. "8N1" = 8 bit, None parity, 1 stop-bit
|
||||
|
||||
| param | value | default | notes |
|
||||
|:---------:|:----------|:---------:|:--------|
|
||||
| bit | 5,6,7,8 | 8 | to be tested
|
||||
| parity | N,E,O,S,M | N | to be tested
|
||||
| stop bits | 0,1,2,3 | 1 | to be tested
|
||||
|
||||
|
||||
#### Stream interface
|
||||
|
||||
The SWSerialOut implements the **public Stream** interface, so
|
||||
it will support the following functions (indirect from Print):
|
||||
|
||||
- **size_t write(char c)** idem.
|
||||
- **size_t print(...)** idem.
|
||||
- **size_t println(...)** idem.
|
||||
|
||||
The input functions are stubs, just returning 0.
|
||||
|
||||
|
||||
#### Interrupts
|
||||
|
||||
To have a more constant timing while sending the bits one can disable
|
||||
interrupts during the transfer of the data.
|
||||
|
||||
- **void disableInterrupts(bool b)** enable/disable interrupts during send.
|
||||
|
||||
|
||||
#### Debug
|
||||
|
||||
- **void debug()** dump internal variables.
|
||||
|
||||
|
||||
## Future
|
||||
|
||||
|
||||
#### Must
|
||||
|
||||
- update documentation
|
||||
- test bits, parity, stop bits
|
||||
|
||||
|
||||
#### Should
|
||||
|
||||
- examples
|
||||
- performance sketch
|
||||
|
||||
|
||||
#### Could
|
||||
|
||||
- unit tests?
|
||||
- support inverse logic.
|
||||
- support 9 bits (low priority)
|
||||
- add RTS / CTS handshake?
|
||||
- investigate optimized transfer per platform
|
||||
- higher baud rates, especially AVR.
|
||||
|
||||
|
||||
#### Wont
|
||||
|
||||
- read()
|
||||
- non blocking version
|
||||
|
||||
|
||||
## Support
|
||||
|
||||
If you appreciate my libraries, you can support the development and maintenance.
|
||||
Improve the quality of the libraries by providing issues and Pull Requests, or
|
||||
donate through PayPal or GitHub sponsors.
|
||||
|
||||
Thank you,
|
||||
|
159
libraries/SWSerialOut/SWSerialOut.h
Normal file
159
libraries/SWSerialOut/SWSerialOut.h
Normal file
@ -0,0 +1,159 @@
|
||||
#pragma once
|
||||
//
|
||||
// FILE: SWSerialOut.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: Arduino library for SWSerialOut, supports only data out (TX).
|
||||
// DATE: 2023-09-02
|
||||
// URL: https://github.com/RobTillaart/SWSerialOut
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
|
||||
#define SWSERIALOUT_LIB_VERSION (F("0.1.0"))
|
||||
|
||||
|
||||
class SWSerialOut : public Stream
|
||||
{
|
||||
public:
|
||||
SWSerialOut(uint8_t TXpin, bool inverse = false)
|
||||
{
|
||||
_TX = TXpin;
|
||||
_inverse = inverse;
|
||||
}
|
||||
|
||||
|
||||
void begin(uint32_t baudRate)
|
||||
{
|
||||
_baud = baudRate;
|
||||
_pulse = round(1000000.0 / _baud);
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
_pulse -= 4;
|
||||
#elif defined(ESP32)
|
||||
_pulse -= 1;
|
||||
#endif
|
||||
pinMode(_TX, OUTPUT);
|
||||
digitalWrite(_TX, HIGH);
|
||||
}
|
||||
|
||||
|
||||
void begin(uint32_t baudRate, char * params) // TODO TEST
|
||||
{
|
||||
begin(baudRate);
|
||||
_bits = constrain(params[0] - '0', 5, 8);
|
||||
_parity = params[1];
|
||||
_stopBits = constrain(params[2] - '0', 0, 3);
|
||||
if (strchr("NEOSM", _parity) == NULL) // invalid?
|
||||
{
|
||||
_parity = 'N';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// PRINT interface
|
||||
size_t write(uint8_t b)
|
||||
{
|
||||
if (_disableInterrupts)
|
||||
{
|
||||
noInterrupts(); // no IRQ disturbances.
|
||||
}
|
||||
|
||||
// start bit
|
||||
uint32_t start = micros();
|
||||
digitalWrite(_TX, LOW);
|
||||
while(micros() - start < _pulse);
|
||||
|
||||
// byte
|
||||
uint8_t parity = 0;
|
||||
uint8_t cnt = _bits;
|
||||
uint8_t bit = 0;
|
||||
while (cnt-- > 0)
|
||||
{
|
||||
start = micros();
|
||||
bit = b & 0x01;
|
||||
if (bit) parity++; // count 1's
|
||||
digitalWrite(_TX, bit);
|
||||
b >>= 1;
|
||||
while(micros() - start < _pulse);
|
||||
}
|
||||
parity &= 0x01;
|
||||
|
||||
// parity bits
|
||||
if (_parity != 'N')
|
||||
{
|
||||
if (_parity == 'E') bit = parity; // even # 1 bits
|
||||
else if (_parity == 'O') bit = 1 - parity; // odd # 1 bits
|
||||
else if (_parity == 'S') bit = 0; // always 0
|
||||
else if (_parity == 'M') bit = 1; // always 1
|
||||
start = micros();
|
||||
digitalWrite(_TX, bit);
|
||||
while(micros() - start < _pulse);
|
||||
}
|
||||
|
||||
// stop bits
|
||||
digitalWrite(_TX, HIGH);
|
||||
delayMicroseconds(_pulse * _stopBits);
|
||||
|
||||
interrupts();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void disableInterrupts(bool b)
|
||||
{
|
||||
_disableInterrupts = b;
|
||||
}
|
||||
|
||||
|
||||
// STREAM interface (for compatibility)
|
||||
int available() { return 0; };
|
||||
int peek() { return 0; };
|
||||
int read() { return 0; };
|
||||
void flush() { return; }; // placeholder to keep build CI happy
|
||||
|
||||
|
||||
// DEBUG
|
||||
void debug()
|
||||
{
|
||||
Serial.print("DBG: PIN");
|
||||
Serial.print(_TX);
|
||||
Serial.print(":");
|
||||
Serial.print(_baud);
|
||||
Serial.print(':');
|
||||
Serial.print(_parity);
|
||||
Serial.print(',');
|
||||
Serial.print(_bits);
|
||||
Serial.print(',');
|
||||
Serial.print(_stopBits);
|
||||
Serial.print('\t');
|
||||
Serial.print(_pulse);
|
||||
Serial.print('\t');
|
||||
Serial.print(_inverse);
|
||||
Serial.print('\t');
|
||||
Serial.println(_disableInterrupts);
|
||||
delay(100);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
uint8_t _TX;
|
||||
|
||||
// configuration
|
||||
uint32_t _baud = 9600; // check range
|
||||
char _parity = 'N'; // None, Even, Odd
|
||||
uint8_t _bits = 8; // 5,6,7,8
|
||||
uint8_t _stopBits = 1; // 0,1,2
|
||||
bool _inverse = false; // TODO
|
||||
bool _disableInterrupts = false;
|
||||
|
||||
// timing
|
||||
uint32_t _pulse;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -0,0 +1,28 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
# - uno
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
# - m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
# - rpipico
|
||||
|
@ -0,0 +1,32 @@
|
||||
//
|
||||
// FILE: SWSO_ESP32_listener.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: SWSO demo for ESP32
|
||||
// URL: https://github.com/RobTillaart/SWSerialOut
|
||||
//
|
||||
// Serial2.RX listens to an SWSO
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.println();
|
||||
|
||||
Serial2.begin(38400);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// echo incoming data
|
||||
while (Serial2.available())
|
||||
{
|
||||
Serial.print((char)Serial2.read());
|
||||
}
|
||||
Serial.println();
|
||||
delay(200);
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
32
libraries/SWSerialOut/examples/SWSO_minimal/SWSO_minimal.ino
Normal file
32
libraries/SWSerialOut/examples/SWSO_minimal/SWSO_minimal.ino
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// FILE: SWSO_minimal.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: HX711 demo
|
||||
// URL: https://github.com/RobTillaart/SWSerialOut
|
||||
|
||||
|
||||
#include "SWSerialOut.h"
|
||||
|
||||
SWSerialOut SWSO(7);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("SWSERIALOUT_LIB_VERSION: ");
|
||||
Serial.println(SWSERIALOUT_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
SWSO.begin(9600);
|
||||
SWSO.println("Hello world");
|
||||
|
||||
Serial.println("\nDone...");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
@ -0,0 +1,28 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
# - uno
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
# - m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
# - rpipico
|
||||
|
@ -0,0 +1,96 @@
|
||||
//
|
||||
// FILE: SWSO_test_ESP32.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: SWSO demo for ESP32
|
||||
// URL: https://github.com/RobTillaart/SWSerialOut
|
||||
//
|
||||
// Connect pin 25 with Serial2.RX to run this program
|
||||
// or patch code :)
|
||||
|
||||
#include "SWSerialOut.h"
|
||||
|
||||
SWSerialOut SWS(25);
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("SWSERIALOUT_LIB_VERSION: ");
|
||||
Serial.println(SWSERIALOUT_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
test_short(300);
|
||||
test_short(600);
|
||||
test_short(1200);
|
||||
test_short(2400);
|
||||
test_short(4800);
|
||||
test_short(7200);
|
||||
test_short(9600);
|
||||
test_short(19200);
|
||||
test_short(38400);
|
||||
test_short(57600);
|
||||
test_short(76800); // fails without pull up
|
||||
test_short(100000);
|
||||
test_short(125000); // fails
|
||||
|
||||
Serial.println("\nDone...");
|
||||
}
|
||||
|
||||
|
||||
void test_short(uint32_t bd)
|
||||
{
|
||||
Serial2.begin(bd);
|
||||
|
||||
SWS.begin(bd);
|
||||
Serial.print(bd);
|
||||
Serial.print(" ");
|
||||
delay(100);
|
||||
|
||||
SWS.print("Hello world");
|
||||
|
||||
// echo incoming data
|
||||
Serial.print(Serial2.available()); // should be 11
|
||||
Serial.print("\t");
|
||||
while (Serial2.available())
|
||||
{
|
||||
Serial.print((char)Serial2.read());
|
||||
}
|
||||
Serial.println();
|
||||
delay(200);
|
||||
}
|
||||
|
||||
|
||||
void test_scan(uint32_t bd)
|
||||
{
|
||||
Serial2.begin(bd);
|
||||
for (uint32_t baud = bd * 0.95; baud < bd * 1.05; baud += bd * 0.01)
|
||||
{
|
||||
SWS.begin(baud);
|
||||
Serial.print(baud);
|
||||
Serial.print(" ");
|
||||
delay(100);
|
||||
|
||||
SWS.print("Hello world");
|
||||
|
||||
// echo incoming data
|
||||
Serial.print(Serial2.available()); // should be 11
|
||||
Serial.print("\t");
|
||||
while (Serial2.available())
|
||||
{
|
||||
Serial.print((char)Serial2.read());
|
||||
}
|
||||
Serial.println();
|
||||
delay(200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
28
libraries/SWSerialOut/examples/SWSO_test_UNO/.arduino-ci.yml
Normal file
28
libraries/SWSerialOut/examples/SWSO_test_UNO/.arduino-ci.yml
Normal file
@ -0,0 +1,28 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
- uno
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
# - m4
|
||||
# - esp32
|
||||
# - esp8266
|
||||
- mega2560
|
||||
- rpipico
|
||||
|
@ -0,0 +1,55 @@
|
||||
//
|
||||
// FILE: SWSO_test.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: HX711 demo
|
||||
// URL: https://github.com/RobTillaart/SWSerialOut
|
||||
|
||||
|
||||
#include "SWSerialOut.h"
|
||||
#include "SoftwareSerial.h"
|
||||
|
||||
SWSerialOut SWS(7);
|
||||
// SoftwareSerial SWS(6, 7);
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(19200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("SWSERIALOUT_LIB_VERSION: ");
|
||||
Serial.println(SWSERIALOUT_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
for (uint32_t baud = 19000; baud < 20000; baud += 10)
|
||||
{
|
||||
SWS.begin(baud);
|
||||
Serial.print(baud);
|
||||
Serial.print(" ");
|
||||
delay(100);
|
||||
// SWS.debug();
|
||||
|
||||
SWS.print("Hello world");
|
||||
|
||||
// echo incoming data
|
||||
Serial.print(Serial.available());
|
||||
Serial.print("\t");
|
||||
while (Serial.available())
|
||||
{
|
||||
Serial.print((char)Serial.read());
|
||||
}
|
||||
Serial.println();
|
||||
delay(200);
|
||||
}
|
||||
|
||||
|
||||
Serial.println("\nDone...");
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
20
libraries/SWSerialOut/keywords.txt
Normal file
20
libraries/SWSerialOut/keywords.txt
Normal file
@ -0,0 +1,20 @@
|
||||
# Syntax Colouring Map For SWSerialOut
|
||||
|
||||
# Data types (KEYWORD1)
|
||||
SWSerialOut KEYWORD1
|
||||
|
||||
|
||||
# Methods and Functions (KEYWORD2)
|
||||
begin KEYWORD2
|
||||
|
||||
disableInterrupts KEYWORD2
|
||||
|
||||
|
||||
# Instances (KEYWORD2)
|
||||
|
||||
|
||||
# Constants (LITERAL1)
|
||||
SWSERIALOUT_LIB_VERSION LITERAL1
|
||||
|
||||
|
||||
|
23
libraries/SWSerialOut/library.json
Normal file
23
libraries/SWSerialOut/library.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "SWSerialOut",
|
||||
"keywords": "",
|
||||
"description": "Arduino library for SWSerialOut, supports only data out (TX).",
|
||||
"authors":
|
||||
[
|
||||
{
|
||||
"name": "Rob Tillaart",
|
||||
"email": "Rob.Tillaart@gmail.com",
|
||||
"maintainer": true
|
||||
}
|
||||
],
|
||||
"repository":
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/SWSerialOut.git"
|
||||
},
|
||||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
"headers": "SWSerialOut.h"
|
||||
}
|
11
libraries/SWSerialOut/library.properties
Normal file
11
libraries/SWSerialOut/library.properties
Normal file
@ -0,0 +1,11 @@
|
||||
name=SWSerialOut
|
||||
version=0.1.0
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for SWSerialOut, supports only data out (TX).
|
||||
paragraph=
|
||||
category=Signal Input/Output
|
||||
url=https://github.com/RobTillaart/SWSerialOut
|
||||
architectures=*
|
||||
includes=SWSerialOut.h
|
||||
depends=
|
63
libraries/SWSerialOut/test/unit_test_001.cpp
Normal file
63
libraries/SWSerialOut/test/unit_test_001.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
//
|
||||
// FILE: unit_test_001.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 2023-09-02
|
||||
// PURPOSE: unit tests for the SWSerialOut library
|
||||
// https://github.com/RobTillaart/SWSerialOut
|
||||
// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md
|
||||
//
|
||||
|
||||
// supported assertions
|
||||
// https://github.com/Arduino-CI/arduino_ci/blob/master/cpp/unittest/Assertion.h#L33-L42
|
||||
// ----------------------------
|
||||
// assertEqual(expected, actual)
|
||||
// assertNotEqual(expected, actual)
|
||||
// assertLess(expected, actual)
|
||||
// assertMore(expected, actual)
|
||||
// assertLessOrEqual(expected, actual)
|
||||
// assertMoreOrEqual(expected, actual)
|
||||
// assertTrue(actual)
|
||||
// assertFalse(actual)
|
||||
// assertNull(actual)
|
||||
// assertNotNull(actual)
|
||||
|
||||
#include <ArduinoUnitTests.h>
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "SWSerialOut.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
fprintf(stderr, "SWSERIALOUT_LIB_VERSION: %s\n", (char *) SWSERIALOUT_LIB_VERSION);
|
||||
}
|
||||
|
||||
unittest_teardown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unittest(test_constants)
|
||||
{
|
||||
assertEqual(1, 1);
|
||||
}
|
||||
|
||||
|
||||
unittest(test_constructor)
|
||||
{
|
||||
SWSerialOut SWSO(7);
|
||||
SWSO.begin(9600);
|
||||
|
||||
assertEqual(1,1);
|
||||
}
|
||||
|
||||
|
||||
unittest_main()
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
Loading…
x
Reference in New Issue
Block a user