Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
PCA9685PWM.cxx
Go to the documentation of this file.
1
34#include "PCA9685PWM.hxx"
35
36//
37// entry()
38//
40{
41 for ( ; /* forever */ ; )
42 {
43 sem_.wait();
44 uint16_t dirty_shaddow = dirty_;
45 dirty_ = 0;
46
47 for (unsigned i = 0; i < NUM_CHANNELS; ++i)
48 {
49 if (dirty_shaddow & (0x1 << i))
50 {
51 write_pwm_duty(i, duty_[i]);
52 }
53 }
54 }
55
56 return NULL;
57}
58
void wait()
Wait on (decrement) a semaphore.
Definition OS.hxx:279
static constexpr size_t NUM_CHANNELS
maximum number of PWM channels supported by the PCA9685
OSSem sem_
Wakeup for the thread processing.
void write_pwm_duty(unsigned channel, uint16_t counts)
Set the pwm duty cycle.
std::array< uint16_t, NUM_CHANNELS > duty_
local cache of the duty cycles
uint16_t dirty_
set if the duty_ value is updated (bit mask)
void * entry() override
User entry point for the created thread.