-
Notifications
You must be signed in to change notification settings - Fork 2
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
7 changed files
with
63 additions
and
73 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 |
---|---|---|
@@ -1,16 +1,38 @@ | ||
# EspNow RcLink | ||
|
||
RcLink that works on ESP-NOW. | ||
RC Link library that works on ESP-NOW for tiny models in short range. | ||
|
||
# Features | ||
|
||
* ESP32 and ESP8266 support | ||
* Auto pairing | ||
* Up to 100Hz packet rate (or maybe more) | ||
* 8 RC channels | ||
* Channels 1-4 are sent with full resolution and extended range 880-2120 | ||
* Channels 5-8 are sent with reduced resolution and scaled for extended range 880-2120 (packed to 8-bit size, resolution is 5 units) | ||
* packet checksum checking | ||
|
||
# How it works | ||
|
||
TODO. | ||
* when reciever is powered it sends pair request | ||
* when transmitter is powered, it scans channels for pair request | ||
* when transmitter receive pair request, adds peer to the list and sends pair response | ||
* when receiver recieive pair response, adds peer to the list and start communicating only with this transmitter | ||
* transmitter will not accept any other pair request, until power cycle | ||
* receiver will not accept any data packet form other transmitter, until power cycle | ||
|
||
# Examples | ||
|
||
* [Receiver](/examples/rx/rx.cpp) | ||
* [Transmitter](/examples/tx/tx.cpp) | ||
|
||
# Todo | ||
|
||
* Tests, a lot of testing required | ||
* Telemetry | ||
* RSSI | ||
* More channels | ||
|
||
# Licence | ||
|
||
This project is distributed under MIT Licence. |
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 |
---|---|---|
@@ -1,35 +1,28 @@ | ||
|
||
#include <Arduino.h> | ||
#include "EspNowRcLink/Receiver.h" | ||
|
||
using namespace EspNowRcLink; | ||
|
||
Receiver rx; | ||
EspNowRcLink::Receiver rx; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
rx.begin(); | ||
// initialize receiver | ||
// - true to init hidden WiFi AP | ||
// - false if you manage WiFi outside (default) | ||
rx.begin(true); | ||
} | ||
|
||
void loop() | ||
{ | ||
uint32_t now = millis(); | ||
static uint32_t rcDataNext = now + 500; | ||
|
||
// receive data | ||
rx.update(); | ||
|
||
// check if new data available | ||
if(rx.available()) | ||
{ | ||
if(rcDataNext < now) | ||
for(size_t c = EspNowRcLink::RC_CHANNEL_MIN; c <= EspNowRcLink::RC_CHANNEL_MAX; c++) | ||
{ | ||
Serial.print("RC: "); | ||
for(size_t i = RC_CHANNEL_MIN; i <= RC_CHANNEL_MAX; i++) | ||
{ | ||
Serial.print(rx.getChannel(i)); | ||
Serial.print(' '); | ||
} | ||
Serial.println(); | ||
rcDataNext = now + 500; | ||
uint16_t v = rx.getChannel(c); | ||
//proceedRcChannel(c, v); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,65 +1,37 @@ | ||
#include <Arduino.h> | ||
#include "EspNowRcLink/Transmitter.h" | ||
|
||
// uncomment to activate simultor on channel 3 | ||
//#define ESPNOW_RCLINK_DEMO_TX_SIM | ||
|
||
using namespace EspNowRcLink; | ||
|
||
Transmitter tx; | ||
EspNowRcLink::Transmitter tx; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
|
||
tx.begin(); | ||
|
||
tx.setChannel(0, 1500); | ||
tx.setChannel(1, 1500); | ||
tx.setChannel(2, 1000); | ||
tx.setChannel(3, 1500); | ||
tx.setChannel(4, 1500); | ||
tx.setChannel(5, 1500); | ||
tx.setChannel(6, 1500); | ||
tx.setChannel(7, 1500); | ||
// initialize transmitter | ||
// - true to init hidden WiFi AP | ||
// - false if you manage WiFi outside (default) | ||
tx.begin(true); | ||
} | ||
|
||
void loop() | ||
{ | ||
static int sim_cnt = 0; | ||
static bool sim_up = true; | ||
int sim_speed = 4; | ||
|
||
uint32_t now = millis(); | ||
static uint32_t rcDataNext = now + 50; | ||
static uint32_t sendNext = now + 20; | ||
|
||
// send rc channels | ||
if(rcDataNext < now) | ||
// send rc channels every 20ms | ||
if(now > sendNext) | ||
{ | ||
tx.setChannel(2, 1000 + (sim_cnt * sim_speed)); | ||
tx.commit(); | ||
rcDataNext = now + 20; | ||
|
||
#ifdef ESPNOW_RCLINK_DEMO_TX_SIM | ||
if(sim_up) | ||
// use rc range 1000-2000 | ||
for(size_t c = EspNowRcLink::RC_CHANNEL_MIN; c <= EspNowRcLink::RC_CHANNEL_MAX; c++) | ||
{ | ||
sim_cnt++; | ||
if(sim_cnt >= (1000 / sim_speed)) | ||
{ | ||
sim_up = false; | ||
} | ||
tx.setChannel(c, 1000); | ||
} | ||
else | ||
{ | ||
sim_cnt--; | ||
if(sim_cnt == 0) | ||
{ | ||
sim_up = true; | ||
} | ||
} | ||
#else | ||
(void)sim_up; | ||
#endif | ||
|
||
// mark as ready to send | ||
tx.commit(); | ||
|
||
// schedule next transmission | ||
sendNext = now + 20; | ||
} | ||
|
||
// proceed sending and handle incoming data | ||
tx.update(); | ||
} | ||
} |
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
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
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
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