Skip to content

Commit

Permalink
🐛 fixes read functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
acarrou committed Oct 2, 2023
1 parent 3882abe commit 2b89e32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
19 changes: 8 additions & 11 deletions demos/applications/telemetry-recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@ hal::status application(hardware_map& p_map)
// Device initialization
auto micro_sd =
HAL_CHECK(hal::microsd::microsd_card::create(spi2, chip_select));
(void)hal::delay(clock, 200ms);
(void)hal::delay(clock, 100ms);
auto neoGPS = HAL_CHECK(hal::neo::neo_GPS::create(gps));
(void)hal::delay(clock, 200ms);
(void)hal::delay(clock, 100ms);
auto xbee_module = HAL_CHECK(hal::xbee::xbee_radio::create(xbee));
(void)hal::delay(clock, 200ms);
(void)hal::delay(clock, 100ms);
auto mpl_device = HAL_CHECK(hal::mpl::mpl3115a2::create(i2c));
(void)hal::delay(clock, 200ms);
(void)hal::delay(clock, 100ms);
auto icm_device = HAL_CHECK(hal::icm::icm20948::create(i2c, 0x69));
(void)hal::delay(clock, 200ms);
hal::delay(clock, 500ms);
(void)hal::delay(clock, 100ms);

// device configuration
icm_device.auto_offsets();
Expand All @@ -67,7 +66,6 @@ hal::status application(hardware_map& p_map)
auto telemetry_recorder =
HAL_CHECK(hal::telemetry_recorder::telemetry_recorder::create(
icm_device, neoGPS, mpl_device, micro_sd, xbee_module));
hal::delay(clock, 500ms);

while (true) {
hal::print(console, "\n=================== Data ===================\n");
Expand Down Expand Up @@ -117,11 +115,10 @@ hal::status application(hardware_map& p_map)

hal::print(console, "Recieveing Data from Ground Station...\n\n");
auto recieved_data = HAL_CHECK(telemetry_recorder.recieve());
hal::print(console,
"\n=================== RECIEVED DATA ===================\n");
hal::print(console, "\n=================== RECIEVED DATA ===================\n");
hal::print(console, recieved_data);
hal::print(console,
"======================================================\n\n");
hal::print(console, "======================================================\n\n");

}

return hal::success();
Expand Down
21 changes: 6 additions & 15 deletions src/telemetry-recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,13 @@ result<telemetry_recorder> telemetry_recorder::create(

hal::result<telemetry_recorder::telemetry_data> telemetry_recorder::record()
{
auto accel_result = m_icm->read_acceleration();
auto gyro_result = m_icm->read_gyroscope();
auto imu_temp_result = m_icm->read_temperature();

auto accel = HAL_CHECK(m_icm->read_acceleration());
auto gyro = HAL_CHECK(m_icm->read_gyroscope());
auto imu_temp = HAL_CHECK(m_icm->read_temperature());
auto gps = HAL_CHECK(m_gps->read());

auto baro_temp_result = m_mpl->read_temperature();
auto pressure_result = m_mpl->read_pressure();
auto altitude_result = m_mpl->read_altitude();

auto accel = *accel_result;
auto gyro = *gyro_result;
auto imu_temp = *imu_temp_result;
auto baro_temp = *baro_temp_result;
auto pressure = *pressure_result;
auto altitude = *altitude_result;
auto baro_temp = HAL_CHECK(m_mpl->read_temperature());
auto pressure = HAL_CHECK(m_mpl->read_pressure());
auto altitude = HAL_CHECK(m_mpl->read_altitude());

m_data.accel_x = accel.x;
m_data.accel_y = accel.y;
Expand Down

0 comments on commit 2b89e32

Please sign in to comment.