mardi 21 juillet 2015

Finding the right C++ design pattern: I2C - ADC - Temperature

I am currently working on my Raspberrry Pi to implement a temperature control. It is pretty simple as it just reads a temperature sensor from an I2C ADC, passes it to an thermistor class which converts the read values into temperature values and a final controller modules which controls a cooler/heater depending on the desired target temperature.

I want to implement this in a smart way using a certain design pattern to support the capability to be modular and generic.

E.g. each class shall be replaceable. So instead of using I2C I like to use SPI, or instead of using the MCPxxxx IC I'd like to use another one. So this involves a lot of abstraction I guess.

Also I'd like to know how all these classes will interact. Will each class hold a reference to another class? Will I create an instance of each class first and then pass it to the appropriate class in charge of controlling the object?

Thanks in advance.

enter image description here

Aucun commentaire:

Enregistrer un commentaire