diff --git a/Core/Src/main.c b/Core/Src/main.c index 97c50bbb492e25573f7d04e71e39c68e6b21dccb..5162d75037b3318a3eccceeb6891bff1a2568e1e 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -536,14 +536,17 @@ uint32_t x = 0u; /* USER CODE END Header_Task01 */ void Levels(void *argument) { - +matrix_s sendQueue; int random; +int rand1; int rand2; int rand3; int counter=0; +int number; /* Infinite loop */ for(;;) { + number=0; if (counter <= 7) { random = 0; @@ -565,46 +568,42 @@ int counter=0; if(random ==0) { - rand2 =(rand()%4); - rand2 ++; - xQueueSend( toLEDMatrixHandle, ( void * ) &rand2, ( TickType_t ) 0 ); - + rand1 =(rand()%4); + number ^=(1 <<rand1); } - if (random ==1) + else if (random ==1) { - rand2 =(rand()%4); - rand3 =(rand()%3); - if (rand2 == rand3 & rand2 !=3) + rand1 =(rand()%4); + rand2 =(rand()%3); + if (rand1 == rand2 & rand1 !=3) { - rand3 ++; + rand2 ++; } else{ - rand3 --; - } - xQueueSend( toLEDMatrixHandle, ( void * ) &rand2, ( TickType_t ) 0 ); - xQueueSend( toLEDMatrixHandle, ( void * ) &rand3, ( TickType_t ) 0 ); - + rand2 --; + } + number ^=(1 <<rand1); + number ^=(1 <<rand2); } - if(random ==2) + else if(random ==2) { - rand2 =(rand()%4); - rand2 ++; - - for(int i=1; i<5; i++) + rand1 =(rand()%4); + for(int i =0; i<4; i++) { - if ( i != rand2) + if (i!= rand1) { - xQueueSend( toLEDMatrixHandle, ( void * ) &i, ( TickType_t ) 0 ); - } + number ^=(1 <<i); + } } } - if(random ==3) + else { - for(int i=1; i<5; i++) - { - xQueueSend( toLEDMatrixHandle, ( void * ) &i, ( TickType_t ) 0 ); - } - } + number=15; + } + + sendQueue.nextLED=number; + sendQueue.isRunning = true; + xQueueSend( toLEDMatrixHandle, &sendQueue, ( TickType_t ) 0 ); } }