Temperature Display: LED Via A PWM Controller#
Standup Records#
2023-11-20#
- Use raw file IO (see :doc: Files And File Descriptors) 
- Do not do the - export(making- /sys/class/pwm/pwmchip0/pwm0available to userspace) dance; rather place that responsibility on a “system-setup phase” (that we don’t have).- “System setup” will have to be done manually before an application run. At the time that this becomes too cumbersome, define how we want it. 
- Look out for something like - class PercentageDisplay { public: // ... virtual void show_percentage(unsigned int) = 0; // ... }; 
- Refactoring round (just like (DONE) Switch Interface): put everything display-like under its hood 
2023-12-14#
- src_demos/? Move things to- toolcase/base/!
- What’s the relationship between, e.g. - src_demos/LEDStripeDisplay.hand- toolcase/base/display-led-stripe.h
- src_demos/PWMDisplay.hand- toolcase/base/pwm_controller.h
 - ⟶ unify! 
Requirements#
Implement a class that implements PWM control according to PWM Userspace Interface (using PCA9685).
When done, try hard to unify (by defining an interface that both
implement) that class with the LEDStripeDisplay that we have in
our project. Hint: both are used to show percentages.
Implementation#
- Write a - class PWMDisplaythat has methods- (Constructor). Configures the PWM channel; parameters - channel(- int) and- period(- unsigned long?).- Export the PWM channel. Write - 5(or whatever the channel is) into- /sys/class/pwm/export. Note that one has to wait a bit until the- pwm5directory becomes visible.
- Configure the period. Write - 10000000(or whatever- periodwas configured) into the- periodfile.
 
- void set_percentage(unsigned long percentage);- Compute the appropriate duty cycle and write that into the - duty_cyclefile.
- Use unbuffered IO, like in Files And File Descriptors, and in the exercise Exercise: Copy A File 
 
Testing#
It is hard to come up with automatic tests for real hardware. (Although the file operations could somehow be verified.)
Write a test program in bin/ that you use interactively/manually.
Future (Not Part Of This Development Cycle)#
(None)
