Ajout de la fonctionnalité d'arc en ciel ! IMPORTANT !
This commit is contained in:
parent
52d880375e
commit
ac1fbe9769
28
ws2812.c
28
ws2812.c
@ -62,11 +62,31 @@ void ws2812_init(){
|
|||||||
|
|
||||||
// Tout rouge !
|
// Tout rouge !
|
||||||
for(uint32_t i = 0; i<12; i++){
|
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();
|
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) {
|
static inline void put_pixel(uint32_t pixel_grb) {
|
||||||
pio_sm_put_blocking(pio0, 0, pixel_grb << 8u);
|
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){
|
if(index_led <12){
|
||||||
buffer_couleur[index_led] = urgb_u32(rouge, vert,bleu);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
4
ws2812.h
4
ws2812.h
@ -2,4 +2,6 @@
|
|||||||
|
|
||||||
void ws2812_init(void);
|
void ws2812_init(void);
|
||||||
void ws2812_affiche_buffer(void);
|
void ws2812_affiche_buffer(void);
|
||||||
void ws2812_set_buffer_rgb(uint8_t rouge, uint8_t vert, uint8_t bleu, uint8_t index_led);
|
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);
|
Loading…
Reference in New Issue
Block a user