Initial import: robot firmware + PlatformIO two-env scaffold
Robot-side firmware (Teensy 4.0) imported unchanged as extracted. platformio.ini defines [env:robot] (teensy40) and [env:remote] (teensy41); scripts/select_src_dir.py points each env at its own sketch folder so robot/ and remote/ stay Arduino-style sketches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
ad77b06c36
27 files changed
+1107
No files matched your search
@@ -0,0 +1,28 @@
|
||||
#include "Comms.h"
|
||||
#include "Config.h"
|
||||
#include <RF24.h>
|
||||
#include <SPI.h>
|
||||
|
||||
static RF24 radio(RADIO_CE_PIN, RADIO_CSN_PIN);
|
||||
|
||||
bool Comms::begin() {
|
||||
radio_present_ = radio.begin();
|
||||
if (radio_present_) {
|
||||
radio.openReadingPipe(1, RADIO_ADDRESS);
|
||||
radio.setPALevel(RF24_PA_LOW);
|
||||
radio.setDataRate(RF24_250KBPS);
|
||||
radio.setChannel(96); // pick one clear of your local Wi-Fi
|
||||
radio.startListening();
|
||||
}
|
||||
return radio_present_;
|
||||
}
|
||||
|
||||
void Comms::update() {
|
||||
if (radio_present_) {
|
||||
while (radio.available()) {
|
||||
radio.read(&packet_, sizeof(packet_));
|
||||
last_rx_ms_ = millis();
|
||||
}
|
||||
}
|
||||
link_ok_ = (millis() - last_rx_ms_) < (uint32_t)(LINK_TIMEOUT_SEC * 1000);
|
||||
}
|
||||
Reference in new issue
Block a user