mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-25 07:19:28 -05:00
Use std:rand() in Touchscreen Test (#1840)
This commit is contained in:
parent
ee2e57d702
commit
464cc8449e
@ -552,6 +552,7 @@ void DebugPmemView::update() {
|
|||||||
DebugScreenTest::DebugScreenTest(NavigationView& nav)
|
DebugScreenTest::DebugScreenTest(NavigationView& nav)
|
||||||
: nav_{nav} {
|
: nav_{nav} {
|
||||||
set_focusable(true);
|
set_focusable(true);
|
||||||
|
std::srand(LPC_RTC->CTIME0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebugScreenTest::on_key(const KeyEvent key) {
|
bool DebugScreenTest::on_key(const KeyEvent key) {
|
||||||
@ -561,10 +562,10 @@ bool DebugScreenTest::on_key(const KeyEvent key) {
|
|||||||
nav_.pop();
|
nav_.pop();
|
||||||
break;
|
break;
|
||||||
case KeyEvent::Down:
|
case KeyEvent::Down:
|
||||||
painter.fill_rectangle({0, 0, screen_width, screen_height}, semirand());
|
painter.fill_rectangle({0, 0, screen_width, screen_height}, std::rand());
|
||||||
break;
|
break;
|
||||||
case KeyEvent::Left:
|
case KeyEvent::Left:
|
||||||
pen_color = semirand();
|
pen_color = std::rand();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -584,17 +585,10 @@ bool DebugScreenTest::on_touch(const TouchEvent event) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t DebugScreenTest::semirand() {
|
|
||||||
static uint64_t seed{0x0102030405060708};
|
|
||||||
seed = seed * 137;
|
|
||||||
seed = (seed >> 1) | ((seed & 0x01) << 63);
|
|
||||||
return (uint16_t)seed;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebugScreenTest::paint(Painter& painter) {
|
void DebugScreenTest::paint(Painter& painter) {
|
||||||
painter.fill_rectangle({0, 16, screen_width, screen_height - 16}, Color::white());
|
painter.fill_rectangle({0, 16, screen_width, screen_height - 16}, Color::white());
|
||||||
painter.draw_string({10 * 8, screen_height / 2}, Styles::white, "Use Stylus");
|
painter.draw_string({10 * 8, screen_height / 2}, Styles::white, "Use Stylus");
|
||||||
pen_color = semirand();
|
pen_color = std::rand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DebugLCRView *******************************************************/
|
/* DebugLCRView *******************************************************/
|
||||||
|
@ -385,7 +385,6 @@ class DebugScreenTest : public View {
|
|||||||
bool on_key(KeyEvent key) override;
|
bool on_key(KeyEvent key) override;
|
||||||
bool on_encoder(EncoderEvent delta) override;
|
bool on_encoder(EncoderEvent delta) override;
|
||||||
bool on_touch(TouchEvent event) override;
|
bool on_touch(TouchEvent event) override;
|
||||||
uint16_t semirand();
|
|
||||||
void paint(Painter& painter) override;
|
void paint(Painter& painter) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user