Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions lib/baro/lps25hb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ float Barometer::getPressure()

bool Barometer::measurementReady()
{

long current_time = millis();
if (current_time - this->previous_time >= this->measurement_delay)
{
Expand Down
8 changes: 8 additions & 0 deletions lib/baro/lps25hb.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@
#include <SPI.h>
#include "chip.h"

#if defined(HALOSHIP)
#define LPS_SCK PA5
#define LPS_MISO PA6
#define LPS_MOSI PA7
#endif

#if defined(FEATHER_BOARD)
#define LPS_SCK PB13
#define LPS_MISO PB14
#define LPS_MOSI PB15
#endif

class Barometer : public Task, public Chip
{
Expand Down
4 changes: 4 additions & 0 deletions lib/buzzer/buzzer.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef BUZZER_H
#define BUZZER_H

#if defined(FEATHER_BOARD)
#define BUZZER PC3
#endif

#include <scheduler.h>
#include <Arduino.h>
#include <mario.h>
Expand Down
71 changes: 71 additions & 0 deletions lib/gps/gps.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include "gps.h";

GPS::GPS(long measurement_delay) : Task(TASK_MILLISECOND, TASK_FOREVER, &scheduler, false),
measurement_delay(measurement_delay),
previous_time(0),
altitudeMSL(-1),
latitude(-1),
longitude(-1)
{
// this->spi_dev = SPIClass(LPS_MOSI, LPS_MISO, LPS_SCK);
// this->spi_dev.begin();
// this->LPS_CS = LPS_CS;
this->gps_driver = new SFE_UBLOX_GNSS();
}

GPS::~GPS() {}

long GPS::getAltitude()
{
return this->altitudeMSL;
}

long GPS::getLatitude()
{
return this->latitude;
}

long GPS::getLongitude()
{
return this->longitude;
}

bool GPS::measurementReady()
{

long current_time = millis();
if (current_time - this->previous_time >= this->measurement_delay)
{
this->previous_time = current_time;
return true;
}
return false;
}

bool GPS::Callback()
{
this->gps_driver->checkUblox();
if (measurementReady())
{
this->altitudeMSL = this->gps_driver->getAltitudeMSL();
this->latitude = this->gps_driver->getLatitude();
this->longitude = this->gps_driver->getLongitude();
return true;
}
return false;
}

bool GPS::OnEnable()
{
return true;
}

void GPS::OnDisable()
{
}

bool GPS::checkStatus()
{
Serial.println("gps Checking status");
return this->gps_driver->begin();
}
55 changes: 55 additions & 0 deletions lib/gps/gps.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// #ifndef LPS25HB_H
// #define LPS25HB_H

#include <scheduler.h>
#include <SparkFun_u-blox_GNSS_Arduino_Library.h>
// #include <Adafruit_LPS2X.h>
// #include <Adafruit_Sensor.h>
#include <Arduino.h>
#include <SPI.h>
#include "chip.h"

// #if defined(FEATHER_BOARD)
// #define LPS_SCK PA5
// #define LPS_MISO PA6
// #define LPS_MOSI PA7
// #endif

// #if defined(FEATHER_BOARD)
// #define LPS_SCK PB13
// #define LPS_MISO PB14
// #define LPS_MOSI PB15
// #endif

class GPS : public Task, public Chip
{
private:
SFE_UBLOX_GNSS *gps_driver;
// Adafruit_Sensor *temp_driver, *pressure_driver;
// SPIClass spi_dev;
// int LPS_CS;
long measurement_delay;
long previous_time = 0;
long altitudeMSL;
long latitude;
long longitude;

public:
GPS(long measurement_delay);
~GPS();

bool measurementReady();
long getAltitude();
long getLatitude();
long getLongitude();

// Task virtual methods
bool Callback();
bool OnEnable();
void OnDisable();

// Chip virtual methods
bool checkStatus();
};

// #endif
37 changes: 36 additions & 1 deletion lib/transceiver/rfm69.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,49 @@
#include "rfm69.h"

Transceiver::Transceiver(int RFM69_CS, int RFM69_INT) : Task(TASK_MILLISECOND, TASK_FOREVER, &scheduler, false)
Transceiver::Transceiver(int RFM69_CS, int RFM69_INT, Barometer *barometer, GPS *gps, long measurement_delay) : Task(TASK_MILLISECOND, TASK_FOREVER, &scheduler, false),
measurements_delay(measurement_delay),
previous_time(0)
{
this->driver = new RH_RF69(RFM69_CS, RFM69_INT);
this->barometer = barometer;
this->gps = gps;
}

Transceiver::~Transceiver() {}

bool Transceiver::measurementsReady()
{

long current_time = millis();
if (current_time - this->previous_time >= this->measurements_delay)
{
this->previous_time = current_time;
return true;
}
return false;
}

bool Transceiver::Callback()
{
long current_time = millis();
if (measurementsReady())
{
char radiopacket[RH_RF69_MAX_MESSAGE_LEN];
snprintf(radiopacket, RH_RF69_MAX_MESSAGE_LEN, "%f\n%f\n%d\n%d\n%d\n ",
this->barometer->getPressure(),
this->barometer->getTemperature(),
this->gps->getAltitude(),
this->gps->getLatitude(),
this->gps->getLongitude());
// Send a message!
this->driver->send((uint8_t *)radiopacket, sizeof(radiopacket));
this->driver->waitPacketSent();
this->previous_time = current_time;
return true;
}
return false;
;

if (this->driver->available())
{
// Should be a message for us now
Expand Down
10 changes: 9 additions & 1 deletion lib/transceiver/rfm69.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,26 @@
#include <RH_RF69.h>
#include <SPI.h>
#include <Arduino.h>
#include <lps25hb.h>
#include <gps.h>
#include "chip.h"

class Transceiver : public Task, public Chip
{
private:
RH_RF69 *driver;
uint8_t *buffer;
Barometer *barometer;
GPS *gps;
long measurements_delay;
long previous_time = 0;

public:
Transceiver(int RFM69_CS, int RFM69_INT);
Transceiver(int RFM69_CS, int RFM69_INT, Barometer *barometer, GPS *gps, long measurements_delay);
~Transceiver();

bool measurementsReady();

// Task virtual methods
bool Callback();
bool OnEnable();
Expand Down
44 changes: 39 additions & 5 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ platform = ststm32@13.0.0
board = haloship
framework = arduino
upload_protocol = stlink
; upload_protocol = dfu
debug_tool = stlink
debug_speed = 480
build_flags =
Expand All @@ -26,14 +25,14 @@ lib_deps =
adafruit/Adafruit LPS2X @ ^2.0.1
lowpowerlab/SPIFlash @ ^101.1.3
https://github.com/haloship/RadioHead.git
; https://github.com/haloship/bmx055.git
; sparkfun/SparkFun u-blox GNSS Arduino Library@^2.0.5
lib_extra_dirs=
niniack/BMX055@^0.1.0
sparkfun/SparkFun u-blox GNSS Arduino Library@^2.0.5
lib_extra_dirs =
/home/dunstan/git/bmx055
lib_ldf_mode = deep

[env:feather]
platform = ststm32
platform = ststm32@13.0.0
board = adafruit_feather_f405
framework = arduino
upload_protocol = dfu
Expand All @@ -44,9 +43,43 @@ build_flags =
-D FEATHER_BOARD
-Wall
lib_deps =
arkhipenko/TaskScheduler @ ^3.2.2
robtillaart/PCA9635 @ ^0.3.1
https://github.com/haloship/RadioHead.git
lowpowerlab/SPIFlash @ ^101.1.3
adafruit/Adafruit LPS2X@^2.0.1
sparkfun/SparkFun u-blox GNSS Arduino Library@^2.0.5
# niniack/BMX055@^0.1.0
https://github.com/haloship/bmx055.git
lib_extra_dirs =
# /home/takumi/Development/Haloship/flight-software/lib
# /home/dunstan/git/bmx055
lib_ldf_mode = deep

# [env:feather_ground]
# platform = ststm32@13.0.0
# board = adafruit_feather_f405
# framework = arduino
# upload_protocol = dfu
# build_flags =
# -D PIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF
# -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
# -D USBCON
# -D FEATHER_BOARD_GROUND
# -Wall
# lib_deps =
# arkhipenko/TaskScheduler @ ^3.2.2
# robtillaart/PCA9635 @ ^0.3.1
# https://github.com/haloship/RadioHead.git
# lowpowerlab/SPIFlash @ ^101.1.3
# adafruit/Adafruit LPS2X@^2.0.1
# # sparkfun/SparkFun u-blox GNSS Arduino Library@^2.0.5
# # niniack/BMX055@^0.1.0
# https://github.com/haloship/bmx055.git
# lib_extra_dirs =
# # /home/takumi/Development/Haloship/flight-software/lib
# # /home/dunstan/git/bmx055
# lib_ldf_mode = deep

[env:nucleo]
platform = ststm32
Expand All @@ -60,3 +93,4 @@ lib_deps =
https://github.com/haloship/RadioHead.git
adafruit/Adafruit LPS2X@^2.0.1
sparkfun/SparkFun u-blox GNSS Arduino Library@^2.0.5
niniack/BMX055@^0.1.0
25 changes: 18 additions & 7 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
#define CONFIG_H

#include <Arduino.h>
#include <Servo.h>
#include <Wire.h>
#include <buzzer.h>
#include <pwm.h>
#include <lps25hb.h>
#include <rfm69.h>
#include <TaskScheduler.h>
#include <gps.h>

#include <Servo.h>
#include <pwm.h>
#include <blink.h>
#include <imu.h>
#include <flash.h>
#include <TaskScheduler.h>

// #define BUZZER PC3

#if defined(HALOSHIP)

Expand Down Expand Up @@ -47,10 +52,16 @@
#endif

// // RFM69 pin definition for stm32F4
// #if defined (FEATHER_BOARD) // Defined in Arduino framework
// #define RFM69_INT PC6 //
// #define RFM69_CS PB9 //
// #define RFM69_RST PB8 // "A"
#if defined(FEATHER_BOARD) // Defined in Arduino framework
#define RFM69_INT PC6 //
#define RFM69_CS PB9 //
#define RFM69_RST PB8 // "A"
#define LPS_CS PC7
#define LPS_SCK PB13
#define LPS_MISO PB14
#define LPS_MOSI PB15
#endif

// #define LED PC1

// // LPS25 pin definition
Expand Down
Loading