102
edits
No edit summary |
|||
Line 73: | Line 73: | ||
return ret; | return ret; | ||
} | |||
</syntaxhighlight> | |||
== Add the New Sensor to ISensor == | |||
* Add constructor method to the new sensor header file. | |||
* Extend the Sensors enumeration with the new IMU sensor. | |||
* Add the new sensor to the ISensor Build method. | |||
=== Add constructor method === | |||
<syntaxhighlight lang=c++> | |||
class NewSensorExample : public ISensor { | |||
public: | |||
explicit NewSensorExample(std::shared_ptr<SensorSettings> settings); | |||
/* Rest of class */ | |||
} | |||
</syntaxhighlight> | |||
=== Extend the Sensor enumeration === | |||
<syntaxhighlight lang=c++> | |||
enum class Sensors { | |||
kRb5Imu = 0, | |||
kBmi160 = 0, | |||
/* Add new sensor */ | |||
kNewSensorExample = 0 | |||
}; | |||
</syntaxhighlight> | |||
=== Add New Sensor to ISensor Build method=== | |||
<syntaxhighlight lang=c++> | |||
std::shared_ptr<ISensor> ISensor::Build( | |||
const Sensors sensor, const std::shared_ptr<SensorSettings> settings) { | |||
switch (sensor) { | |||
case Sensors::kRb5Imu: | |||
return std::make_shared<Rb5Imu>(settings); | |||
case Sensors::kBmi160: | |||
return std::make_shared<Bmi160>(settings); | |||
default: | |||
return nullptr; | |||
} | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
edits