[RTTY] String encoding based on number of data bits
This commit is contained in:
parent
f6f2215a7d
commit
8562b7a71e
3 changed files with 49 additions and 15 deletions
|
@ -48,9 +48,9 @@ void setup() {
|
|||
// low frequency: 434.0 MHz
|
||||
// frequency shift: 183 Hz
|
||||
// baud rate: 45 baud
|
||||
// data bits: 8
|
||||
// data bits: 8 (ASCII encoding)
|
||||
// stop bits: 1
|
||||
state = rtty.begin(434, 183, 45, 5);
|
||||
state = rtty.begin(434, 183, 45, 8);
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
|
@ -94,21 +94,27 @@ void loop() {
|
|||
|
||||
/*
|
||||
// KiteLib also provides ITA2 ("Baudot") code support
|
||||
// RTTY client must be configured to 5 bits
|
||||
// To enable ITA2 encoding, set RTTY client
|
||||
// to 5 data bits
|
||||
rtty.begin(434, 183, 45, 5);
|
||||
|
||||
// send synchronization string ("RYRY..." corresponds
|
||||
// to binary 01010101010101010101... in ITA2 encoding)
|
||||
ITA2 sync = "RYRYRYRY";
|
||||
rtty.println(sync);
|
||||
rtty.println("RYRYRYRY");
|
||||
|
||||
// create ITA2-encoded string
|
||||
// NOTE: ASCII characters that do not have ITA2
|
||||
// equivalent will be replaced with NUL
|
||||
ITA2 itaStr = "HELLO WORLD";
|
||||
|
||||
// print the ITA2 string
|
||||
rtty.println(itaStr);
|
||||
// send ITA2-encoded string (all ASCII characters
|
||||
// that do not have ITA2 equivalent will be replaced
|
||||
// with NUL
|
||||
rtty.println("HELLO WORLD!");
|
||||
|
||||
String aStr = "ARDUINO STRING";
|
||||
rtty.println(aStr);
|
||||
|
||||
// character array (C-string)
|
||||
rtty.println("C-STRING");
|
||||
|
||||
// character
|
||||
rtty.println('C');
|
||||
|
||||
// all numbers can also be sent using ITA2
|
||||
float f = -3.1415;
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
#include "RTTY.h"
|
||||
|
||||
ITA2::ITA2(char c) {
|
||||
_len = 1;
|
||||
_str = new char[1];
|
||||
_str[0] = c;
|
||||
}
|
||||
|
||||
ITA2::ITA2(const char* str) {
|
||||
_len = strlen(str);
|
||||
_str = new char[_len];
|
||||
|
@ -147,15 +153,36 @@ size_t RTTYClient::print(ITA2& ita2) {
|
|||
}
|
||||
|
||||
size_t RTTYClient::print(const String& str) {
|
||||
return(RTTYClient::write((uint8_t*)str.c_str(), str.length()));
|
||||
size_t n = 0;
|
||||
if(_dataBits == 5) {
|
||||
ITA2 ita2 = str.c_str();
|
||||
n = RTTYClient::print(ita2);
|
||||
} else {
|
||||
n = RTTYClient::write((uint8_t*)str.c_str(), str.length());
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
size_t RTTYClient::print(const char str[]) {
|
||||
return(RTTYClient::write((uint8_t*)str, strlen(str)));
|
||||
size_t n = 0;
|
||||
if(_dataBits == 5) {
|
||||
ITA2 ita2 = str;
|
||||
n = RTTYClient::print(ita2);
|
||||
} else {
|
||||
n = RTTYClient::write((uint8_t*)str, strlen(str));
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
size_t RTTYClient::print(char c) {
|
||||
return(RTTYClient::write(c));
|
||||
size_t n = 0;
|
||||
if(_dataBits == 5) {
|
||||
ITA2 ita2 = c;
|
||||
n = RTTYClient::print(ita2);
|
||||
} else {
|
||||
n = RTTYClient::write(c);
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
size_t RTTYClient::print(unsigned char b, int base) {
|
||||
|
|
|
@ -18,6 +18,7 @@ const char ITA2Table[ITA2_LENGTH][2] = {{'\0', '\0'}, {'E', '3'}, {'\n', '\n'},
|
|||
|
||||
class ITA2 {
|
||||
public:
|
||||
ITA2(char c);
|
||||
ITA2(const char* str);
|
||||
~ITA2();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue