comments and update readme
This commit is contained in:
@@ -35,3 +35,11 @@ After cloning: $ ./scripts/repo-setup # installs esp-idf, sets up target configu
|
|||||||
To build: $ ./scripts/build.sh\
|
To build: $ ./scripts/build.sh\
|
||||||
To flash: $ ./scripts/flash.sh # note: flash.sh automatically builds\
|
To flash: $ ./scripts/flash.sh # note: flash.sh automatically builds\
|
||||||
To monitor: $ ./scripts/monitor.sh\
|
To monitor: $ ./scripts/monitor.sh\
|
||||||
|
|
||||||
|
## TODOs for developers
|
||||||
|
- [ ] Move all hardware specifications to config/Kconfig.projbuild file. (things like NUM_LEDS, pins.h, ssd_digits, etc.)
|
||||||
|
- [ ] Create an effect base class for effects to inherit from
|
||||||
|
- [ ] Attach interrupts for hardware inputs
|
||||||
|
- [ ] Human I/O (like from buttons, knobs) needs to be in its own io task. Other tasks will be injected with a general I/O interface
|
||||||
|
- [ ] Investigate putting the wsled task on a separate core from io and such
|
||||||
|
- [ ] Wsled interface needs a platform for matrix creation
|
||||||
|
|||||||
@@ -33,39 +33,35 @@ static spi_settings_t spiSettings = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// translations from SPI -> ws2812b protocol
|
||||||
|
// [spi] 0b1110 = [ws2812b]0b1 and [spi] 0b1000 = [ws2812b]0b0
|
||||||
static const uint16_t timingBits[16] = {
|
static const uint16_t timingBits[16] = {
|
||||||
0x1111, 0x7111, 0x1711, 0x7711, 0x1171, 0x7171, 0x1771, 0x7771,
|
0x1111, 0x7111, 0x1711, 0x7711, 0x1171, 0x7171, 0x1771, 0x7771,
|
||||||
0x1117, 0x7117, 0x1717, 0x7717, 0x1177, 0x7177, 0x1777, 0x7777};
|
0x1117, 0x7117, 0x1717, 0x7717, 0x1177, 0x7177, 0x1777, 0x7777};
|
||||||
|
|
||||||
|
// WS2812b can handle shorter reset delays than the WS2815
|
||||||
static inline uint32_t resetDelay(const wsled_t* dev) {
|
static inline uint32_t resetDelay(const wsled_t* dev) {
|
||||||
return (dev->type == WS2812B) ? WSLED_12_RESET_TIME : WSLED_15_RESET_TIME;
|
return (dev->type == WS2812B) ? WSLED_12_RESET_TIME : WSLED_15_RESET_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t wsledInit(const wsled_t* dev) {
|
esp_err_t wsledInit(const wsled_t* dev) {
|
||||||
|
|
||||||
ESP_LOGI(__FILE__, "Initializing wsled device...");
|
|
||||||
|
|
||||||
ESP_LOGI(__FILE__, "mallocing the wsledPixel buffer with size %u bytes", sizeof(CRGB) * dev->numLeds);
|
|
||||||
|
|
||||||
// 12 bytes for each led + bytes for initial zero and reset state
|
// 12 bytes for each led + bytes for initial zero and reset state
|
||||||
dmaBufferSize = dev->numLeds * 12 + (resetDelay(dev) + 1) * 2;
|
dmaBufferSize = dev->numLeds * 12 + (resetDelay(dev) + 1) * 2;
|
||||||
|
|
||||||
spiSettings.buscfg.mosi_io_num = dev->pin;
|
spiSettings.buscfg.mosi_io_num = dev->pin;
|
||||||
spiSettings.buscfg.max_transfer_sz = dmaBufferSize;
|
spiSettings.buscfg.max_transfer_sz = dmaBufferSize;
|
||||||
|
|
||||||
ESP_LOGI(__FILE__, "Initializing spi interface...");
|
|
||||||
if (ESP_OK != spi_bus_initialize(spiSettings.host, &spiSettings.buscfg, spiSettings.dma_chan)) {
|
if (ESP_OK != spi_bus_initialize(spiSettings.host, &spiSettings.buscfg, spiSettings.dma_chan)) {
|
||||||
ESP_LOGI(__FILE__, "SPI initialization failed");
|
ESP_LOGI(__FILE__, "SPI initialization failed");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(__FILE__, "Adding spi bus device...");
|
|
||||||
if (ESP_OK != spi_bus_add_device(spiSettings.host, &spiSettings.devcfg, &spiSettings.spi)) {
|
if (ESP_OK != spi_bus_add_device(spiSettings.host, &spiSettings.devcfg, &spiSettings.spi)) {
|
||||||
ESP_LOGI(__FILE__, "Failed to add spi bus device");
|
ESP_LOGI(__FILE__, "Failed to add spi bus device");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(__FILE__, "heap_caps_malloc() with dmaBufferSize=%u...", dmaBufferSize);
|
|
||||||
dmaBuffer = heap_caps_malloc(dmaBufferSize, MALLOC_CAP_DMA);
|
dmaBuffer = heap_caps_malloc(dmaBufferSize, MALLOC_CAP_DMA);
|
||||||
if (NULL == dmaBuffer) {
|
if (NULL == dmaBuffer) {
|
||||||
ESP_LOGI(__FILE__, "Failed to heap_caps_malloc");
|
ESP_LOGI(__FILE__, "Failed to heap_caps_malloc");
|
||||||
|
|||||||
@@ -29,10 +29,13 @@ void DemoTask::run() {
|
|||||||
uint8_t digit = 0;
|
uint8_t digit = 0;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
|
|
||||||
|
// the SSD demo shifts a single hex digit over
|
||||||
ssd.writeRaw(&digitMap[digit], 1);
|
ssd.writeRaw(&digitMap[digit], 1);
|
||||||
digit++;
|
digit++;
|
||||||
if(digit >= 16) digit = 0;
|
if(digit >= 16) digit = 0;
|
||||||
|
|
||||||
|
// the wsled demo toggles the entire array between red and blue
|
||||||
CRGB color = (digit % 2) ? CRGB{100, 20, 20} : CRGB{20, 20, 100};
|
CRGB color = (digit % 2) ? CRGB{100, 20, 20} : CRGB{20, 20, 100};
|
||||||
wsled.fill(color);
|
wsled.fill(color);
|
||||||
wsled.flush();
|
wsled.flush();
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ WsledInterface::WsledInterface(const wsled_t* device) : device_(device), numLeds
|
|||||||
|
|
||||||
(void)wsledInit(device);
|
(void)wsledInit(device);
|
||||||
|
|
||||||
|
// who cares if its dynamically allocated we have like 4 Mb of ram
|
||||||
|
// an led strip 1024 long will use 3kb here and 12kb in the driver for dma
|
||||||
leds_.resize(numLeds_);
|
leds_.resize(numLeds_);
|
||||||
|
|
||||||
// turn all leds off
|
// turn all leds off
|
||||||
@@ -15,6 +17,7 @@ WsledInterface::WsledInterface(const wsled_t* device) : device_(device), numLeds
|
|||||||
|
|
||||||
STATUS WsledInterface::writePixel(CRGB pixel, size_t index) {
|
STATUS WsledInterface::writePixel(CRGB pixel, size_t index) {
|
||||||
|
|
||||||
|
// is it really that easy
|
||||||
leds_[index] = pixel;
|
leds_[index] = pixel;
|
||||||
|
|
||||||
return OKAY;
|
return OKAY;
|
||||||
@@ -22,6 +25,7 @@ STATUS WsledInterface::writePixel(CRGB pixel, size_t index) {
|
|||||||
|
|
||||||
STATUS WsledInterface::get(CRGB* pixel, size_t index) {
|
STATUS WsledInterface::get(CRGB* pixel, size_t index) {
|
||||||
|
|
||||||
|
// I could just return the pixel but im so cool and C coded
|
||||||
*pixel = leds_[index];
|
*pixel = leds_[index];
|
||||||
|
|
||||||
return OKAY;
|
return OKAY;
|
||||||
@@ -29,6 +33,7 @@ STATUS WsledInterface::get(CRGB* pixel, size_t index) {
|
|||||||
|
|
||||||
STATUS WsledInterface::flush() {
|
STATUS WsledInterface::flush() {
|
||||||
|
|
||||||
|
// man I wrote my driver so well that it really is that easy
|
||||||
wsledUpdate(device_, leds_.data(), numLeds_);
|
wsledUpdate(device_, leds_.data(), numLeds_);
|
||||||
|
|
||||||
return OKAY;
|
return OKAY;
|
||||||
@@ -36,6 +41,7 @@ STATUS WsledInterface::flush() {
|
|||||||
|
|
||||||
STATUS WsledInterface::fill(CRGB color) {
|
STATUS WsledInterface::fill(CRGB color) {
|
||||||
|
|
||||||
|
// I HATE ITERATORS YOU CAN NEVER MAKE ME USE THEM !!!!
|
||||||
for (size_t i = 0; i < numLeds_; i++) {
|
for (size_t i = 0; i < numLeds_; i++) {
|
||||||
leds_[i] = color;
|
leds_[i] = color;
|
||||||
}
|
}
|
||||||
|
|||||||
0
src/wsled/effects/.gitkeep
Normal file
0
src/wsled/effects/.gitkeep
Normal file
Reference in New Issue
Block a user