Skip to content

Commit 681850c

Browse files
authored
Merge pull request #214 from Alpha-CubeSat/take_two
add second ODS capture + delayed first capture
2 parents 2382798 + be9306a commit 681850c

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

src/Control Tasks/CameraControlTask.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,13 @@ void CameraControlTask::execute()
155155

156156
// handle taking and storing photos
157157
if (sfr::camera::take_photo == true && sfr::camera::powered == true) {
158-
if (!adaCam.takePicture()) {
158+
// extra delay (200 ms default) between commanding photo and triggering capture
159+
if (sfr::camera::start_progress < (sfr::camera::delay_count + 6)) {
160+
sfr::camera::start_progress++;
161+
#ifdef VERBOSE
162+
Serial.println("Photo triggered, delaying additional 100ms");
163+
#endif
164+
} else if (!adaCam.takePicture()) {
159165
#ifdef VERBOSE
160166
Serial.println("Failed to snap!");
161167
#endif
@@ -206,7 +212,21 @@ void CameraControlTask::execute()
206212
#ifdef VERBOSE
207213
Serial.println("Done writing file");
208214
#endif
209-
sfr::camera::power_setting = (uint8_t)sensor_power_mode_type::off;
215+
if (sfr::camera::images_written == 1) {
216+
if (!adaCam.resumeVideo()) {
217+
#ifdef VERBOSE
218+
Serial.println("Failed to resume ODS frame!");
219+
#endif
220+
sfr::camera::power_setting = (uint8_t)sensor_power_mode_type::off;
221+
} else {
222+
sfr::camera::take_photo = true;
223+
#ifdef VERBOSE
224+
Serial.println("Triggering second activation of optical sensor");
225+
#endif
226+
}
227+
} else {
228+
sfr::camera::power_setting = (uint8_t)sensor_power_mode_type::off;
229+
}
210230
}
211231
}
212232
}
@@ -244,6 +264,7 @@ void CameraControlTask::camera_shutdown()
244264
pinMode(constants::camera::tx, OUTPUT);
245265
Pins::setPinState(constants::camera::rx, LOW);
246266
Pins::setPinState(constants::camera::tx, LOW);
267+
sfr::camera::start_progress = 0;
247268

248269
// if SD.begin succeeds but camera is never able to snap, reduce SD card power consumption
249270
File file = SD.open("-", FILE_WRITE);

src/constants.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ namespace constants {
8686
constexpr uint16_t fault_opcode_max = 0x6100;
8787

8888
} // namespace opcodes
89-
} // namespace rockblock
89+
} // namespace rockblock
9090
namespace temperature {
9191
constexpr int pin = 39;
9292
constexpr int in_sun_val = 30;
@@ -98,7 +98,7 @@ namespace constants {
9898
constexpr float in_sun_val = 70; // mA
9999
constexpr int load = 30; // load resister value (kOhm)
100100
constexpr float shunt = 0.1; // shunt resistor value (Ohm)
101-
} // namespace current
101+
} // namespace current
102102
namespace masks {
103103
constexpr uint32_t uint32_byte1_mask = 0b11111111000000000000000000000000;
104104
constexpr uint32_t uint32_byte2_mask = 0b00000000111111110000000000000000;
@@ -248,7 +248,7 @@ namespace constants {
248248
} // namespace battery
249249
namespace camera {
250250
constexpr int power_on_pin = 31;
251-
constexpr int content_length = 64;
251+
constexpr int content_length = 80;
252252
constexpr int bytes_allocated_fragment = 4;
253253
constexpr int tx = 34;
254254
constexpr int rx = 33;
@@ -293,7 +293,7 @@ namespace constants {
293293
static constexpr unsigned int dynamic_data_start = 10;
294294
static constexpr unsigned int sfr_data_start = 460;
295295
static constexpr unsigned int sfr_store_size = 5;
296-
static constexpr unsigned int sfr_num_fields = 92;
296+
static constexpr unsigned int sfr_num_fields = 93;
297297
static constexpr unsigned int sfr_data_full_offset = sfr_num_fields * sfr_store_size + 4;
298298
static constexpr unsigned int write_age_limit = 95000; // Must be less than 100000
299299

@@ -304,6 +304,6 @@ namespace constants {
304304
namespace watchdog {
305305
constexpr uint32_t max_period_ms = 10000;
306306
} // namespace watchdog
307-
}; // namespace constants
307+
}; // namespace constants
308308

309309
#endif

src/sfr.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace sfr {
1717
SFRField<uint8_t> max_stable_gyro_y = SFRField<uint8_t>((0.2 * constants::imu::sfr_resolution), 0x1502, constants::imu::sfr_resolution); // rad/s
1818
SFRField<uint8_t> min_unstable_gyro_x = SFRField<uint8_t>((0.7 * constants::imu::sfr_resolution), 0x1503, constants::imu::sfr_resolution); // rad/s
1919
SFRField<uint8_t> min_unstable_gyro_y = SFRField<uint8_t>((0.7 * constants::imu::sfr_resolution), 0x1504, constants::imu::sfr_resolution); // rad/s
20-
} // namespace detumble
20+
} // namespace detumble
2121
namespace aliveSignal {
2222
// OP Codes 1600
2323
SFRField<bool> downlinked = SFRField<bool>(false, 0x1600);
@@ -139,6 +139,7 @@ namespace sfr {
139139
SFRField<uint32_t> fragment_number_requested = SFRField<uint32_t>(0, 0x2016);
140140
SFRField<uint32_t> power_start_time = SFRField<uint32_t>(0, 0x2017);
141141
SFRField<uint32_t> power_time = SFRField<uint32_t>(400, 0x2018);
142+
SFRField<uint8_t> delay_count = SFRField<uint8_t>(2, 0x2019);
142143
} // namespace camera
143144
namespace rockblock {
144145
// OP Codes 2100
@@ -283,4 +284,4 @@ namespace sfr {
283284
SFRField<uint32_t> dynamic_data_age = SFRField<uint32_t>(0, 0x2809);
284285
SFRField<uint32_t> sfr_data_age = SFRField<uint32_t>(0, 0x2810);
285286
} // namespace eeprom
286-
}; // namespace sfr
287+
}; // namespace sfr

src/sfr.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ namespace sfr {
159159
extern SFRField<uint32_t> fragment_number_requested;
160160
extern SFRField<uint32_t> power_start_time;
161161
extern SFRField<uint32_t> power_time;
162+
extern SFRField<uint8_t> delay_count;
162163
} // namespace camera
163164
namespace rockblock {
164165
// OP Codes 2100
@@ -286,6 +287,6 @@ namespace sfr {
286287
extern SFRField<uint32_t> dynamic_data_age;
287288
extern SFRField<uint32_t> sfr_data_age;
288289
} // namespace eeprom
289-
}; // namespace sfr
290+
}; // namespace sfr
290291

291292
#endif

0 commit comments

Comments
 (0)