-
Notifications
You must be signed in to change notification settings - Fork 0
B1 #1
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
Open
stillmant
wants to merge
12
commits into
master
Choose a base branch
from
b1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
B1 #1
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6da7581
test2
stillmant 2e2b0d9
test3
stillmant 01f0c80
test4
stillmant 6308e62
test5
stillmant 4f843cc
test6
stillmant ee0cfee
test6
stillmant dfbcf3d
test7
stillmant 639a2ab
test8
stillmant 2affd23
test9
stillmant 8cfdf29
added example folder, modified travis.yml
stillmant a212a99
moved ino file to folder w/ same name
stillmant 5ce1893
added dependencies
stillmant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/*Main Arduino Sketch*/ | ||
|
||
/*Includes------------------------------------------------------------*/ | ||
#include "sensors.h" | ||
#include "statemachine.h" | ||
#include "calculations.h" | ||
|
||
#include <Arduino.h> | ||
#include <HardwareSerial.h> | ||
#include <i2c_t3.h> | ||
#include <SD.h> | ||
|
||
/*Variables------------------------------------------------------------*/ | ||
File radiolog; | ||
|
||
/*Functions------------------------------------------------------------*/ | ||
/** | ||
* @brief The Arduino setup function | ||
* @param None | ||
* @return None | ||
*/ | ||
void setup() | ||
{ | ||
bool status = true; | ||
|
||
/*init serial comms*/ | ||
#ifdef TESTING | ||
SerialUSB.begin(9600); | ||
while (!SerialUSB) {} //TODO add print in while to see what happens | ||
SerialUSB.println("Initializing..."); | ||
#endif | ||
|
||
/*init I2C bus*/ | ||
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, I2C_RATE_400); //400kHz | ||
Wire.setDefaultTimeout(100000); //100ms | ||
|
||
/*init sensors*/ | ||
status = initSensors() | ||
|
||
error | ||
|
||
/*init interrupts*/ | ||
//attachInterrupt(digitalPinToInterrupt(LAUNCH_INTERRUPT_PIN), launchInterrupt, CHANGE) | ||
|
||
/*if something went wrong spin infinitely, otherwise indicate completion*/ | ||
if (!status) { | ||
#ifdef TESTING | ||
SerialUSB.println("Initialization failed! >:-{"); | ||
#endif | ||
while (1) {} | ||
} else { | ||
pinMode(LED_BUILTIN,OUTPUT); | ||
digitalWrite(LED_BUILTIN,HIGH); | ||
#ifdef TESTING | ||
SerialUSB.println("Initialization complete! :D"); | ||
#endif | ||
} | ||
} | ||
|
||
/** | ||
* @brief The Arduino loop function | ||
* @param None | ||
* @return None | ||
*/ | ||
void loop() | ||
{ | ||
unsigned long timestamp; | ||
static float barometer_data_init = barSensorInit(); | ||
static float baseline_pressure = groundAlt_init(&barometer_data_init); // IF YOU CAN'T DO THIS USE GLOBAL VAR | ||
static unsigned long old_time = 0; //ms | ||
static unsigned long new_time = 0; //ms | ||
unsigned long delta_time; | ||
static uint16_t time_interval = 5000; //ms | ||
float acc_data[ACC_DATA_ARRAY_SIZE], bar_data[BAR_DATA_ARRAY_SIZE], | ||
temp_sensor_data, IMU_data[IMU_DATA_ARRAY_SIZE]; | ||
char GPS_data[GPS_DATA_ARRAY_SIZE][GPS_FIELD_LENGTH]; | ||
static float abs_accel, prev_altitude, altitude, delta_altitude, prev_delta_altitude, ground_altitude; | ||
static FlightStates state = STANDBY; | ||
|
||
if (SerialRadio.available()) { | ||
radiolog.print("Received Message: "); | ||
#ifdef TESTING | ||
SerialUSB.print("Received Message: "); | ||
#endif | ||
while (SerialRadio.available()) { | ||
char command = SerialRadio.read(); | ||
radiolog.print(command); | ||
#ifdef TESTING | ||
SerialUSB.print(command); | ||
#endif | ||
} | ||
} | ||
|
||
new_time = millis(); | ||
if ((new_time - old_time) > time_interval) { | ||
delta_time = new_time - old_time; | ||
old_time = new_time; | ||
pollSensors(×tamp, acc_data, bar_data, &temp_sensor_data, IMU_data, GPS_data); | ||
calculateValues(acc_data, bar_data, &prev_altitude, &altitude, &delta_altitude, &prev_delta_altitude, &baseline_pressure, &delta_time); | ||
stateMachine(&altitude, &delta_altitude, &prev_altitude, bar_data, &baseline_pressure, &ground_altitude, &state); | ||
logData(×tamp, acc_data, bar_data, &temp_sensor_data, IMU_data, GPS_data); | ||
} | ||
|
||
SerialRadio.println(bar_data[0]); | ||
radiolog.print("Sent Message: "); | ||
radiolog.println(bar_data[0]); | ||
#ifdef TESTING | ||
SerialUSB.print("Sent Message: "); | ||
SerialUSB.println(bar_data[0]); | ||
#endif | ||
|
||
#ifdef TESTING | ||
delay(1000); | ||
#endif | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is close, but it needs to be in
examples/avionics/avionics.ino
. For some reason, Arduino wants the sketch to live in a folder of the same name.