test sur 2 coeurs
This commit is contained in:
parent
dd78e63897
commit
0b1fcaa085
@ -72,6 +72,7 @@ target_link_libraries( host_cdc_msc_hid PUBLIC
|
||||
hardware_sync
|
||||
pico_aon_timer
|
||||
pico_stdlib
|
||||
pico_multicore
|
||||
${HWDEP_LIBS}
|
||||
)
|
||||
|
||||
|
||||
49
main.c
49
main.c
@ -105,12 +105,61 @@ sd_card_t* sd_get_by_num(size_t num) {
|
||||
}
|
||||
}
|
||||
|
||||
void sd_card_gestion(){
|
||||
if(gpio_get(1) == 1){
|
||||
ws2812_set_buffer_rgb(OFF_24BITS, 0);
|
||||
// Unmount FS + de-init log SD
|
||||
}else{
|
||||
ws2812_set_buffer_rgb(BLEU_24BITS, 0);
|
||||
}
|
||||
|
||||
// Init SD Card for log
|
||||
FATFS fs;
|
||||
char drive_path[3] = "0:";
|
||||
drive_path[0] += DEV_SDIO_MIN;
|
||||
FRESULT fr;
|
||||
do{
|
||||
fr = f_mount(&fs, drive_path, 1);
|
||||
if(FR_OK != fr){
|
||||
printf("f_mount error: %s (%d)\n", FRESULT_str(fr), fr);
|
||||
printf(">f_mount:0\n");
|
||||
sleep_ms(50);
|
||||
}else{
|
||||
printf(">f_mount:1\n");
|
||||
f_unmount(drive_path);
|
||||
sleep_ms(50);
|
||||
}
|
||||
}while(1);
|
||||
}
|
||||
|
||||
void core1_functions(){
|
||||
while(1){
|
||||
ws2812_affiche_buffer();
|
||||
sleep_ms(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------- MAIN -------------*/
|
||||
int main(void) {
|
||||
multicore_launch_core1(core1_functions);
|
||||
board_init();
|
||||
ws2812_init();
|
||||
|
||||
ws2812_set_buffer_rgb(2,2,2,0);
|
||||
ws2812_set_buffer_rgb(2,2,2,3);
|
||||
|
||||
// Init detection carte SD
|
||||
gpio_init(1);
|
||||
gpio_set_dir(1, GPIO_IN);
|
||||
gpio_pull_up(1);
|
||||
|
||||
/*while(1){
|
||||
sd_card_gestion();
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
gpio_set_function(12, UART_FUNCSEL_NUM(uart0, 12));
|
||||
gpio_set_function(13, UART_FUNCSEL_NUM(uart0, 13));
|
||||
printf("TinyUSB Host CDC MSC HID - Logs\r\n");
|
||||
|
||||
22
ws2812.c
22
ws2812.c
@ -64,7 +64,7 @@ void ws2812_init(){
|
||||
|
||||
// Tout rouge !
|
||||
for(uint32_t i = 0; i<12; i++){
|
||||
ws2812_set_buffer_rgb(0x4, 0x1, 0, i);
|
||||
ws2812_set_buffer_rgb(ORANGE_24BITS, i);
|
||||
}
|
||||
ws2812_affiche_buffer();
|
||||
}
|
||||
@ -110,6 +110,12 @@ void ws2812_set_buffer_rgb(uint8_t rouge, uint8_t vert, uint8_t bleu, uint8_t in
|
||||
ws2812_set_buffer(urgb_u32(rouge, vert,bleu), index_led);
|
||||
}
|
||||
|
||||
void ws2812_set_rgb(uint8_t rouge, uint8_t vert, uint8_t bleu, uint8_t index_led){
|
||||
ws2812_set_buffer(urgb_u32(rouge, vert,bleu), index_led);
|
||||
ws2812_affiche_buffer();
|
||||
sleep_us(500);
|
||||
}
|
||||
|
||||
//Bit 7 6 5 4 3 2 1 0
|
||||
//Data R R R G G G B B
|
||||
void ws2812_set_buffer_8bits(uint8_t couleur, uint8_t index_led){
|
||||
@ -123,4 +129,18 @@ void ws2812_set_buffer(uint32_t couleur, uint8_t index_led){
|
||||
if(index_led <12){
|
||||
buffer_couleur[index_led] = couleur;
|
||||
}
|
||||
}
|
||||
|
||||
void ws2812_set_led(uint8_t led, uint32_t couleur){
|
||||
ws2812_set_buffer(couleur, led);
|
||||
ws2812_affiche_buffer();
|
||||
|
||||
}
|
||||
|
||||
uint32_t ws2812_mix_color(uint32_t couleur1, uint32_t couleur2, float facteur){
|
||||
uint8_t r, g, b;
|
||||
b = (couleur1 & 0xFF) * (1 - facteur) + (couleur2 & 0xFF) * facteur;
|
||||
r = ((couleur1 & 0xFF00)>> 8) * (1 - facteur) + ((couleur2 & 0xFF00)>> 8) * facteur;
|
||||
g = ((couleur1 & 0xFF0000)>> 16) * (1 - facteur) + ((couleur2 & 0xFF00)>> 16) * facteur;
|
||||
return urgb_u32(r, g, b);
|
||||
}
|
||||
9
ws2812.h
9
ws2812.h
@ -3,5 +3,12 @@
|
||||
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);
|
||||
void ws2812_set_rgb(uint8_t rouge, uint8_t vert, uint8_t bleu, uint8_t index_led);
|
||||
void ws2812_set_buffer_8bits(uint8_t couleur, uint8_t index_led);
|
||||
void ws2812_arc_en_ciel(void);
|
||||
void ws2812_arc_en_ciel(void);
|
||||
void ws2812_set_led(uint8_t led, uint32_t couleur);
|
||||
|
||||
#define OFF_24BITS 0, 0, 0
|
||||
#define ORANGE_24BITS 4, 1, 0
|
||||
#define BLEU_24BITS 0, 0, 4
|
||||
#define VERT_24BITS 0, 4, 1
|
||||
Loading…
Reference in New Issue
Block a user