diff --git a/README.md b/README.md index a354ea7..1a3c0a6 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,11 @@ After cloning: $ ./scripts/repo-setup # installs esp-idf, sets up target configu To build: $ ./scripts/build.sh\ To flash: $ ./scripts/flash.sh # note: flash.sh automatically builds\ 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 diff --git a/src/drivers/wsled.c b/src/drivers/wsled.c index fbee956..f83fdbc 100644 --- a/src/drivers/wsled.c +++ b/src/drivers/wsled.c @@ -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] = { 0x1111, 0x7111, 0x1711, 0x7711, 0x1171, 0x7171, 0x1771, 0x7771, 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) { return (dev->type == WS2812B) ? WSLED_12_RESET_TIME : WSLED_15_RESET_TIME; } 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 dmaBufferSize = dev->numLeds * 12 + (resetDelay(dev) + 1) * 2; spiSettings.buscfg.mosi_io_num = dev->pin; 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)) { ESP_LOGI(__FILE__, "SPI initialization failed"); return -1; } - ESP_LOGI(__FILE__, "Adding spi bus device..."); if (ESP_OK != spi_bus_add_device(spiSettings.host, &spiSettings.devcfg, &spiSettings.spi)) { ESP_LOGI(__FILE__, "Failed to add spi bus device"); return -1; } - ESP_LOGI(__FILE__, "heap_caps_malloc() with dmaBufferSize=%u...", dmaBufferSize); dmaBuffer = heap_caps_malloc(dmaBufferSize, MALLOC_CAP_DMA); if (NULL == dmaBuffer) { ESP_LOGI(__FILE__, "Failed to heap_caps_malloc"); diff --git a/src/tasks/DemoTask.cpp b/src/tasks/DemoTask.cpp index c6b0211..e5f782b 100644 --- a/src/tasks/DemoTask.cpp +++ b/src/tasks/DemoTask.cpp @@ -29,10 +29,13 @@ void DemoTask::run() { uint8_t digit = 0; while(1) { + + // the SSD demo shifts a single hex digit over ssd.writeRaw(&digitMap[digit], 1); digit++; 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}; wsled.fill(color); wsled.flush(); diff --git a/src/wsled/WsledInterface.cpp b/src/wsled/WsledInterface.cpp index bb2851b..df56721 100644 --- a/src/wsled/WsledInterface.cpp +++ b/src/wsled/WsledInterface.cpp @@ -5,6 +5,8 @@ WsledInterface::WsledInterface(const wsled_t* device) : device_(device), numLeds (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_); // 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) { + // is it really that easy leds_[index] = pixel; return OKAY; @@ -22,6 +25,7 @@ STATUS WsledInterface::writePixel(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]; return OKAY; @@ -29,6 +33,7 @@ STATUS WsledInterface::get(CRGB* pixel, size_t index) { STATUS WsledInterface::flush() { + // man I wrote my driver so well that it really is that easy wsledUpdate(device_, leds_.data(), numLeds_); return OKAY; @@ -36,6 +41,7 @@ STATUS WsledInterface::flush() { STATUS WsledInterface::fill(CRGB color) { + // I HATE ITERATORS YOU CAN NEVER MAKE ME USE THEM !!!! for (size_t i = 0; i < numLeds_; i++) { leds_[i] = color; } diff --git a/src/wsled/effects/.gitkeep b/src/wsled/effects/.gitkeep new file mode 100644 index 0000000..e69de29