Temperature Display: LED Via A PWM Controller¶
Standup Records¶
2023-11-20¶
Use raw file IO (see :doc: File I/O: Basics)
Do not do the
export
(making/sys/class/pwm/pwmchip0/pwm0
available 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 totoolcase/base/
!What’s the relationship between, e.g.
src_demos/LEDStripeDisplay.h
andtoolcase/base/display-led-stripe.h
src_demos/PWMDisplay.h
andtoolcase/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 PWMDisplay
that has methods(Constructor). Configures the PWM channel; parameters
channel
(int
) andperiod
(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 thepwm5
directory becomes visible.Configure the period. Write
10000000
(or whateverperiod
was configured) into theperiod
file.
void set_percentage(unsigned long percentage);
Compute the appropriate duty cycle and write that into the
duty_cycle
file.Use unbuffered IO, like in File I/O: Basics, 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)