From ac1fbe97693043eb84772d35d0036e16da42b0d2 Mon Sep 17 00:00:00 2001 From: Samuel Date: Sun, 26 Feb 2023 14:10:57 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20fonctionnalit=C3=A9=20d'arc?= =?UTF-8?q?=20en=20ciel=20!=20IMPORTANT=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ws2812.c | 28 +++++++++++++++++++++++++++- ws2812.h | 4 +++- 2 files changed, 30 insertions(+), 2 deletions(-) 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