diff --git a/ws2812.c b/ws2812.c index b07638e..cac360d 100644 --- a/ws2812.c +++ b/ws2812.c @@ -62,11 +62,31 @@ void ws2812_init(){ // Tout rouge ! for(uint32_t i = 0; i<12; i++){ - ws2812_set_buffer_rgb(0x10, 0, 0, i); + ws2812_set_buffer_rgb(0x1, 0, 0, i); } ws2812_affiche_buffer(); } + +void ws2812_arc_en_ciel(){ + while(1){ + uint32_t i; + sleep_ms(50); + + // Affichage + for(i = 0; i<12; i++){ + ws2812_set_buffer(couleur[i], i); + } + ws2812_affiche_buffer(); + + // Décalage des couleurs + for(i = 0; i<12; i++){ + couleur[i] = couleur[i+1]; + } + couleur[12]=couleur[0]; + } +} + static inline void put_pixel(uint32_t pixel_grb) { pio_sm_put_blocking(pio0, 0, pixel_grb << 8u); } @@ -88,4 +108,10 @@ void ws2812_set_buffer_rgb(uint8_t rouge, uint8_t vert, uint8_t bleu, uint8_t in if(index_led <12){ buffer_couleur[index_led] = urgb_u32(rouge, vert,bleu); } +} + +void ws2812_set_buffer(uint32_t couleur, uint8_t index_led){ + if(index_led <12){ + buffer_couleur[index_led] = couleur; + } } \ No newline at end of file diff --git a/ws2812.h b/ws2812.h index 40cdf19..dca15e4 100644 --- a/ws2812.h +++ b/ws2812.h @@ -2,4 +2,6 @@ void ws2812_init(void); void ws2812_affiche_buffer(void); -void ws2812_set_buffer_rgb(uint8_t rouge, uint8_t vert, uint8_t bleu, uint8_t index_led); \ No newline at end of file +void ws2812_set_buffer_rgb(uint8_t rouge, uint8_t vert, uint8_t bleu, uint8_t index_led); +void ws2812_set_buffer(uint32_t couleur, uint8_t index_led); +void ws2812_arc_en_ciel(void); \ No newline at end of file