From d5a0f87f915af817034c2a73a9fe7743917a9cdc Mon Sep 17 00:00:00 2001 From: Klemek Date: Mon, 11 Mar 2024 20:54:01 +0100 Subject: [PATCH] shinies --- watchfaces/pokemon-2.0/Watchy_Pokemon.cpp | 22 ++++++++++++++++------ watchfaces/pokemon-2.0/Watchy_Pokemon.h | 8 ++++---- 2 files changed, 20 insertions(+), 10 deletions(-) mode change 100755 => 100644 watchfaces/pokemon-2.0/Watchy_Pokemon.h diff --git a/watchfaces/pokemon-2.0/Watchy_Pokemon.cpp b/watchfaces/pokemon-2.0/Watchy_Pokemon.cpp index 7a9aeaa..34502f8 100644 --- a/watchfaces/pokemon-2.0/Watchy_Pokemon.cpp +++ b/watchfaces/pokemon-2.0/Watchy_Pokemon.cpp @@ -36,14 +36,18 @@ void WatchyPokemon::drawWatchFace(){ display.setFont(&FreeMonoBold7pt7b); display.setTextColor(GxEPD_BLACK); - int pkm1_id = int(randomDay() * 151); - int pkm2_id = int(randomHour() * 151); + int pkm1_id = int(randomDay(0) * 151); + bool pkm1_shiny = int(randomDay(8231) * 4096) == 0; + int pkm2_id = int(randomHour(0) * 151); + bool pkm2_shiny = int(randomHour(3872) * 4096) == 0; // PKM display.drawBitmap(10, 60, pokemon_back[pkm1_id], 80, 68, GxEPD_BLACK); display.setCursor(100, 90); display.print(pokemon_names[pkm1_id]); + if (pkm1_shiny) + display.print('*'); display.setCursor(130, 100); #ifdef FR @@ -63,6 +67,8 @@ void WatchyPokemon::drawWatchFace(){ display.setCursor(20, 20); display.print(pokemon_names[pkm2_id]); + if (pkm2_shiny) + display.print('*'); display.setCursor(50, 30); #ifdef FR @@ -107,7 +113,7 @@ void WatchyPokemon::drawWatchFace(){ display.print(currentTime.Minute); // CURSOR - int pos = int(randomMinute() * 4); + int pos = int(randomMinute(0) * 4); int posX = pos % 2; int posY = int(pos / 2); #ifdef FR @@ -117,13 +123,15 @@ void WatchyPokemon::drawWatchFace(){ #endif } -double WatchyPokemon::randomMinute() +double WatchyPokemon::randomMinute(uint32_t d) { uint32_t seed = currentTime.Year; seed = seed * 12 + currentTime.Month; seed = seed * 31 + currentTime.Day; seed = seed * 24 + currentTime.Hour; seed = seed * 60 + currentTime.Minute; + seed += d; + double v = pow(seed, 6.0 / 7.0); v *= sin(v) + 1; @@ -131,12 +139,13 @@ double WatchyPokemon::randomMinute() return v - floor(v); } -double WatchyPokemon::randomHour() +double WatchyPokemon::randomHour(uint32_t d) { uint32_t seed = currentTime.Year; seed = seed * 12 + currentTime.Month; seed = seed * 31 + currentTime.Day; seed = seed * 24 + currentTime.Hour; + seed += d; double v = pow(seed, 6.0 / 7.0); v *= sin(v) + 1; @@ -144,11 +153,12 @@ double WatchyPokemon::randomHour() return v - floor(v); } -double WatchyPokemon::randomDay() +double WatchyPokemon::randomDay(uint32_t d) { uint32_t seed = currentTime.Year; seed = seed * 12 + currentTime.Month; seed = seed * 31 + currentTime.Day; + seed += d; double v = pow(seed, 6.0 / 7.0); v *= sin(v) + 1; diff --git a/watchfaces/pokemon-2.0/Watchy_Pokemon.h b/watchfaces/pokemon-2.0/Watchy_Pokemon.h old mode 100755 new mode 100644 index d3a7d28..c6a9dda --- a/watchfaces/pokemon-2.0/Watchy_Pokemon.h +++ b/watchfaces/pokemon-2.0/Watchy_Pokemon.h @@ -19,9 +19,9 @@ class WatchyPokemon : public WatchySynced using WatchySynced::WatchySynced; public: void drawWatchFace(); - double randomDay(); - double randomHour(); - double randomMinute(); + double randomDay(uint32_t d); + double randomHour(uint32_t d); + double randomMinute(uint32_t d); }; -#endif \ No newline at end of file +#endif