Update Payload_BME280_MPU6050_XS_Extended.ino cleanup - removing extra code

pull/295/head
Alan Johnston 2 years ago committed by GitHub
parent 93181451e5
commit 4e263ecc28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,6 @@
// code for Pico or Pro Micro or STM32 on the CubeSat Simulator STEM Payload board // code for Pico or Pro Micro or STM32 on the CubeSat Simulator STEM Payload board
// works wih CubeSatSim software v1.3.2 or later // works wih CubeSatSim software v1.3.2 or later
// extra sensors can be added in payload_extension.cpp // extra sensors can be added in payload_extension.cpp file
#include <Wire.h> #include <Wire.h>
#include <Adafruit_Sensor.h> #include <Adafruit_Sensor.h>
@ -8,7 +8,7 @@
#include <MPU6050_tockn.h> #include <MPU6050_tockn.h>
#include <TinyGPS++.h> #include <TinyGPS++.h>
#ifdef ARDUINO_ARCH_RP2040 #ifdef ARDUINO_ARCH_RP2040
UART Serial2(8, 9, 0, 0); //UART Serial2(8, 9, 0, 0);
#else #else
#include <EEPROM.h> #include <EEPROM.h>
#endif #endif
@ -31,10 +31,10 @@ void ee_prom_word_write(int addr, int val);
short ee_prom_word_read(int addr); short ee_prom_word_read(int addr);
int first_time = true; int first_time = true;
int first_read = true; int first_read = true;
bool check_for_wifi(); //bool check_for_wifi();
bool wifi = false; //bool wifi = false;
int led_builtin_pin; //int led_builtin_pin;
#define PICO_W // define if Pico W board. Otherwise, compilation fail for Pico or runtime fail if compile as Pico W //#define PICO_W // define if Pico W board. Otherwise, compilation fail for Pico or runtime fail if compile as Pico W
#if defined ARDUINO_ARCH_RP2040 #if defined ARDUINO_ARCH_RP2040
float T2 = 26.3; // Temperature data point 1 float T2 = 26.3; // Temperature data point 1
@ -69,18 +69,10 @@ extern void payload_setup(); // sensor extension setup function defined in payl
extern void payload_loop(); // sensor extension read function defined in payload_extension.cpp extern void payload_loop(); // sensor extension read function defined in payload_extension.cpp
void setup() { void setup() {
#ifdef ARDUINO_ARCH_RP2040
// Serial1.setRX(1);
// delay(100);
// Serial1.setTX(0);
// delay(100);
#endif
Serial.begin(115200); // Serial Monitor for testing Serial.begin(115200); // Serial Monitor for testing
Serial1.begin(115200); // Pi UART faster spd Serial1.begin(115200); // for communication with Pi Zero
// Serial1.begin(9600); // Pi UART faster spd
delay(10000); delay(10000);
@ -90,11 +82,10 @@ void setup() {
Serial.println("This code is for the Raspberry Pi Pico hardware."); Serial.println("This code is for the Raspberry Pi Pico hardware.");
Serial.println("Starting Serial2 for optional GPS on JP12"); Serial.println("Starting Serial2 for optional GPS on JP12");
// Serial2.begin(9600); // serial from - some modules need 115200 // Serial2.begin(9600); // serial from - some modules need 115200
UART Serial2(8, 9, 0, 0);
Serial2.begin(9600); // serial from GPS or other serial sensor. Some GPS need 115200
// pinMode(0, INPUT);
// pinMode(1, INPUT);
// set all Pico GPIO connected pins to input // set all Pico GPIO connected pins to input
for (int i = 6; i < 22; i++) { for (int i = 6; i < 22; i++) {
pinMode(i, INPUT); pinMode(i, INPUT);
@ -144,13 +135,10 @@ void setup() {
} }
else else
{ {
#ifdef ARDUINO_ARCH_RP2040
Serial.println("Calculating gyro offsets\n"); Serial.println("Calculating gyro offsets\n");
mpu6050.calcGyroOffsets(true); mpu6050.calcGyroOffsets(true);
#endif #ifndef ARDUINO_ARCH_RP2040
#ifndef ARDUINO_ARCH_RP2040 Serial.println("Storing gyro offsets in EEPROM\n");
Serial.println("Calculating gyro offsets and storing in EEPROM\n");
mpu6050.calcGyroOffsets(true);
eeprom_word_write(0, 0xA07); eeprom_word_write(0, 0xA07);
eeprom_word_write(1, (int)(mpu6050.getGyroXoffset() * 100.0) + 0.5); eeprom_word_write(1, (int)(mpu6050.getGyroXoffset() * 100.0) + 0.5);
@ -374,11 +362,11 @@ void blink_setup()
led_builtin_pin = 25; // manually set GPIO 25 for Pico board led_builtin_pin = 25; // manually set GPIO 25 for Pico board
// pinMode(25, OUTPUT); // pinMode(25, OUTPUT);
*/ */
led_builtin_pin = LED_BUILTIN; // use default GPIO for Pico W // led_builtin_pin = LED_BUILTIN; // use default GPIO for Pico W
pinMode(LED_BUILTIN, OUTPUT); pinMode(LED_BUILTIN, OUTPUT);
wifi = true; // wifi = true;
pinMode(18, OUTPUT); pinMode(18, OUTPUT); // blue LED on STEM Payload Board v1.3.2
pinMode(19, OUTPUT); pinMode(19, OUTPUT); // green LED on STEM Payload Board v1.3.2
// } // }
#endif #endif
@ -396,10 +384,10 @@ void blink(int length)
#endif #endif
#if defined ARDUINO_ARCH_RP2040 #if defined ARDUINO_ARCH_RP2040
if (wifi) // if (wifi)
digitalWrite(LED_BUILTIN, HIGH); // set the built-in LED ON digitalWrite(LED_BUILTIN, HIGH); // set the built-in LED ON
else // else
digitalWrite(led_builtin_pin, HIGH); // set the built-in LED ON // digitalWrite(led_builtin_pin, HIGH); // set the built-in LED ON
#endif #endif
#if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4) #if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4)
@ -412,10 +400,10 @@ void blink(int length)
#endif #endif
#if defined ARDUINO_ARCH_RP2040 #if defined ARDUINO_ARCH_RP2040
if (wifi) // if (wifi)
digitalWrite(LED_BUILTIN, LOW); // set the built-in LED OFF digitalWrite(LED_BUILTIN, LOW); // set the built-in LED OFF
else // else
digitalWrite(led_builtin_pin, LOW); // set the built-in LED OFF // digitalWrite(led_builtin_pin, LOW); // set the built-in LED OFF
// delay(length); // wait for a lenth of time // delay(length); // wait for a lenth of time
#endif #endif
@ -458,12 +446,12 @@ int read_analog()
#endif #endif
return(sensorValue); return(sensorValue);
} }
/*
bool check_for_wifi() { bool check_for_wifi() {
#ifndef PICO_W #ifndef PICO_W
Serial.println("WiFi disabled in software"); Serial.println("WiFi disafbled in software");
return(false); // skip check if not Pico W board or compilation will fail return(false); // skip check if not Pico W board or compilation will fail
#endif #endif
@ -488,7 +476,7 @@ bool check_for_wifi() {
return(false); return(false);
} }
} }
*/
void get_gps() { void get_gps() {
//#ifndef ARDUINO_ARCH_RP2040 //#ifndef ARDUINO_ARCH_RP2040
bool newData = false; bool newData = false;

Loading…
Cancel
Save

Powered by TurnKey Linux.