Updates along with SDK1.3.0 release (#181)

Bug fixes and new examples

Co-authored-by: Paulo Marques <pm@quant-insight.com>
Co-authored-by: martin <admin@crossleys.biz>
Co-authored-by: matiasilva <matias.silva@raspberrypi.com>
Co-authored-by: Uri Shaked <uri@urishaked.com>
Co-authored-by: Diego Solano <diegosolano@gmail.com>
Co-authored-by: Andrew Scheller <andrew.scheller@raspberrypi.com>
Co-authored-by: Adrian Hesketh <a-h@users.noreply.github.com>
Co-authored-by: Emircan Gündoğdu <58917386+emircangun@users.noreply.github.com>
Co-authored-by: Josef Wegner <80200012+josefwegner@users.noreply.github.com>
Co-authored-by: pmarques-dev <72901351+pmarques-dev@users.noreply.github.com>
Co-authored-by: Paulo Marques <pm@quant-insight.com>
Co-authored-by: mjcross <mjcross@users.noreply.github.com>
Co-authored-by: martin <admin@crossleys.biz>
This commit is contained in:
Graham Sanderson
2021-11-01 14:41:54 -05:00
committed by GitHub
parent 146680d625
commit f800a7e303
150 changed files with 4832 additions and 98 deletions

View File

@@ -16,7 +16,8 @@
#include "ws2812.pio.h"
#define FRAC_BITS 4
#define PIN_TX 0
#define NUM_PIXELS 64
#define WS2812_PIN_BASE 2
// horrible temporary hack to avoid changing pattern code
static uint8_t *current_string_out;
@@ -174,17 +175,15 @@ void dither_values(const value_bits_t *colors, value_bits_t *state, const value_
}
}
#define MAX_LENGTH 100
// requested colors * 4 to allow for WRGB
static value_bits_t colors[MAX_LENGTH * 4];
// requested colors * 4 to allow for RGBW
static value_bits_t colors[NUM_PIXELS * 4];
// double buffer the state of the string, since we update next version in parallel with DMAing out old version
static value_bits_t states[2][MAX_LENGTH * 4];
static value_bits_t states[2][NUM_PIXELS * 4];
// example - string 0 is RGB only
static uint8_t string0_data[MAX_LENGTH * 3];
// example - string 1 is WRGB
static uint8_t string1_data[MAX_LENGTH * 4];
static uint8_t string0_data[NUM_PIXELS * 3];
// example - string 1 is RGBW
static uint8_t string1_data[NUM_PIXELS * 4];
string_t string0 = {
.data = string0_data,
@@ -213,7 +212,7 @@ string_t *strings[] = {
#define DMA_CHANNELS_MASK (DMA_CHANNEL_MASK | DMA_CB_CHANNEL_MASK)
// start of each value fragment (+1 for NULL terminator)
static uintptr_t fragment_start[MAX_LENGTH * 4 + 1];
static uintptr_t fragment_start[NUM_PIXELS * 4 + 1];
// posted when it is safe to output a new set of values
static struct semaphore reset_delay_complete_sem;
@@ -286,7 +285,7 @@ int main() {
int sm = 0;
uint offset = pio_add_program(pio, &ws2812_parallel_program);
ws2812_parallel_program_init(pio, sm, offset, PIN_TX, count_of(strings), 800000);
ws2812_parallel_program_init(pio, sm, offset, WS2812_PIN_BASE, count_of(strings), 800000);
sem_init(&reset_delay_complete_sem, 1, 1); // initially posted so we don't block first time
dma_init(pio, sm);
@@ -300,19 +299,17 @@ int main() {
int brightness = 0;
uint current = 0;
for (int i = 0; i < 1000; ++i) {
int n = 64;
current_string_out = string0.data;
current_string_4color = false;
pattern_table[pat].pat(n, t);
pattern_table[pat].pat(NUM_PIXELS, t);
current_string_out = string1.data;
current_string_4color = true;
pattern_table[pat].pat(n, t);
pattern_table[pat].pat(NUM_PIXELS, t);
transform_strings(strings, count_of(strings), colors, n * 4, brightness);
dither_values(colors, states[current], states[current ^ 1], n * 4);
transform_strings(strings, count_of(strings), colors, NUM_PIXELS * 4, brightness);
dither_values(colors, states[current], states[current ^ 1], NUM_PIXELS * 4);
sem_acquire_blocking(&reset_delay_complete_sem);
output_strings_dma(states[current], n * 4);
output_strings_dma(states[current], NUM_PIXELS * 4);
current ^= 1;
t += dir;