stash
This commit is contained in:
parent
7f422a2ddd
commit
b72426b9c7
1 changed files with 33 additions and 28 deletions
|
@ -54,34 +54,6 @@ static apa10xx_pixel_t next_color(int i) {
|
|||
return colour;
|
||||
}
|
||||
|
||||
void spi_dac(int id, int val) {
|
||||
int dac_val = (val << 2) & 0x3FFC;
|
||||
|
||||
spi_transfer_8(1, ~(0x00));
|
||||
gpio_write(cs0, 1);
|
||||
gpio_write(cs0, 0);
|
||||
spi_transfer_8(1, ~(0x01 << id));
|
||||
gpio_write(cs0, 1);
|
||||
gpio_write(cs0, 0);
|
||||
|
||||
spi_transfer_16(1, dac_val);
|
||||
|
||||
spi_transfer_8(1, ~(0x00));
|
||||
gpio_write(cs0, 1);
|
||||
gpio_write(cs0, 0);
|
||||
spi_transfer_8(1, ~(0x01 << id));
|
||||
gpio_write(cs0, 1);
|
||||
gpio_write(cs0, 0);
|
||||
}
|
||||
|
||||
void write_leds(apa10xx_pixel_t *arr, size_t len) {
|
||||
spi_transfer_32(1, 0x00000000);
|
||||
for (size_t i = 0; i < len; i++)
|
||||
spi_transfer_32(1, *(uint32_t *) &arr[i]);
|
||||
spi_transfer_32(1, 0xFFFFFFFF);
|
||||
spi_transfer_32(1, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
namespace fiatlux {
|
||||
|
||||
namespace signal {
|
||||
|
@ -184,6 +156,39 @@ namespace fiatlux {
|
|||
}
|
||||
}
|
||||
|
||||
hal_error_t setup_channel(size_t count, size_t stride, hal_module_t mod) {
|
||||
/*if(mod == hal_module_t::SIGNAL) {
|
||||
if(count != 1)
|
||||
return "unsupported value for count";
|
||||
if(stride != 1)
|
||||
return "unsupported value for stride";
|
||||
signal::write_data(data[0]);
|
||||
} else if(mod == hal_module_t::RELAIS) {
|
||||
if(count != 2)
|
||||
return "unsupported value for count";
|
||||
if(stride != 1)
|
||||
return "unsupported value for stride";
|
||||
relais::write_data(data);
|
||||
} else if(mod == hal_module_t::SPI_DIMMER) {
|
||||
if(count != 6)
|
||||
return "unsupported value for count";
|
||||
if(stride != 2)
|
||||
return "unsupported value for stride";
|
||||
spi_dimmer::write_data((uint16_t *) data);
|
||||
} else if(mod == hal_module_t::WS28X) {
|
||||
if(stride != 4)
|
||||
return "unsupported value for stride";
|
||||
ws28x::write_data((ws2812_pixel_t *) data, count);
|
||||
} else if(mod == hal_module_t::APA10X) {
|
||||
if(stride != 4)
|
||||
return "unsupported value for stride";
|
||||
apa10x::write_data((apa10xx_pixel_t *) data, count);
|
||||
} else {
|
||||
return "unsupported module";
|
||||
}
|
||||
return empty_error;*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ws2812_pixel_t **pixels_ptr;
|
||||
|
|
Loading…
Reference in a new issue