2026-05-16 (3UE*2): Exercise Polymorphic Types ============================================== * Based on the demo in :doc:`2026-05-11`, rearrange the ``PMWPin`` side of ``Logic`` in a way that: * ``PWMPin`` constitutes an *interface* * The original ``PWMPin`` *concrete implementation* is renamed to ``LinuxSysfsPWMPin`` * ``LinuxSysfsPWMPin`` *implements* the ``PWMPin`` interface * ``Logic`` *uses* the interface, ``PWMPin`` * Modify ``main.cpp`` in a way that the "real" hardware implementations ``LinuxSysfsPWMPin`` and ``LinuxHWMONSensor`` are not instantiated. Rather, instantiate ``MockSensor`` and ``StdoutPWMPin``, and pass these to ``Logic``. When everything is well, you should see whatever you wrote in your ``StdoutPWMPin`` implementation. .. plantuml:: @startuml interface Sensor { + double get_temperature() } interface PWMPin { + void set_duty_cycle(uint64_t) + void set_period(uint64_t) } class LinuxSysfsPWMPin {} PWMPin <|.. LinuxSysfsPWMPin class StdoutPWMPin {} PWMPin <|.. StdoutPWMPin note bottom of StdoutPWMPin: writes new period/duty_cycle to std::cout class Logic { + void loop() } Logic -l-> Sensor Logic -r-> PWMPin @enduml