This commit is contained in:
j3d1 2022-09-24 08:27:44 +02:00
parent 1263d7836f
commit be01d6b985
2 changed files with 25 additions and 31 deletions

View file

@ -61,6 +61,7 @@ static apa10xx_pixel_t next_color(int i) {
rgba_t top_color;
rgba_t bottom_color;
uint16_t dimmer_value;
namespace fiatlux {
@ -298,34 +299,9 @@ extern "C" [[noreturn]] void lux_task(void *pvParameters) {
uint32_t _;
} frame = {._=0};
frame.addr = 0x123;
frame.dat = 0xAA55;
frame.op = 0x7;
dimmer_value = 255;
auto transfer = [](uint32_t val) -> uint32_t {
uint32_t out = val;
uint32_t in;
spi_transfer(1, &out, &in, 1, SPI_32BIT);
return in;
};
dummy = transfer(frame._);
if(dummy) {
syslog("> ");
syslog_i32(dummy);
syslog("\n");
}
syslog("< ");
syslog_i32(frame._);
syslog("\n");
dummy = 0;
for (volatile int i = 0; i < 512 * 16; ++i);
frame._ = transfer(dummy);
if(frame._) {
syslog("> ");
syslog_i32(frame._);
syslog("\n");
}
uint16_t last_dimmer_value = 0;
while (true) {
/*for (int j = 0; j < 64; j++) {
@ -350,9 +326,27 @@ extern "C" [[noreturn]] void lux_task(void *pvParameters) {
pixel = next_colour(c);
}*/
//for (auto &led: leds) {
// led = next_color(c);
//}
if(last_dimmer_value != dimmer_value) {
for (int i = 0; i < 6; ++i) {
frame.op = 0xA;
frame.addr = i * 2 + 1;
frame.dat = 255;
spi_transfer_32(1, frame._);
vTaskDelay(13 / portTICK_PERIOD_MS);
//for (volatile int i = 0; i < 512 * 32; ++i);
frame.op = 0xA;
frame.addr = i * 2;
frame.dat = dimmer_value << 4;
spi_transfer_32(1, frame._);
vTaskDelay(13 / portTICK_PERIOD_MS);
//for (volatile int i = 0; i < 512 * 32; ++i);
}
//last_dimmer_value = dimmer_value;
}
for (int i = 0; i < 120; i++)
pixels[i] = {{top_color.r, top_color.g, top_color.b, top_color.a}};
@ -373,6 +367,5 @@ extern "C" [[noreturn]] void lux_task(void *pvParameters) {
vTaskDelay(200 / portTICK_PERIOD_MS);
}
}

View file

@ -24,6 +24,7 @@ typedef struct {
extern rgba_t top_color;
extern rgba_t bottom_color;
extern uint16_t dimmer_value;
#ifdef __cplusplus
}