Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
caila-marashaj committed Jan 4, 2024
1 parent 7a82f63 commit 6b98075
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 37 deletions.
33 changes: 14 additions & 19 deletions include/sensors/core/tasks/pressure_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ template <class I2CQueueWriter, class I2CQueuePoller,
class MMR920 {
public:
MMR920(I2CQueueWriter &writer, I2CQueuePoller &poller,
CanClient &can_client, OwnQueue &own_queue,
sensors::hardware::SensorHardwareBase &hardware,
const can::ids::SensorId &id)
CanClient &can_client, OwnQueue &own_queue,
sensors::hardware::SensorHardwareBase &hardware,
const can::ids::SensorId &id)
: writer(writer),
poller(poller),
can_client(can_client),
Expand All @@ -50,9 +50,7 @@ class MMR920 {
*/
[[nodiscard]] auto initialized() const -> bool { return _initialized; }

auto register_map() -> mmr920::MMR920RegisterMap & {
return _registers;
}
auto register_map() -> mmr920::MMR920RegisterMap & { return _registers; }

auto get_sensor_type() -> SensorType { return SensorType::pressure; }

Expand Down Expand Up @@ -161,8 +159,8 @@ class MMR920 {
}

poller.continuous_single_register_poll(
mmr920::ADDRESS, command_data, 3, mode_delay_with_buffer,
own_queue, utils::build_id(mmr920::ADDRESS, command_data, tags));
mmr920::ADDRESS, command_data, 3, mode_delay_with_buffer, own_queue,
utils::build_id(mmr920::ADDRESS, command_data, tags));
}

auto poll_continuous_temperature(uint8_t tags) -> void {
Expand All @@ -173,8 +171,8 @@ class MMR920 {
build_register_command(_registers.temperature_command);

poller.continuous_single_register_poll(
mmr920::ADDRESS, command_data, 3, mode_delay_with_buffer,
own_queue, utils::build_id(mmr920::ADDRESS, command_data, tags));
mmr920::ADDRESS, command_data, 3, mode_delay_with_buffer, own_queue,
utils::build_id(mmr920::ADDRESS, command_data, tags));
}

auto set_measure_mode(mmr920::MeasurementRate rate) -> bool {
Expand Down Expand Up @@ -233,8 +231,8 @@ class MMR920 {
}

auto send_status(uint32_t message_index) -> void {
auto status = mmr920::StatusResult::to_status(
_registers.status_result.reading);
auto status =
mmr920::StatusResult::to_status(_registers.status_result.reading);
auto message = can::messages::ReadFromSensorResponse{
.message_index = message_index,
.sensor = get_sensor_type(),
Expand Down Expand Up @@ -267,9 +265,8 @@ class MMR920 {
}

void stop_continuous_polling(uint32_t transaction_id, uint8_t reg_id) {
poller.continuous_single_register_poll(mmr920::ADDRESS, reg_id, 3,
STOP_DELAY, own_queue,
transaction_id);
poller.continuous_single_register_poll(
mmr920::ADDRESS, reg_id, 3, STOP_DELAY, own_queue, transaction_id);
}

auto handle_ongoing_pressure_response(i2c::messages::TransactionResponse &m)
Expand Down Expand Up @@ -335,8 +332,7 @@ class MMR920 {
.message_index = m.message_index,
.sensor = can::ids::SensorType::pressure,
.sensor_id = sensor_id,
.sensor_data =
mmr920::reading_to_fixed_point(pressure)});
.sensor_data = mmr920::reading_to_fixed_point(pressure)});
}
}

Expand Down Expand Up @@ -378,8 +374,7 @@ class MMR920 {

uint32_t shifted_data_store = temporary_data_store >> 8;

auto pressure =
mmr920::PressureResult::to_pressure(shifted_data_store);
auto pressure = mmr920::PressureResult::to_pressure(shifted_data_store);
pressure_running_total += pressure;

if (!m.id.is_completed_poll) {
Expand Down
6 changes: 2 additions & 4 deletions include/sensors/simulation/mmr920C04.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ class MMR920 : public I2CRegisterMap<uint8_t, uint32_t> {
mmr920::ADDRESS,
{{static_cast<uint8_t>(mmr920::Registers::STATUS), 0xED},
{static_cast<uint8_t>(mmr920::Registers::MEASURE_MODE_1), 0},
{static_cast<uint8_t>(mmr920::Registers::PRESSURE_READ),
6000},
{static_cast<uint8_t>(
mmr920::Registers::LOW_PASS_PRESSURE_READ),
{static_cast<uint8_t>(mmr920::Registers::PRESSURE_READ), 6000},
{static_cast<uint8_t>(mmr920::Registers::LOW_PASS_PRESSURE_READ),
6000},
{static_cast<uint8_t>(mmr920::Registers::TEMPERATURE_READ),
3200}}) {}
Expand Down
6 changes: 2 additions & 4 deletions pipettes/simulator/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,8 @@ int main(int argc, char** argv) {
auto fake_sensor_hw_secondary =
std::make_shared<sim_mocks::MockSensorHardware>();
fake_sensor_hw_secondary->provide_state_manager(state_manager_connection);
auto pressuresensor_i2c1 =
std::make_shared<mmr920_simulator::MMR920>();
auto pressuresensor_i2c3 =
std::make_shared<mmr920_simulator::MMR920>();
auto pressuresensor_i2c1 = std::make_shared<mmr920_simulator::MMR920>();
auto pressuresensor_i2c3 = std::make_shared<mmr920_simulator::MMR920>();
i2c::hardware::SimI2C::DeviceMap sensor_map_i2c1 = {
{hdcsensor->get_address(), *hdcsensor},
{pressuresensor_i2c1->get_address(), *pressuresensor_i2c1}};
Expand Down
12 changes: 6 additions & 6 deletions sensors/tests/test_pressure_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ SCENARIO("Testing the pressure sensor driver") {
queue_client.set_queue(&can_queue);
writer.set_queue(&i2c_queue);
poller.set_queue(&i2c_poll_queue);
sensors::tasks::MMR920 driver(writer, poller, queue_client,
pressure_queue, hardware, sensor_id);
sensors::tasks::MMR920 driver(writer, poller, queue_client, pressure_queue,
hardware, sensor_id);

can::message_writer_task::TaskMessage empty_can_msg{};

Expand All @@ -69,8 +69,8 @@ SCENARIO("Testing the pressure sensor driver") {
i2c::messages::TransactionIdentifier{
.token = sensors::utils::build_id(
sensors::mmr920::ADDRESS,
static_cast<uint8_t>(sensors::mmr920::Registers::
LOW_PASS_PRESSURE_READ),
static_cast<uint8_t>(
sensors::mmr920::Registers::LOW_PASS_PRESSURE_READ),
0x1),
.is_completed_poll = 1,
.transaction_index = 0},
Expand Down Expand Up @@ -137,8 +137,8 @@ SCENARIO("Testing the pressure sensor driver") {
i2c::messages::TransactionIdentifier{
.token = sensors::utils::build_id(
sensors::mmr920::ADDRESS,
static_cast<uint8_t>(sensors::mmr920::Registers::
LOW_PASS_PRESSURE_READ),
static_cast<uint8_t>(
sensors::mmr920::Registers::LOW_PASS_PRESSURE_READ),
sensors::utils::byte_from_tags(tags_for_baseline)),
.is_completed_poll = 1,
.transaction_index = 0},
Expand Down
7 changes: 3 additions & 4 deletions sensors/tests/test_pressure_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ SCENARIO("Receiving messages through the pressure sensor message handler") {
i2c::messages::TransactionIdentifier{
.token = sensors::utils::build_id(
sensors::mmr920::ADDRESS,
static_cast<uint8_t>(sensors::mmr920::Registers::
LOW_PASS_PRESSURE_READ),
static_cast<uint8_t>(
sensors::mmr920::Registers::LOW_PASS_PRESSURE_READ),
0x1),
.is_completed_poll = 1,
.transaction_index = 0},
Expand Down Expand Up @@ -139,8 +139,7 @@ SCENARIO("Receiving messages through the pressure sensor message handler") {
sensors::utils::ResponseTag::IS_THRESHOLD_SENSE};
response_details.id.token = sensors::utils::build_id(
sensors::mmr920::ADDRESS,
static_cast<uint8_t>(
sensors::mmr920::Registers::MACRAM_WRITE),
static_cast<uint8_t>(sensors::mmr920::Registers::MACRAM_WRITE),
sensors::utils::byte_from_tags(tags_for_baseline));
auto response_read = sensors::utils::TaskMessage(response_details);
sensor.handle_message(response_read);
Expand Down

0 comments on commit 6b98075

Please sign in to comment.