From 29a6cb62ecfa86ef47185bc49a471cfde1984ff5 Mon Sep 17 00:00:00 2001 From: VeyPatch <126267034+VeyPatch@users.noreply.github.com> Date: Tue, 24 Dec 2024 22:04:21 +0100 Subject: [PATCH] Add more randomness --- .../hlc_tft_display/hlc_tft_display.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/users/halcyon_modules/hlc_tft_display/hlc_tft_display.c b/users/halcyon_modules/hlc_tft_display/hlc_tft_display.c index 6efd3d2d..11f56c9d 100644 --- a/users/halcyon_modules/hlc_tft_display/hlc_tft_display.c +++ b/users/halcyon_modules/hlc_tft_display/hlc_tft_display.c @@ -5,7 +5,7 @@ #include "hlc_tft_display.h" #include "qp_surface.h" -#include +#include "hardware/structs/rosc.h" // Fonts mono2 #include "graphics/fonts/Retron2000-27.qff.h" @@ -54,6 +54,15 @@ bool grid[GRID_HEIGHT][GRID_WIDTH]; // Current state bool new_grid[GRID_HEIGHT][GRID_WIDTH]; // Next state bool changed_grid[GRID_HEIGHT][GRID_WIDTH]; // Tracks changed cells +uint32_t get_random_32bit(void) { + uint32_t random_value = 0; + for (int i = 0; i < 32; i++) { + wait_ms(1); + random_value = (random_value << 1) | (rosc_hw->randombit & 1); + } + return random_value; +} + void init_grid() { // Initialize grid with alive cells for (int y = 0; y < GRID_HEIGHT; y++) { @@ -284,7 +293,7 @@ bool display_module_housekeeping_task_kb(bool second_display) { static uint32_t previous_matrix_activity_time = 0; if(!second_display_set) { - srand(time(NULL)); + srand(get_random_32bit()); init_grid(); color_value = rand() % 8; second_display_set = true;