mirror of
https://github.com/qmk/qmk_userspace.git
synced 2025-09-21 19:29:46 -04:00
Add more randomness
This commit is contained in:
parent
b21425c33a
commit
29a6cb62ec
1 changed files with 11 additions and 2 deletions
|
@ -5,7 +5,7 @@
|
|||
#include "hlc_tft_display.h"
|
||||
|
||||
#include "qp_surface.h"
|
||||
#include <time.h>
|
||||
#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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue