MY9231/MY9291 Output

FloatOutput support for an MY9231/MY9291 LED driver chain.

Example Usage

// Create the MY9231 Output hub connected to GPIO12 (DI pin) and
// GPIO14 (DCKI pin).
auto *pmy9231 = App.make_my9231_component(12, 14);

See Application::make_my9231_component().

API Reference


class MY9231OutputComponent : public Component

MY9231 float output component.

Public Functions

MY9231OutputComponent(GPIOPin *pin_di, GPIOPin *pin_dcki, uint16_t num_channels = 6, uint8_t num_chips = 2, uint8_t bit_depth = 16, bool update = true)

Construct the component.

  • pin_di: The pin which DI is connected to.
  • pin_dcki: The pin which DCKI is connected to.
  • num_channels: Total number of channels of the whole daisy chain.
  • num_chips: Number of chips in the daisy chain.
  • bit_depth: Bit depth of each channel
  • update: Update/reset duty data at boot (driver will keep configuration after powercycle)

MY9231OutputComponent::Channel *create_channel(uint8_t channel, PowerSupplyComponent *power_supply = nullptr, float max_power = 1.0f)

Get a MY9231 output channel.

The new channel output component.
  • channel: The channel number. (0 is the closest channel)
  • power_supply: The power supply that should be set for this channel. Default: nullptr.
  • max_power: The maximum power output of this channel. Each value will be multiplied by this.

void set_num_channels(uint16_t num_channels)

Manually set the total number of channels. Defaults to 6.

void set_num_chips(uint8_t num_chips)

Manually set the number of chips. Defaults to 2.

void set_bit_depth(uint8_t bit_depth)

Manually set the bit depth. Defaults to 16.

void set_update(bool update)

Manually set duty data update on boot. Defaults is true.

uint16_t get_num_channels() const
uint8_t get_num_chips() const
uint8_t get_bit_depth() const
uint16_t get_max_amount() const
void setup()

Setup the MY9231.

void dump_config()
float get_setup_priority() const

HARDWARE setup_priority.

void loop()

Send new values if they were updated.

Protected Functions

void set_channel_value(uint8_t channel, uint16_t value)
void init_chips(uint8_t cmd)
void write_word(uint16_t value, uint8_t bits)
void send_di_pulses(uint8_t count)

Protected Attributes

GPIOPin *pin_di_
GPIOPin *pin_dcki_
uint8_t bit_depth_
uint16_t num_channels_
uint8_t num_chips_
std::vector<uint16_t> pwm_amounts_
bool update_
class Channel : public output::FloatOutput

Public Functions

Channel(MY9231OutputComponent *parent, uint8_t channel)
void write_state(float state)

Protected Attributes

MY9231OutputComponent *parent_
uint8_t channel_