added payload_OK_only() for when Pi present

pico-v0.1
alanbjohnston 3 years ago committed by GitHub
parent 1844c7c232
commit eac4d5b7b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -55,6 +55,16 @@ void setup() {
config_gpio();
pinMode(PI_3V3_PIN, INPUT);
Serial.print("Pi 3.3V: ");
Serial.println(digitalRead(PI_3V3_PIN));
if (digitalRead(PI_3V3_PIN) == LOW) {
Serial.print("Pi Zero present, so running Payload OK code instead of CubeSatSim code.");
start_payload();
while(true) {
payload_OK_only();
}
}
read_reset_count();
// mode = FSK; // AFSK;
@ -2272,6 +2282,194 @@ void read_payload()
// delay(100);
}
void payload_OK_only()
{
payload_str[0] = '\0'; // clear the payload string
if ((Serial.available() > 0)|| first_time == true) // commented back in
{
blink(50);
char result = Serial.read();
char header[] = "OK BME280 ";
char str[100];
strcpy(payload_str, header);
// print_string(str);
if (bmePresent)
// sprintf(str, "%4.2f %6.2f %6.2f %5.2f ",
sprintf(str, "%.1f %.2f %.1f %.2f ",
bme.readTemperature(), bme.readPressure() / 100.0, bme.readAltitude(SEALEVELPRESSURE_HPA), bme.readHumidity());
else
sprintf(str, "OK BME280 0.0 0.0 0.0 0.0 ");
strcat(payload_str, str);
if (mpuPresent) {
// print_string(payload_str);
mpu6050.update();
// sprintf(str, " MPU6050 %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f ",
sprintf(str, " MPU6050 %.1f %.1f %.1f %.1f %.1f %.1f ",
mpu6050.getGyroX(), mpu6050.getGyroY(), mpu6050.getGyroZ(), mpu6050.getAccX(), mpu6050.getAccY(), mpu6050.getAccZ());
strcat(payload_str, str);
// print_string(payload_str);
}
if (result == 'R') {
Serial.println("OK");
delay(100);
first_time = true;
setup();
}
else if (result == 'C') {
Serial.println("Clearing stored gyro offsets in EEPROM\n");
EEPROM.put(0, (float)0.0);
first_time = true;
setup();
}
if ((result == '?') || first_time == true) // commented back in
if (true)
{
first_time = false;
if (bmePresent) {
Serial.print("OK BME280 ");
Serial.print(bme.readTemperature());
Serial.print(" ");
Serial.print(bme.readPressure() / 100.0F);
Serial.print(" ");
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial.print(" ");
Serial.print(bme.readHumidity());
} else
{
Serial.print("OK BME280 0.0 0.0 0.0 0.0");
}
if (mpuPresent) {
mpu6050.update();
Serial.print(" MPU6050 ");
Serial.print(mpu6050.getGyroX());
Serial.print(" ");
Serial.print(mpu6050.getGyroY());
Serial.print(" ");
Serial.print(mpu6050.getGyroZ());
Serial.print(" ");
Serial.print(mpu6050.getAccX());
Serial.print(" ");
Serial.print(mpu6050.getAccY());
Serial.print(" ");
Serial.print(mpu6050.getAccZ());
}
sensorValue = analogRead(A3);
//Serial.println(sensorValue);
Temp = T1 + (sensorValue - R1) *((T2 - T1)/(R2 - R1));
Serial.print(" XS ");
Serial.print(Temp);
Serial.print(" ");
Serial.println(Sensor1);
if (mpuPresent) {
float rotation = sqrt(mpu6050.getGyroX()*mpu6050.getGyroX() + mpu6050.getGyroY()*mpu6050.getGyroY() + mpu6050.getGyroZ()*mpu6050.getGyroZ());
float acceleration = sqrt(mpu6050.getAccX()*mpu6050.getAccX() + mpu6050.getAccY()*mpu6050.getAccY() + mpu6050.getAccZ()*mpu6050.getAccZ());
// Serial.print(rotation);
// Serial.print(" ");
// Serial.println(acceleration);
if (acceleration > 1.2)
led_set(greenLED, HIGH);
else
led_set(greenLED, LOW);
if (rotation > 5)
led_set(blueLED, HIGH);
else
led_set(blueLED, LOW);
}
}
}
if (Serial1.available() > 0) {
blink(50);
char result = Serial1.read();
// Serial1.println(result);
if (result == 'R') {
Serial1.println("OK");
delay(100);
first_read = true;
setup();
}
if (result == '?')
{
if (bmePresent) {
Serial1.print("OK BME280 ");
Serial1.print(bme.readTemperature());
Serial1.print(" ");
Serial1.print(bme.readPressure() / 100.0F);
Serial1.print(" ");
Serial1.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial1.print(" ");
Serial1.print(bme.readHumidity());
} else
{
Serial1.print("OK BME280 0.0 0.0 0.0 0.0");
}
mpu6050.update();
Serial1.print(" MPU6050 ");
Serial1.print(mpu6050.getGyroX());
Serial1.print(" ");
Serial1.print(mpu6050.getGyroY());
Serial1.print(" ");
Serial1.print(mpu6050.getGyroZ());
Serial1.print(" ");
Serial1.print(mpu6050.getAccX());
Serial1.print(" ");
Serial1.print(mpu6050.getAccY());
Serial1.print(" ");
Serial1.print(mpu6050.getAccZ());
sensorValue = analogRead(A3);
//Serial.println(sensorValue);
Temp = T1 + (sensorValue - R1) *((T2 - T1)/(R2 - R1));
Serial1.print(" XS ");
Serial1.print(Temp);
Serial1.print(" ");
Serial1.println(Sensor2);
float rotation = sqrt(mpu6050.getGyroX()*mpu6050.getGyroX() + mpu6050.getGyroY()*mpu6050.getGyroY() + mpu6050.getGyroZ()*mpu6050.getGyroZ());
float acceleration = sqrt(mpu6050.getAccX()*mpu6050.getAccX() + mpu6050.getAccY()*mpu6050.getAccY() + mpu6050.getAccZ()*mpu6050.getAccZ());
// Serial.print(rotation);
// Serial.print(" ");
// Serial.println(acceleration);
if (first_read == true) {
first_read = false;
rest = acceleration;
}
if (acceleration > 1.2 * rest)
led_set(greenLED, HIGH);
else
led_set(greenLED, LOW);
if (rotation > 5)
led_set(blueLED, HIGH);
else
led_set(blueLED, LOW);
}
}
delay(100);
}
/*
void eeprom_word_write(int addr, int val)
{

Loading…
Cancel
Save

Powered by TurnKey Linux.