Skip to content

PWM Driver

Doug edited this page Dec 24, 2021 · 2 revisions

PWM Driver

This driver controls both eyes (LED's) and the jaw (a SERVO). The eyes are driven with a 'fast' clock at LED_FREQ (set in config.h) (500 hz at last check). The servo is inherently designed for a 50 hz signal, and is driven with a 'slow' clock. Additional devices, both LED's and SERVOS, could be added in the future.

This class inherits the Device base class, and defines a callback routine which is how the SwitchBoard will deliver messages to the driver.

Since the only thing we need to do is set the duty cycle, this action is taken inside the callback routine.

This driver serves two devices - the 'EYES' and the 'JAW'.

The following EVENTS are implemented:

  • EVENT_ACTION_SETVALUE: Set the EYE (or JAW) to a percentage value (range 0 thru 100). As expected, 0 is dark (eyes) or closed (jaw), 100 is max brightness or max jaw open. For the EYES, the first value is the left eye, the second value is the right eye setting. For the JAW, the first value is the position of the jaw to be used.
  • EVENT_ACTION_SET_EYEDIR: For the EYES only, the first value modifies left eye, the second modifies the RIGHT eye. This variation will give the illusion that the skull is looking in a particular direction. The values represent a percentage - 0 is blackout, 100 is max.

Note that the values will have to be be scaled appropriately for each device to give a near-linear reaction to a command.

Clone this wiki locally