Skip to content

Commit

Permalink
Add randomness to the example
Browse files Browse the repository at this point in the history
  • Loading branch information
mryndzionek committed Jul 9, 2023
1 parent f7b4f4f commit 0fa455b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions rp2040/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ add_executable(chimes
target_link_libraries(chimes
pico_multicore
pico_stdlib
pico_rand
hardware_dma
hardware_pio
hardware_timer
Expand Down
4 changes: 3 additions & 1 deletion rp2040/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "pico/util/queue.h"
#include "pico/multicore.h"
#include "pico/sem.h"
#include "pico/rand.h"

#include "hardware/irq.h"
#include "hardware/pwm.h"
Expand Down Expand Up @@ -61,6 +62,7 @@ static void core1_entry()
sample = chime_update(chime);
if (chime_is_finished(chime))
{
srand(get_rand_32());
chime = chime_init();
}
outputBuffer[n][i] = (sample + 1.0) * 80;
Expand All @@ -76,7 +78,7 @@ int main()
{
uint16_t *data;

srand(time(NULL));
srand(get_rand_32());
set_sys_clock_khz(FCPU / 1000, true);

queue_init(&results_queue, sizeof(uint16_t *), 1);
Expand Down

0 comments on commit 0fa455b

Please sign in to comment.