This commit is contained in:
j3d1 2021-09-11 21:49:53 +02:00
parent 78934b85c2
commit 769351684b
2 changed files with 19 additions and 8 deletions

View file

@ -17,7 +17,8 @@ extern "C" {
const int signal_led_pin = 2; const int signal_led_pin = 2;
const int cs0 = 15; //const int cs0 = 15;
const int gpio4 = 4; const int gpio4 = 4;
const int gpio5 = 5; const int gpio5 = 5;
@ -54,6 +55,7 @@ static apa10xx_pixel_t next_color(int i) {
return colour; return colour;
} }
/*
void spi_dac(int id, int val) { void spi_dac(int id, int val) {
int dac_val = (val << 2) & 0x3FFC; int dac_val = (val << 2) & 0x3FFC;
@ -73,7 +75,7 @@ void spi_dac(int id, int val) {
gpio_write(cs0, 1); gpio_write(cs0, 1);
gpio_write(cs0, 0); gpio_write(cs0, 0);
} }
*/
void write_leds(apa10xx_pixel_t *arr, size_t len) { void write_leds(apa10xx_pixel_t *arr, size_t len) {
spi_transfer_32(1, 0x00000000); spi_transfer_32(1, 0x00000000);
@ -118,29 +120,29 @@ extern "C" void lux_task(void *pvParameters) {
//lux_apa102c_number //lux_apa102c_number
gpio_enable(signal_led_pin, GPIO_OUTPUT); gpio_enable(signal_led_pin, GPIO_OUTPUT);
gpio_enable(cs0, GPIO_OUTPUT); //gpio_enable(cs0, GPIO_OUTPUT);
gpio_enable(gpio4, GPIO_OUTPUT); gpio_enable(gpio4, GPIO_OUTPUT);
gpio_enable(gpio5, GPIO_OUTPUT); gpio_enable(gpio5, GPIO_OUTPUT);
//spi_init(1, SPI_MODE0, SPI_FREQ_DIV_1M, 1, SPI_BIG_ENDIAN, 1); //for spi dimmer //spi_init(1, SPI_MODE0, SPI_FREQ_DIV_1M, 1, SPI_BIG_ENDIAN, 1); //for spi dimmer
spi_init(1, SPI_MODE0, SPI_FREQ_DIV_1M, 1, SPI_LITTLE_ENDIAN, false); //for apa10xx spi_init(1, SPI_MODE0, SPI_FREQ_DIV_1M, 1, SPI_LITTLE_ENDIAN, false); //for apa10xx
while (1) { while (1) {
gpio_write(gpio4, 1);
vTaskDelay(200 / portTICK_PERIOD_MS);
gpio_write(gpio4, 0);
/*for (int j = 0; j < 64; j++) { /*for (int j = 0; j < 64; j++) {
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
spi_dac(i, 64 * j); spi_dac(i, 64 * j);
//printf("> %d\n", 64*j); //printf("> %d\n", 64*j);
vTaskDelay(100 / portTICK_PERIOD_MS); vTaskDelay(100 / portTICK_PERIOD_MS);
}*/ }*/
/*gpio_write(gpio4, 1);
vTaskDelay(200 / portTICK_PERIOD_MS);
gpio_write(gpio4, 0);
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
spi_dac(i, 0); spi_dac(i, 0);
gpio_write(gpio5, 1); gpio_write(gpio5, 1);
vTaskDelay(200 / portTICK_PERIOD_MS); vTaskDelay(200 / portTICK_PERIOD_MS);
gpio_write(gpio5, 0); gpio_write(gpio5, 0);*/
signal_led(0);
for (int c = 8; c >= 0; c--) { for (int c = 8; c >= 0; c--) {
for (auto &pixel: pixels) { for (auto &pixel: pixels) {
@ -153,6 +155,14 @@ extern "C" void lux_task(void *pvParameters) {
write_leds(leds, lux_apa10xx_number); write_leds(leds, lux_apa10xx_number);
vTaskDelay(200 / portTICK_PERIOD_MS); vTaskDelay(200 / portTICK_PERIOD_MS);
} }
gpio_write(gpio4, 1);
vTaskDelay(200 / portTICK_PERIOD_MS);
gpio_write(gpio4, 0);
gpio_write(gpio5, 1);
vTaskDelay(200 / portTICK_PERIOD_MS);
gpio_write(gpio5, 0);
signal_led(1);
vTaskDelay(200 / portTICK_PERIOD_MS);
} }
} }

File diff suppressed because one or more lines are too long