Compare commits

..

No commits in common. "88c22ee4572e4acaccd66091e77cb8be2fad7e7d" and "1eee1f09bb42e5913a425ab7732f54787238c8d5" have entirely different histories.

11 changed files with 37 additions and 211 deletions

View file

@ -9,18 +9,37 @@
#include <TinyGPS++.h> // Library to handle GPS data
#include <SoftwareSerial.h> // Software serial for GPS communication
#include <RH_RF95.h> //
//#include "Radio/Radio.h"
#include "inc/board_config.h"
//GLOBAL VARS/OBJS
// MAGNETOMETER (LIS2MDL) CONFIGURATION
Adafruit_LIS2MDL lis2mdl = Adafruit_LIS2MDL(12345); // Create magnetometer object
// DISPLAY CONFIGURATION (ST7789)
#define TFT_CS 5 // Chip select pin for the display
#define TFT_RST 9 // Reset pin for the display
#define TFT_DC 6 // Data/Command pin for the display
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST); // Initialize display
// LED RING CONFIGURATION (WS2812)
#define NUM_LEDS 24 // Number of LEDs in the ring
#define DATA_PIN 12 // Pin for LED data
CRGB leds[NUM_LEDS]; // Array to hold LED colors
// GPS CONFIGURATION (BN-220)
#define GPS_TX_PIN 10 // GPS TX pin connected to Arduino RX
#define GPS_RX_PIN 11 // GPS RX pin connected to Arduino TX
SoftwareSerial gpsSerial(GPS_RX_PIN, GPS_TX_PIN); // Software serial for GPS
TinyGPSPlus gps; // TinyGPS++ object to process GPS data
// Radio defines
#define RFM95_CS 8
#define RFM95_INT 7
#define RFM95_RST 4
#define RF95_FREQ 915.0
#define RF95_MAX_DB 23
#define RF95_MIN_DB 5
#define RF95_TIMEOUT 250
#define RF95_BUF_SZ 32
RH_RF95 rf95(RFM95_CS, RMF95_INT); // Radio instance.
@ -42,6 +61,7 @@ NodeId node = {
};
uint8_t reciver_buffer[RF95_BUF_SZ];
void Radio_setup(void) {
pinMode(RFM95_RST, OUTPUT);
digitalWrite(RFM95_RST, HIGH);
@ -59,7 +79,6 @@ void Radio_setup(void) {
rf95.setTxPower(RF95_MIN_DB, false);
}
void Radio_reset(void) {
digitalWrite(RFM95_RST, LOW);
delay(10);
@ -100,8 +119,6 @@ int Radio_SendData() {
rf95.setModeIdle();
}
int Radio_ReceiveData() {
//Set radio into RX mode.
rf95.setModeRx();
@ -117,10 +134,10 @@ int Radio_ReceiveData() {
void setup(void) {
// Initialize Serial Communication for debugging
Serial.begin(SERIAL_BUADRATE);
Serial.begin(115200);
// Display Setup
tft.init(TFT_X, TFT_Y); // Initialize the display with a resolution of 240x280 pixels
tft.init(240, 280); // Initialize the display with a resolution of 240x280 pixels
tft.fillScreen(ST77XX_BLACK); // Set the screen background to black
// Magnetometer Setup
@ -130,10 +147,10 @@ void setup(void) {
}
// LED Ring Setup
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // Initialize the LED ring
// GPS Setup
gpsSerial.begin(GPS_BUADRATE);
gpsSerial.begin(9600); // Start GPS communication at 9600 baud rate
}
void loop() {

View file

@ -1,41 +0,0 @@
#ifndef BOARD_CONFIG_H
#define BOARD_CONFIG_H
//Un-comment a line below for the target board/uC.
#define FEATHER_RFM95
//#define FEATHER_RFM96
//Only applied if defined
#ifdef FEATHER_RFM9X
//Define Serial params for debuging
#define SERIAL_BUADRATE 115200
// DISPLAY CONFIGURATION (ST7789)
#define TFT_CS 5 // Chip select pin for the display
#define TFT_RST 9 // Reset pin for the display
#define TFT_DC 6 // Data/Command pin for the display
#define TFT_X 240 // Number of pixes in X axis.
#define TFT_Y 280 // Number of pixes in Y axis.
// LED RING CONFIGURATION (WS2812)
#define NUM_LEDS 24 // Number of LEDs in the ring
#define DATA_PIN 12 // Pin for LED data
// GPS CONFIGURATION (BN-220)
#define GPS_TX_PIN 10 // GPS TX pin connected to Arduino RX
#define GPS_RX_PIN 11 // GPS RX pin connected to Arduino TX
#define GPS_BUADRATE 9600 // GPS serial baud rate.
// Radio defines
#define RFM95_CS 8
#define RFM95_INT 7
#define RFM95_RST 4
#define RF95_FREQ 915.0
#define RF95_MAX_DB 23
#define RF95_MIN_DB 5
#define RF95_TIMEOUT 250
#define RF95_BUF_SZ 32
#endif //FEATHER_RFM9X
#endif //BOARD_CONFIG_H

View file

@ -1 +0,0 @@
./src/main.cpp

View file

@ -1,4 +1,3 @@
add_executable(main
main.c
)
add_subdirectory(Radio)

View file

@ -1,7 +0,0 @@
add_library(Radio STATIC
Radio.c
)
target_include_directories(Radio PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)

View file

@ -1,68 +0,0 @@
/*
* Author: username
* Date: 2024
* filename: Radio.c
* description: module_purpose
*/
#include "Radio.h"
void Radio_setup(void) {
pinMode(RFM95_RST, OUTPUT);
digitalWrite(RFM95_RST, HIGH);
while(!rf95.init()){}
Serial.println("radio: Initialized");
if(rf95.setFrequency(RF95_FREQ)) {
Serial.println("radio: Error could not set frequency");
while(true){} //Loop forever
}
Serial.print("radio: Frequency = ");
Serial.println(RF95_FREQ);
rf95.setTxPower(RF95_MIN_DB, false);
}
void Radio_reset(void) {
digitalWrite(RFM95_RST, LOW);
delay(10);
digitalWrite(RFM95_RST, HIGH);
delay(10);
}
int Radio_SendData() {
int8_t tx_power = RF95_MIN_DB;
uint8_t received_id = 0;
//Set the radio output to lowest power.
rf95.setTxPower(tx_power, false);
//Set the radio into TX mode.
rf95.setModeTx();
//Try transmitting data
rf95.send(node.id, 1);
rf95.waitPacketSent();
//Wait for ACK or Radio Msg. (Timeout Should be included).
//On timeout increase the transmit power and re-attempt.
if(!rf95.waitAvailbleTimeout(RF95_TIMEOUT)) {
if(rf95.recv(reciver_buffer, RF95_BUF_SZ)) {
}
else {
//Failed to receive the message.
}
}
else {
//No reply of any kind.
}
//Set the radio mode to idle.
rf95.setModeIdle();
}

View file

@ -1,30 +0,0 @@
/*
* Author: username
* Date: 2024
* filename: RADIO.h
* description: module_purpose
*/
#ifndef RADIO
#define RADIO
/**
* @brief Preforms radio setup using defined values.
*/
void Radio_setup(void);
/**
* @brief Resets the radio module.
*/
void Radio_reset(void);
/**
* @brief Sends data to any receiving radios.
*/
int Radio_SendData();
#endif //RADIO

7
src/main.c Normal file
View file

@ -0,0 +1,7 @@
#include "stdio.h"
int main(int argc, char **argv)
{
printf("Hello!\n");
return 0;
}

View file

@ -1,7 +1,6 @@
project(Tests)
# TEST_DIRS
add_subdirectory(Radio)
add_subdirectory(simple_test)
# TEST_RUNNER
@ -13,6 +12,5 @@ target_link_libraries(AllTests
${CPPUTEST_LIBRARIES}/libCppUTest.a
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
# TEST_LINKS
Radio
simple_test
)

View file

@ -1,10 +0,0 @@
# TEST_RUNNER
add_library(test_Radio
test_Radio.cpp
)
target_link_libraries(test_Radio
${CPPUTEST_LIBRARIES}/libCppUTest.a
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
Radio
)

View file

@ -1,38 +0,0 @@
/*
* Author: username
* Date: todays_date
* filename: test_Radio.c
* description: module_purpose
*/
#include "CppUTest/CommandLineTestRunner.h"
extern "C"
{
#include "Radio.h"
}
TEST_GROUP(FirstTestGroup)
{
void setup()
{
}
void teardown()
{
}
};
TEST(FirstTestGroup, FirstTest)
{
FAIL("Fail me!");
}
TEST(FirstTestGroup, SecondTest)
{
STRCMP_EQUAL("hello", "world");
LONGS_EQUAL(1, 2);
CHECK(false);
}