Skip to content
Merged
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
25 changes: 23 additions & 2 deletions src/Control Tasks/CameraControlTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ void CameraControlTask::execute()

// handle taking and storing photos
if (sfr::camera::take_photo == true && sfr::camera::powered == true) {
if (!adaCam.takePicture()) {
// extra delay (200 ms default) between commanding photo and triggering capture
if (sfr::camera::start_progress < (sfr::camera::delay_count + 6)) {
sfr::camera::start_progress++;
#ifdef VERBOSE
Serial.println("Photo triggered, delaying additional 100ms");
#endif
} else if (!adaCam.takePicture()) {
#ifdef VERBOSE
Serial.println("Failed to snap!");
#endif
Expand Down Expand Up @@ -206,7 +212,21 @@ void CameraControlTask::execute()
#ifdef VERBOSE
Serial.println("Done writing file");
#endif
sfr::camera::power_setting = (uint8_t)sensor_power_mode_type::off;
if (sfr::camera::images_written == 1) {
if (!adaCam.resumeVideo()) {
#ifdef VERBOSE
Serial.println("Failed to resume ODS frame!");
#endif
sfr::camera::power_setting = (uint8_t)sensor_power_mode_type::off;
} else {
sfr::camera::take_photo = true;
#ifdef VERBOSE
Serial.println("Triggering second activation of optical sensor");
#endif
}
} else {
sfr::camera::power_setting = (uint8_t)sensor_power_mode_type::off;
}
}
}
}
Expand Down Expand Up @@ -244,6 +264,7 @@ void CameraControlTask::camera_shutdown()
pinMode(constants::camera::tx, OUTPUT);
Pins::setPinState(constants::camera::rx, LOW);
Pins::setPinState(constants::camera::tx, LOW);
sfr::camera::start_progress = 0;

// if SD.begin succeeds but camera is never able to snap, reduce SD card power consumption
File file = SD.open("-", FILE_WRITE);
Expand Down
10 changes: 5 additions & 5 deletions src/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace constants {
constexpr uint16_t fault_opcode_max = 0x6100;

} // namespace opcodes
} // namespace rockblock
} // namespace rockblock
namespace temperature {
constexpr int pin = 39;
constexpr int in_sun_val = 30;
Expand All @@ -98,7 +98,7 @@ namespace constants {
constexpr float in_sun_val = 70; // mA
constexpr int load = 30; // load resister value (kOhm)
constexpr float shunt = 0.1; // shunt resistor value (Ohm)
} // namespace current
} // namespace current
namespace masks {
constexpr uint32_t uint32_byte1_mask = 0b11111111000000000000000000000000;
constexpr uint32_t uint32_byte2_mask = 0b00000000111111110000000000000000;
Expand Down Expand Up @@ -248,7 +248,7 @@ namespace constants {
} // namespace battery
namespace camera {
constexpr int power_on_pin = 31;
constexpr int content_length = 64;
constexpr int content_length = 80;
constexpr int bytes_allocated_fragment = 4;
constexpr int tx = 34;
constexpr int rx = 33;
Expand Down Expand Up @@ -293,7 +293,7 @@ namespace constants {
static constexpr unsigned int dynamic_data_start = 10;
static constexpr unsigned int sfr_data_start = 460;
static constexpr unsigned int sfr_store_size = 5;
static constexpr unsigned int sfr_num_fields = 92;
static constexpr unsigned int sfr_num_fields = 93;
static constexpr unsigned int sfr_data_full_offset = sfr_num_fields * sfr_store_size + 4;
static constexpr unsigned int write_age_limit = 95000; // Must be less than 100000

Expand All @@ -304,6 +304,6 @@ namespace constants {
namespace watchdog {
constexpr uint32_t max_period_ms = 10000;
} // namespace watchdog
}; // namespace constants
}; // namespace constants

#endif
5 changes: 3 additions & 2 deletions src/sfr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace sfr {
SFRField<uint8_t> max_stable_gyro_y = SFRField<uint8_t>((0.2 * constants::imu::sfr_resolution), 0x1502, constants::imu::sfr_resolution); // rad/s
SFRField<uint8_t> min_unstable_gyro_x = SFRField<uint8_t>((0.7 * constants::imu::sfr_resolution), 0x1503, constants::imu::sfr_resolution); // rad/s
SFRField<uint8_t> min_unstable_gyro_y = SFRField<uint8_t>((0.7 * constants::imu::sfr_resolution), 0x1504, constants::imu::sfr_resolution); // rad/s
} // namespace detumble
} // namespace detumble
namespace aliveSignal {
// OP Codes 1600
SFRField<bool> downlinked = SFRField<bool>(false, 0x1600);
Expand Down Expand Up @@ -139,6 +139,7 @@ namespace sfr {
SFRField<uint32_t> fragment_number_requested = SFRField<uint32_t>(0, 0x2016);
SFRField<uint32_t> power_start_time = SFRField<uint32_t>(0, 0x2017);
SFRField<uint32_t> power_time = SFRField<uint32_t>(400, 0x2018);
SFRField<uint8_t> delay_count = SFRField<uint8_t>(2, 0x2019);
} // namespace camera
namespace rockblock {
// OP Codes 2100
Expand Down Expand Up @@ -283,4 +284,4 @@ namespace sfr {
SFRField<uint32_t> dynamic_data_age = SFRField<uint32_t>(0, 0x2809);
SFRField<uint32_t> sfr_data_age = SFRField<uint32_t>(0, 0x2810);
} // namespace eeprom
}; // namespace sfr
}; // namespace sfr
3 changes: 2 additions & 1 deletion src/sfr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ namespace sfr {
extern SFRField<uint32_t> fragment_number_requested;
extern SFRField<uint32_t> power_start_time;
extern SFRField<uint32_t> power_time;
extern SFRField<uint8_t> delay_count;
} // namespace camera
namespace rockblock {
// OP Codes 2100
Expand Down Expand Up @@ -286,6 +287,6 @@ namespace sfr {
extern SFRField<uint32_t> dynamic_data_age;
extern SFRField<uint32_t> sfr_data_age;
} // namespace eeprom
}; // namespace sfr
}; // namespace sfr

#endif