Skip to content

Commit

Permalink
Mystrix animation system ported
Browse files Browse the repository at this point in the history
  • Loading branch information
203Null committed Dec 1, 2024
1 parent 37a225f commit 35c71e9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
10 changes: 8 additions & 2 deletions ports/espressif/boards/boards.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static esp_timer_handle_t timer_hdl;

#ifdef NEOPIXEL_PIN
#include "led_strip.h"
static led_strip_handle_t led_strip;
led_strip_handle_t led_strip;
#endif

#ifdef DOTSTAR_PIN_DATA
Expand Down Expand Up @@ -239,9 +239,15 @@ void board_init(void) {
.flags.invert_out = false, // whether to invert the output signal
};

ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
// ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));

led_strip_spi_config_t spi_config = {
.clk_src = SPI_CLK_SRC_DEFAULT, // SPI clock source
.spi_bus = SPI3_HOST, // SPI bus ID. Which buses are available depends on the specific chip
.flags.with_dma = 1, // Use DMA to transmit data
};

ESP_ERROR_CHECK(led_strip_new_spi_device(&strip_config, &spi_config, &led_strip));

led_strip_clear(led_strip); // off
#endif
Expand Down
21 changes: 10 additions & 11 deletions ports/espressif/boards/mystrix/animation.c
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
#include "board_api.h"
#include "led_strip.h"

extern led_strip_t *strip;
extern led_strip_handle_t led_strip;

uint8_t upload_symbol[10] = {19, 20, 27, 28, 34, 35, 36, 37, 43, 44};

#define WAVE_STEP 16
uint8_t* grayscale_wave;





void show_upload_symbol(uint8_t r, uint8_t g, uint8_t b)
{
r = r * NEOPIXEL_BRIGHTNESS / 255;
g = g * NEOPIXEL_BRIGHTNESS / 255;
b = b * NEOPIXEL_BRIGHTNESS / 255;
for(uint32_t i = 0; i < sizeof(upload_symbol); i++)
{
strip->set_pixel(strip, upload_symbol[i], r, g, b);
led_strip_set_pixel(led_strip, upload_symbol[i], r, g, b);
}
strip->refresh(strip, 100);
led_strip_refresh(led_strip);
}

void generate_wave()
Expand Down Expand Up @@ -55,7 +54,7 @@ void board_rgb_state(uint32_t state)

case STATE_WRITING_FINISHED:
board_timer_stop();
strip->clear(strip, 100);
led_strip_clear(led_strip);
break;

default:
Expand All @@ -73,10 +72,10 @@ void animation_handler(void)
uint8_t y = upload_symbol[i] / 8 - 2;
if(y >= led_index)
break;
uint8_t brightness = grayscale_wave[((4-y) + led_index) % WAVE_STEP];
strip->set_pixel(strip, upload_symbol[i], 0, brightness, brightness);
uint8_t brightness = grayscale_wave[((4-y) + led_index) % WAVE_STEP] * NEOPIXEL_BRIGHTNESS / 255;
led_strip_set_pixel(led_strip, upload_symbol[i], 0, brightness, brightness);
}
}
led_index ++;
strip->refresh(strip, 100);
led_strip_refresh(led_strip);
}
4 changes: 3 additions & 1 deletion ports/espressif/boards/mystrix/board.cmake
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Apply board specific content here
set(IDF_TARGET "esp32s3")
set(IDF_TARGET "esp32s3")

set(BOARD_SOURCES "${BOARD}/animation.c")

0 comments on commit 35c71e9

Please sign in to comment.