JanWielgus / STM_FlightController

0 stars 0 forks source link

Create interfaces for gyro, acc, etc.. (sensors generally) #65

Open JanWielgus opened 4 years ago

JanWielgus commented 4 years ago

Create interfaces for sensors, but only for obtaining data and other things common if sensor would change (for example cannot be getReadings() method because MPU6050 has both gyro and acc readings but there could be two separate sensors)

Some example methods for 3 axis sensors (acc, gyro, for separate interface for each one!):

Sensors like barometer will have similar but separate interface for one axis data

In the end there is no need to use adapter design pattern for gyro and acc. AHRS could receive pointers to IGyro and IAccelerometer instances. This make code more flexible and less coupled.

JanWielgus commented 4 years ago

This could be tough but think about some more general interfaces. Problem is for example with general calibration method because MPU6050 class will implement both acc and gyro interface so general calibrate() method will have to calibrate both (which cannot be, these sensors have to be calibrated separately)

JanWielgus commented 4 years ago

This could be tough but think about some more general interfaces. Problem is for example with general calibration method because MPU6050 class will implement both acc and gyro interface so general calibrate() method will have to calibrate both (which cannot be, these sensors have to be calibrated separately)

Maybe make just general interface for gyro, separate for acc, for baro, gps etc. Of course there will be some important methods that interface won't cover, so make original-type instances in code and pass them by pointers or references wherever needed