Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radio to Gui code #69

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d266cdf
Initialize tranceiver branch
sxj754 Jan 21, 2023
50cf04d
Receiver module sends submerge signal
sxj754 Jan 28, 2023
7e6a809
Code to manually set RTC
rickyrnt Feb 11, 2023
339b18a
Merge branch 'main' into tranceiver
rickyrnt Feb 11, 2023
8aaf7d5
Added serial reader node
rickyrnt Feb 15, 2023
ffc24af
Merge remote-tracking branch 'origin/main' into tranceiver
rickyrnt Feb 25, 2023
f399053
Added serial monitor read capability
rickyrnt Feb 25, 2023
068bd69
added stuff to cobtrol callback
Hwodza Mar 24, 2023
4be6a44
Add code to parse commands
rickyrnt Mar 24, 2023
f4ba7e2
Finish float communication code
rickyrnt Mar 25, 2023
603dc9d
Merge remote-tracking branch 'origin/main' into tranceiver
rickyrnt Mar 25, 2023
d7425de
Integrate into gui
rickyrnt Mar 25, 2023
7b7f28d
small pog
InvincibleRMC Apr 8, 2023
af7c55c
work?
InvincibleRMC Apr 8, 2023
059afb1
fixed spelling
InvincibleRMC Apr 8, 2023
c6e6559
remapping
InvincibleRMC Apr 8, 2023
13abd8e
Remove unneccessary messages
rickyrnt Apr 8, 2023
4585983
Merge branch 'tranceiver' of https://github.com/cwruRobotics/rov-23 i…
rickyrnt Apr 8, 2023
ba078f7
Added response codes
rickyrnt Apr 8, 2023
f34f00f
Appease the all-powerful linter
rickyrnt Apr 8, 2023
7e37ae8
fixed message
InvincibleRMC Apr 8, 2023
e996037
Fix formatting
rickyrnt Apr 22, 2023
0d2adf6
Change to custom message
rickyrnt Apr 22, 2023
65aba37
Rectify the egrigous typographical error
rickyrnt Apr 29, 2023
0f5a9e7
Merge branch 'main' into tranceiver
rickyrnt Apr 29, 2023
5cc91e8
Sensible filenames
benjaminwp18 May 29, 2023
93dbe82
Spellcheck & formatting
benjaminwp18 May 29, 2023
1b834ad
Create profiling schedule
benjaminwp18 Jun 1, 2023
d60c981
Merge branch 'main' into tranceiver
benjaminwp18 Jun 1, 2023
c245134
Add FloatCommand to CMake
benjaminwp18 Jun 1, 2023
e143218
Float GUI has single command on main tab
benjaminwp18 Jun 1, 2023
d096419
Unused button vars
benjaminwp18 Jun 1, 2023
bb3c04e
Update team name
benjaminwp18 Jun 1, 2023
9d5920f
Merge remote-tracking branch 'origin/main' into tranceiver
Jun 15, 2023
48a0496
Fixed float code
Jun 21, 2023
171ccc1
comm
Jun 22, 2023
f489768
Merge branch 'main' into tranceiver
Jun 23, 2023
732a3a1
Add time set button to gui (maybe)
NoahMollerstuen Jun 23, 2023
672277d
Fix layout
cwru-rov-laptop Jun 23, 2023
52f75fd
Float stuff idk
NoahMollerstuen Jun 23, 2023
4061850
Merge remote-tracking branch 'origin/tranceiver' into tranceiver
NoahMollerstuen Jun 23, 2023
d13bf97
Add time set buttons
cwru-rov-laptop Jun 23, 2023
12a0957
Merge branch 'tranceiver' of github.com:cwruRobotics/rov-23 into tran…
cwru-rov-laptop Jun 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 94 additions & 58 deletions float/Tranciever_Reciever/Tranciever_Reciever.ino
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,101 +1,111 @@
// rf69 demo tx rx.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client
// Example sketch showing how to create a simple messageing client
// with the RH_RF69 class. RH_RF69 class does not provide for addressing or
// reliability, so you should only use RH_RF69 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example rf69_server.
// Demonstrates the use of AES encryption, setting the frequency and modem
// Demonstrates the use of AES encryption, setting the frequency and modem
// configuration

#include <SPI.h>
#include <RH_RF69.h>

// Digital input pin where the input source(physical switch or GUI) will be coonnected.
// High = submerge, Low = float
// You might change pin number
#define SYRINCE_INPUT 9
benjaminwp18 marked this conversation as resolved.
Show resolved Hide resolved

// True = submerge, False = float
bool syringeCtrl = false;

/************ Radio Setup ***************/

//yes, the key is EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE. best key ever.
uint8_t key[] = { 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE};
uint8_t key[] = {
0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE
};
benjaminwp18 marked this conversation as resolved.
Show resolved Hide resolved

// Change to 434.0 or other frequency, must match RX's freq!
#define RF69_FREQ 877.0

#if defined (__AVR_ATmega32U4__) // Feather 32u4 w/Radio
#define RFM69_CS 8
#define RFM69_INT 7
#define RFM69_RST 4
#define LED 13
#define RFM69_CS 8
#define RFM69_INT 7
#define RFM69_RST 4
#define LED 13
#endif

#if defined(ADAFRUIT_FEATHER_M0) || defined(ADAFRUIT_FEATHER_M0_EXPRESS) || defined(ARDUINO_SAMD_FEATHER_M0)
// Feather M0 w/Radio
#define RFM69_CS 8
#define RFM69_INT 3
#define RFM69_RST 4
#define LED 13
// Feather M0 w/Radio
#define RFM69_CS 8
#define RFM69_INT 3
#define RFM69_RST 4
#define LED 13
#endif

#if defined (__AVR_ATmega328P__) // Feather 328P w/wing
#define RFM69_INT 3 //
#define RFM69_CS 4 //
#define RFM69_RST 2 // "A"
#define LED 13
#define RFM69_INT 3 //
#define RFM69_CS 4 //
#define RFM69_RST 2 // "A"
#define LED 13
#endif

#if defined(ESP8266) // ESP8266 feather w/wing
#define RFM69_CS 2 // "E"
#define RFM69_IRQ 15 // "B"
#define RFM69_RST 16 // "D"
#define LED 0
#define RFM69_CS 2 // "E"
#define RFM69_IRQ 15 // "B"
#define RFM69_RST 16 // "D"
#define LED 0
#endif

#if defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) || defined(ARDUINO_NRF52840_FEATHER) || defined(ARDUINO_NRF52840_FEATHER_SENSE)
#define RFM69_INT 9 // "A"
#define RFM69_CS 10 // "B"
#define RFM69_RST 11 // "C"
#define LED 13
#define RFM69_INT 9 // "A"
#define RFM69_CS 10 // "B"
#define RFM69_RST 11 // "C"
#define LED 13

#elif defined(ESP32) // ESP32 feather w/wing
#define RFM69_RST 13 // same as LED
#define RFM69_CS 33 // "B"
#define RFM69_INT 27 // "A"
#define LED 13
#define RFM69_RST 13 // same as LED
#define RFM69_CS 33 // "B"
#define RFM69_INT 27 // "A"
#define LED 13
#endif

#if defined(ARDUINO_NRF52832_FEATHER)
/* nRF52832 feather w/wing */
#define RFM69_RST 7 // "A"
#define RFM69_CS 11 // "B"
#define RFM69_INT 31 // "C"
#define LED 17
/* nRF52832 feather w/wing */
#define RFM69_RST 7 // "A"
#define RFM69_CS 11 // "B"
#define RFM69_INT 31 // "C"
#define LED 17
#endif

/* Teensy 3.x w/wing
#define RFM69_RST 9 // "A"
#define RFM69_CS 10 // "B"
#define RFM69_IRQ 4 // "C"
#define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ )
#define RFM69_RST 9 // "A"
#define RFM69_CS 10 // "B"
#define RFM69_IRQ 4 // "C"
#define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ )
*/
/* WICED Feather w/wing
#define RFM69_RST PA4 // "A"
#define RFM69_CS PB4 // "B"
#define RFM69_IRQ PA15 // "C"
#define RFM69_IRQN RFM69_IRQ

/* WICED Feather w/wing
#define RFM69_RST PA4 // "A"
#define RFM69_CS PB4 // "B"
#define RFM69_IRQ PA15 // "C"
#define RFM69_IRQN RFM69_IRQ
*/

// Singleton instance of the radio driver
RH_RF69 rf69(RFM69_CS, RFM69_INT);

int16_t packetnum = 0; // packet counter, we increment per xmission

void setup()
void setup()
{
Serial.begin(115200);
//while (!Serial) { delay(1); } // wait until serial console is open, remove if not tethered to computer

Serial.println("Float Receiver");
pinMode(LED, OUTPUT);
Serial.println("Float Reciever");
pinMode(LED, OUTPUT);
pinMode(RFM69_RST, OUTPUT);
digitalWrite(RFM69_RST, LOW);

Expand All @@ -107,13 +117,13 @@ void setup()
delay(10);
digitalWrite(RFM69_RST, LOW);
delay(10);

if (!rf69.init()) {
Serial.println("RFM69 radio init failed");
while (1);
}
Serial.println("RFM69 radio init OK!");

// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM (for low power module)
// No encryption
if (!rf69.setFrequency(RF69_FREQ)) {
Expand All @@ -126,16 +136,35 @@ void setup()

// The encryption key has to be the same as the one in the server
rf69.setEncryptionKey(key);

pinMode(LED, OUTPUT);
pinMode(SYRINCE_INPUT, INPUT);
benjaminwp18 marked this conversation as resolved.
Show resolved Hide resolved

Serial.print("RFM69 radio @"); Serial.print((int)RF69_FREQ); Serial.println(" MHz");
}


void loop() {
if (rf69.available()) {
// Should be a message for us now
receiveData();
// Check if serial signal recieved
if (Serial.available() == 1) {
String command;
command = Serial.readString();
if (command == "submerge") {
sendControlSignal("submerge");
benjaminwp18 marked this conversation as resolved.
Show resolved Hide resolved
} else if (command == "extend") {
sendControlSignal("extend");
} else if (command == "retract") {
sendControlSignal("retract");
} else {
Serial.println("Invalid command");
}
}
}

void receiveData() {
if (rf69.available()) {
// Should be a message for us now
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (rf69.recv(buf, &len)) {
Expand All @@ -145,20 +174,27 @@ void loop() {
Serial.print(len);
Serial.print("]: ");
Serial.println((char*)buf);
Serial.print("RSSI: ");
Serial.println(rf69.lastRssi(), DEC);
//Serial.print("RSSI: ");
//Serial.println(rf69.lastRssi(), DEC);
} else {
Serial.println("Receive failed");
}
}
}

void sendControlSignal(char* message) {
// Send a message to rf69_server
rf69.send(message, sizeof(message));
rf69.waitPacketSent();
Serial.print(message); Serial.println(" signal sent!");
}


void Blink(byte PIN, byte DELAY_MS, byte loops) {
for (byte i=0; i<loops; i++) {
digitalWrite(PIN,HIGH);
void blink(byte PIN, byte DELAY_MS, byte loops) {
for (byte i = 0; i < loops; i++) {
digitalWrite(PIN, HIGH);
delay(DELAY_MS);
digitalWrite(PIN,LOW);
digitalWrite(PIN, LOW);
delay(DELAY_MS);
}
}
Loading