-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
548 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
 | ||
 | ||
# Gyver433_TX | ||
Библиотека для радиомодулей 433 МГц и Arduino | ||
- Не использует прерывания и таймеры (кроме нулевого, читает micros()) | ||
- Встроенный CRC контроль целостности | ||
- Ускоренный алгоритм IO для AVR Arduino | ||
|
||
### Совместимость | ||
Совместима со всеми Arduino платформами (используются Arduino-функции) | ||
|
||
## Содержание | ||
- [Установка](#install) | ||
- [Инициализация](#init) | ||
- [Использование](#usage) | ||
- [Пример](#example) | ||
- [Версии](#versions) | ||
- [Баги и обратная связь](#feedback) | ||
|
||
<a id="install"></a> | ||
## Установка | ||
- Библиотеку можно найти по названию **Gyver433_TX** и установить через менеджер библиотек в: | ||
- Arduino IDE | ||
- Arduino IDE v2 | ||
- PlatformIO | ||
- [Скачать библиотеку](https://github.com/GyverLibs/Gyver433_TX/archive/refs/heads/main.zip) .zip архивом для ручной установки: | ||
- Распаковать и положить в *C:\Program Files (x86)\Arduino\libraries* (Windows x64) | ||
- Распаковать и положить в *C:\Program Files\Arduino\libraries* (Windows x32) | ||
- Распаковать и положить в *Документы/Arduino/libraries/* | ||
- (Arduino IDE) автоматическая установка из .zip: *Скетч/Подключить библиотеку/Добавить .ZIP библиотеку…* и указать скачанный архив | ||
- Читай более подробную инструкцию по установке библиотек [здесь](https://alexgyver.ru/arduino-first/#%D0%A3%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BA%D0%B0_%D0%B1%D0%B8%D0%B1%D0%BB%D0%B8%D0%BE%D1%82%D0%B5%D0%BA) | ||
|
||
<a id="init"></a> | ||
## Инициализация | ||
```cpp | ||
// указать пин | ||
Gyver433_RX rx(2); | ||
Gyver433_TX tx(2); | ||
``` | ||
<a id="usage"></a> | ||
## Использование | ||
```cpp | ||
// ========= Gyver433_TX ========= | ||
void sendData(T &data); // отправить данные любого типа | ||
// ========= Gyver433_RX ========= | ||
uint8_t tick(); // неблокирующий приём, вернёт кол-во успешно принятых байт | ||
uint8_t tickWait(); // блокирующий приём, вернёт кол-во успешно принятых байт | ||
bool readData(T &data); // прочитает буфер в любой тип данных (в указанную переменную) | ||
int getSize(); // получить размер принятых данных | ||
``` | ||
|
||
<a id="example"></a> | ||
## Пример | ||
Остальные примеры смотри в **examples**! | ||
### Отправка | ||
```cpp | ||
// мелкий передатчик 3.6V SYN115 | ||
|
||
#define G433_BUFSIZE 50 // размер буфера | ||
#define G433_SPEED 2000 // скорость бит/сек (минимальная) | ||
|
||
#include <Gyver433.h> | ||
Gyver433_TX tx(2); // указали пин | ||
|
||
void setup() { | ||
} | ||
|
||
char data[] = "Hello from #xx"; | ||
byte count = 0; | ||
void loop() { | ||
data[12] = (count / 10) + '0'; | ||
data[13] = (count % 10) + '0'; | ||
if (++count >= 100) count = 0; | ||
tx.sendData(data); | ||
delay(100); | ||
} | ||
``` | ||
### Приём | ||
```cpp | ||
// крупный приёмник 5.0 SYN480R | ||
#define G433_BUFSIZE 50 // размер буфера | ||
#define G433_SPEED 2000 // скорость бит/сек (минимальная) | ||
#include <Gyver433.h> | ||
Gyver433_RX rx(2); | ||
void setup() { | ||
Serial.begin(9600); | ||
} | ||
void loop() { | ||
// tick принимает асинхронно, но может ловить ошибки при загруженном коде | ||
// tickWait блокирует выполнение, но принимает данные чётко | ||
if (rx.tickWait()) { | ||
byte buf[64]; | ||
rx.readData(buf); | ||
for (byte i = 0; i < rx.size; i++) Serial.write(buf[i]); | ||
} | ||
} | ||
``` | ||
|
||
<a id="versions"></a> | ||
## Версии | ||
- v1.0 | ||
|
||
<a id="feedback"></a> | ||
## Баги и обратная связь | ||
При нахождении багов создавайте **Issue**, а лучше сразу пишите на почту [alex@alexgyver.ru](mailto:alex@alexgyver.ru) | ||
Библиотека открыта для доработки и ваших **Pull Request**'ов! |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// крупный приёмник 5.0 SYN480R | ||
|
||
#define G433_BUFSIZE 50 // размер буфера | ||
#define G433_SPEED 2000 // скорость бит/сек (минимальная) | ||
|
||
#include <Gyver433.h> | ||
Gyver433_RX rx(2); | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
} | ||
|
||
|
||
void loop() { | ||
// tick принимает асинхронно, но может ловить ошибки при загруженном коде | ||
// tickWait блокирует выполнение, но принимает данные чётко | ||
if (rx.tickWait()) { | ||
byte buf[64]; | ||
rx.readData(buf); | ||
for (byte i = 0; i < rx.size; i++) Serial.write(buf[i]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// крупный приёмник 5.0V SYN480R | ||
#define G433_BUFSIZE 50 // размер буфера | ||
#define G433_SPEED 2000 // скорость бит/сек (минимальная) | ||
|
||
#include <Gyver433.h> | ||
Gyver433_RX rx(2); // указали пин | ||
|
||
#include <Wire.h> | ||
#include <LiquidCrystal_I2C.h> | ||
LiquidCrystal_I2C lcd(0x3f, 16, 2); // или 0x27 | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
lcd.init(); | ||
lcd.backlight(); | ||
} | ||
|
||
void loop() { | ||
// tick принимает асинхронно, но может ловить ошибки при загруженном коде | ||
// tickWait блокирует выполнение, но принимает данные чётко | ||
if (rx.tick()) { | ||
byte buf[64]; | ||
rx.readData(buf); // прочитать в buf | ||
lcd.clear(); | ||
lcd.home(); | ||
for (byte i = 0; i < rx.size; i++) lcd.write(buf[i]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// передача структуры данных | ||
// крупный приёмник 5.0V SYN480R | ||
#define G433_BUFSIZE 50 // размер буфера | ||
#define G433_SPEED 2000 // скорость бит/сек (минимальная) | ||
|
||
#include <Gyver433.h> | ||
Gyver433_RX rx(2); // указали пин | ||
|
||
// формат пакета для приёма (такой же как отправляется) | ||
struct dataPack { | ||
byte counter; | ||
byte randomNum; | ||
int analog; | ||
uint32_t time; | ||
}; | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
} | ||
|
||
void loop() { | ||
// tick принимает асинхронно, но может ловить ошибки при загруженном коде | ||
// tickWait блокирует выполнение, но принимает данные чётко | ||
if (rx.tick()) { | ||
dataPack data; | ||
rx.readData(data); // прочитать в buf | ||
|
||
Serial.println("Received:"); | ||
Serial.println(data.counter); | ||
Serial.println(data.randomNum); | ||
Serial.println(data.analog); | ||
Serial.println(data.time); | ||
Serial.println(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// мелкий передатчик 3.6V SYN115 | ||
#define G433_BUFSIZE 50 // размер буфера | ||
#define G433_SPEED 2000 // скорость бит/сек (минимальная) | ||
#include <Gyver433.h> | ||
Gyver433_TX tx(2); // указали пин | ||
|
||
void setup() { | ||
} | ||
|
||
char data[] = "Hello from #xx"; | ||
byte count = 0; | ||
void loop() { | ||
data[12] = (count / 10) + '0'; | ||
data[13] = (count % 10) + '0'; | ||
if (++count >= 100) count = 0; | ||
tx.sendData(data); | ||
delay(100); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// передача структуры данных | ||
// мелкий передатчик 3.6V SYN115 | ||
|
||
#define G433_BUFSIZE 50 // размер буфера | ||
#define G433_SPEED 2000 // скорость бит/сек (минимальная) | ||
#include <Gyver433.h> | ||
Gyver433_TX tx(2); // указали пин | ||
|
||
// формат пакета для отправки | ||
struct dataPack { | ||
byte counter; | ||
byte randomNum; | ||
int analog; | ||
uint32_t time; | ||
}; | ||
dataPack data; | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
} | ||
|
||
void loop() { | ||
data.counter++; // тут счётчик | ||
data.randomNum = random(256); // случайное число | ||
data.analog = analogRead(0); // тут ацп | ||
data.time = millis(); // тут миллис | ||
|
||
Serial.println("Transmit:"); | ||
Serial.println(data.counter); | ||
Serial.println(data.randomNum); | ||
Serial.println(data.analog); | ||
Serial.println(data.time); | ||
Serial.println(); | ||
|
||
tx.sendData(data); | ||
delay(1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
####################################### | ||
# Syntax Coloring Map For Gyver433 | ||
####################################### | ||
|
||
####################################### | ||
# Datatypes (KEYWORD1) | ||
####################################### | ||
Gyver433 KEYWORD1 | ||
Gyver433_TX KEYWORD1 | ||
Gyver433_RX KEYWORD1 | ||
|
||
####################################### | ||
# Methods and Functions (KEYWORD2) | ||
####################################### | ||
sendData KEYWORD2 | ||
tick KEYWORD2 | ||
tickWait KEYWORD2 | ||
readData KEYWORD2 | ||
size KEYWORD2 | ||
getSize KEYWORD2 | ||
|
||
####################################### | ||
# Constants (LITERAL1) | ||
####################################### | ||
G433_SPEED LITERAL1 | ||
G433_BUFSIZE LITERAL1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name=Gyver433 | ||
version=1.0 | ||
author=AlexGyver <alex@alexgyver.ru> | ||
maintainer=AlexGyver <alex@alexgyver.ru> | ||
sentence=Simple library for 433 MHz radio | ||
paragraph=Simple library for 433 MHz radio | ||
category=Device Control | ||
url=https://github.com/GyverLibs/Gyver433 | ||
architectures=* |
Oops, something went wrong.