Open CBMalloch opened 2 years ago
You sure we are better served with the issue here instead of https://github.com/xoseperez/my92xx/issues?
Is this the actual MCVE, and channels don't properly adjust from 0 to 255?
#include <Arduino.h>
#include <my92xx.h>
#define MY92XX_MODEL MY92XX_MODEL_MY9231
#define MY92XX_CHIPS 2
#define MY92XX_DI_PIN 12
#define MY92XX_DCKI_PIN 14
#define MY92XX_COLD 0
#define MY92XX_WARM 1
#define MY92XX_RED 4
#define MY92XX_GREEN 3
#define MY92XX_BLUE 5
static constexpr unsigned char MY92XX_CHANNELS[] {
MY92XX_RED,
MY92XX_GREEN,
MY92XX_BLUE,
MY92XX_WARM,
MY92XX_COLD
};
static my92xx* _my92xx { nullptr };
void setup() {
_my92xx = new my92xx ( MY92XX_MODEL, MY92XX_CHIPS,
MY92XX_DI_PIN, MY92XX_DCKI_PIN,
{ \
.scatter = MY92XX_CMD_SCATTER_APDM, \
.frequency = MY92XX_CMD_FREQUENCY_DIVIDE_1, \
.bit_width = MY92XX_CMD_BIT_WIDTH_8, \
.reaction = MY92XX_CMD_REACTION_FAST, \
.one_shot = MY92XX_CMD_ONE_SHOT_DISABLE, \
.resv = 0 \
}
);
_my92xx->setState(true);
for (;;) {
for (unsigned char value = 0; value < 255; ++value) {
for (auto channel : MY92XX_CHANNELS) {
_my92xx->setChannel(channel, value);
}
_my92xx->update();
delay(100);
}
}
}
void loop() { }
delayMicroseconds(...)
is os_delay_us(...)
so no surprise there :)
https://github.com/esp8266/Arduino/blob/c312a2eaf1356ceaafad7c4935fa850e087c84fe/cores/esp8266/core_esp8266_wiring.cpp#L189-L191
Since we are expected to digitalWrite in a tight sequence... Have you tried locking interrupts before doing _my92xx->update()
in the sendOutput()
, like the library source have tried originally (but commented out)? Something like
ets_intr_lock();
_my92xx->update();
ets_intr_unlock();
I just tried locking interrupts before the update call. No change. :(
Basic Infos
Platform
Settings in IDE
Problem Description
Sending code to an Itead SONOFF B1 light bulb, which uses a my9231 chip to control the 5 channels of LED. When I use ESP8266 board definitions 2.7.4, everything works as planned. If I update to 3.0.0 or above, the bulb flashes more or less at random as I adjust values. The brightnesses no longer scale smoothly with the commands, nor go to the proper channels. Seems funny, since the my92xx library isn't using much - only digitalWrites and the c code for os_delay_us. I tried replacing the os_delay_us definition with delayMicroseconds, without any better luck.
MCVE Sketch
Debug Messages