Soundboard uses common lfsr rand()

This commit is contained in:
furrtek 2016-09-23 12:20:36 +02:00
parent d8a0b9c2de
commit 8c0ff7f9c0
4 changed files with 9 additions and 17 deletions

View File

@ -27,15 +27,16 @@
#include "ch.h"
#include "file.hpp"
#include "lfsr_random.hpp"
#include "ui_alphanum.hpp"
#include "ff.h"
#include "hackrf_gpio.hpp"
//#include "ff.h"
//#include "hackrf_gpio.hpp"
#include "portapack.hpp"
#include "radio.hpp"
#include "event_m0.hpp"
//#include "radio.hpp"
//#include "event_m0.hpp"
#include "string_format.hpp"
#include "hackrf_hal.hpp"
//#include "hackrf_hal.hpp"
#include "portapack_shared_memory.hpp"
#include <cstring>
@ -45,20 +46,12 @@ using namespace portapack;
namespace ui {
uint16_t SoundBoardView::shitty_rand() {
uint8_t bit;
bit = ((lfsr >> 0) ^ (lfsr >> 2) ^ (lfsr >> 3) ^ (lfsr >> 5) ) & 1;
return lfsr = (lfsr >> 1) | (bit << 15);
}
void SoundBoardView::do_random() {
uint16_t id;
chThdSleepMilliseconds(300); // 100ms
chThdSleepMilliseconds(300); // 300ms
id = shitty_rand() % max_sound;
id = lfsr_iterate(lfsr_v) % max_sound;
play_sound(id);

View File

@ -68,7 +68,7 @@ private:
File file;
uint16_t lfsr = 0x1337u;
uint16_t lfsr_v = 0x1337;
sound sounds[100];
uint8_t max_sound;
@ -103,7 +103,6 @@ private:
void on_tuning_frequency_changed(rf::Frequency f);
void do_random();
uint16_t shitty_rand();
void show_infos(uint16_t id);
void change_page(Button& button, const KeyEvent key);
void refresh_buttons(uint16_t id);

Binary file not shown.

Binary file not shown.