8 static const char *
const TAG =
"my9231.output";
11 static const uint8_t MY9231_CMD_ONE_SHOT_DISABLE = 0x0 << 6;
12 static const uint8_t MY9231_CMD_ONE_SHOT_ENFORCE = 0x1 << 6;
14 static const uint8_t MY9231_CMD_REACTION_FAST = 0x0 << 5;
15 static const uint8_t MY9231_CMD_REACTION_SLOW = 0x1 << 5;
17 static const uint8_t MY9231_CMD_BIT_WIDTH_16 = 0x0 << 3;
18 static const uint8_t MY9231_CMD_BIT_WIDTH_14 = 0x1 << 3;
19 static const uint8_t MY9231_CMD_BIT_WIDTH_12 = 0x2 << 3;
20 static const uint8_t MY9231_CMD_BIT_WIDTH_8 = 0x3 << 3;
22 static const uint8_t MY9231_CMD_FREQUENCY_DIVIDE_1 = 0x0 << 1;
23 static const uint8_t MY9231_CMD_FREQUENCY_DIVIDE_4 = 0x1 << 1;
24 static const uint8_t MY9231_CMD_FREQUENCY_DIVIDE_16 = 0x2 << 1;
25 static const uint8_t MY9231_CMD_FREQUENCY_DIVIDE_64 = 0x3 << 1;
27 static const uint8_t MY9231_CMD_SCATTER_APDM = 0x0 << 0;
28 static const uint8_t MY9231_CMD_SCATTER_PWM = 0x1 << 0;
31 ESP_LOGCONFIG(TAG,
"Setting up MY9231OutputComponent...");
40 command |= MY9231_CMD_BIT_WIDTH_8;
43 command |= MY9231_CMD_BIT_WIDTH_12;
46 command |= MY9231_CMD_BIT_WIDTH_14;
49 command |= MY9231_CMD_BIT_WIDTH_16;
52 MY9231_CMD_SCATTER_APDM | MY9231_CMD_FREQUENCY_DIVIDE_1 | MY9231_CMD_REACTION_FAST | MY9231_CMD_ONE_SHOT_DISABLE;
53 ESP_LOGV(TAG,
" Command: 0x%02X", command);
60 ESP_LOGV(TAG,
" Chips initialized.");
63 ESP_LOGCONFIG(TAG,
"MY9231:");
64 LOG_PIN(
" DI Pin: ", this->
pin_di_);
66 ESP_LOGCONFIG(TAG,
" Total number of channels: %u", this->
num_channels_);
67 ESP_LOGCONFIG(TAG,
" Number of chips: %u", this->
num_chips_);
68 ESP_LOGCONFIG(TAG,
" Bit depth: %u", this->
bit_depth_);
85 ESP_LOGV(TAG,
"set channels %u to %u", channel, value);
97 for (uint8_t i = 0; i < this->
num_chips_; i++) {
106 for (uint8_t i = bits; i > 0; i--) {
113 for (uint8_t i = 0; i < count; i++) {
120 for (uint8_t i = 0; i < count; i++) {
virtual void digital_write(bool value)=0
void set_channel_value_(uint8_t channel, uint16_t value)
void setup() override
Setup the MY9231.
void send_di_pulses_(uint8_t count)
virtual bool digital_read()=0
std::vector< uint16_t > pwm_amounts_
void dump_config() override
Helper class to disable interrupts.
void write_word_(uint16_t value, uint8_t bits)
Implementation of SPI Controller mode.
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
void loop() override
Send new values if they were updated.
void init_chips_(uint8_t command)
void send_dcki_pulses_(uint8_t count)