|
@@ -20,13 +20,13 @@
|
|
|
#include "print.h"
|
|
|
|
|
|
|
|
|
-#define TWINKLE_PROBABILITY_MODULATOR 100 / TWINKLE_PROBABILITY
|
|
|
-#define TOTAL_STARS STARS_PER_LINE *NUMBER_OF_STAR_LINES
|
|
|
-#define OCEAN_ANIMATION_MODULATOR NUMBER_OF_FRAMES / OCEAN_ANIMATION_SPEED
|
|
|
-#define SHOOTING_STAR_ANIMATION_MODULATOR NUMBER_OF_FRAMES / SHOOTING_STAR_ANIMATION_SPEED
|
|
|
-#define STAR_ANIMATION_MODULATOR NUMBER_OF_FRAMES / STAR_ANIMATION_SPEED
|
|
|
+#define TWINKLE_PROBABILITY_MODULATOR 100 / TWINKLE_PROBABILITY
|
|
|
+#define TOTAL_STARS STARS_PER_LINE *NUMBER_OF_STAR_LINES
|
|
|
+#define OCEAN_ANIMATION_MODULATOR NUMBER_OF_FRAMES / OCEAN_ANIMATION_SPEED
|
|
|
+#define SHOOTING_STAR_ANIMATION_MODULATOR NUMBER_OF_FRAMES / SHOOTING_STAR_ANIMATION_SPEED
|
|
|
+#define STAR_ANIMATION_MODULATOR NUMBER_OF_FRAMES / STAR_ANIMATION_SPEED
|
|
|
|
|
|
-uint8_t animation_counter = 0;
|
|
|
+uint8_t animation_counter = 0;
|
|
|
bool is_calm = false;
|
|
|
uint32_t starry_night_anim_timer = 0;
|
|
|
uint32_t starry_night_anim_sleep = 0;
|
|
@@ -52,10 +52,10 @@ static uint8_t decrement_counter(uint8_t counter, uint8_t max) {
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
-#ifdef ENABLE_MOON
|
|
|
+#ifdef ENABLE_MOON
|
|
|
# ifndef STATIC_MOON
|
|
|
-uint8_t moon_animation_frame = 0;
|
|
|
-uint16_t moon_animation_counter = 0;
|
|
|
+uint8_t moon_animation_frame = 0;
|
|
|
+uint16_t moon_animation_counter = 0;
|
|
|
# endif
|
|
|
|
|
|
# ifdef STATIC_MOON
|
|
@@ -99,9 +99,9 @@ static void draw_moon(void) {
|
|
|
}
|
|
|
# endif
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
-#ifdef ENABLE_WAVE
|
|
|
+#ifdef ENABLE_WAVE
|
|
|
uint8_t starry_night_wave_frame_width_counter = 31;
|
|
|
uint8_t rough_waves_frame_counter = 0;
|
|
|
|
|
@@ -193,8 +193,8 @@ static const char PROGMEM ocean_bottom[8][32] = {
|
|
|
|
|
|
|
|
|
static void animate_waves(void) {
|
|
|
- starry_night_wave_frame_width_counter = decrement_counter(starry_night_wave_frame_width_counter, WIDTH - 1);
|
|
|
- rough_waves_frame_counter = increment_counter(rough_waves_frame_counter, 3);
|
|
|
+ starry_night_wave_frame_width_counter = decrement_counter(starry_night_wave_frame_width_counter, WIDTH - 1);
|
|
|
+ rough_waves_frame_counter = increment_counter(rough_waves_frame_counter, 3);
|
|
|
|
|
|
void draw_ocean(uint8_t frame, uint16_t offset, uint8_t byte_index) {
|
|
|
oled_write_raw_byte(pgm_read_byte(ocean_top[frame] + byte_index), offset);
|
|
@@ -218,9 +218,9 @@ static void animate_waves(void) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
-#ifdef ENABLE_ISLAND
|
|
|
+#ifdef ENABLE_ISLAND
|
|
|
uint8_t island_frame_1 = 0;
|
|
|
|
|
|
|
|
@@ -276,17 +276,17 @@ static void animate_island(void) {
|
|
|
draw_island_parts(island_frame_1 + 4);
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
-#ifdef ENABLE_STARS
|
|
|
-bool stars_setup = false;
|
|
|
+#ifdef ENABLE_STARS
|
|
|
+bool stars_setup = false;
|
|
|
struct Coordinate {
|
|
|
int x;
|
|
|
int y;
|
|
|
bool exists;
|
|
|
};
|
|
|
|
|
|
-struct Coordinate stars[TOTAL_STARS];
|
|
|
+struct Coordinate stars[TOTAL_STARS];
|
|
|
|
|
|
|
|
|
* Setup all the initial stars on the screen
|
|
@@ -334,18 +334,18 @@ static void twinkle_stars(void) {
|
|
|
continue;
|
|
|
}
|
|
|
if (rand() % TWINKLE_PROBABILITY_MODULATOR == 0) {
|
|
|
- oled_write_pixel(star.x, star.y, false);
|
|
|
+ oled_write_pixel(star.x, star.y, false);
|
|
|
|
|
|
|
|
|
- if (star.x == (column_group * 8)) {
|
|
|
- star.x++;
|
|
|
- } else if (star.x == (((column_group + 1) * 8) - 1)) {
|
|
|
- star.x--;
|
|
|
+ if (star.x == (column_group * 8)) {
|
|
|
+ star.x++;
|
|
|
+ } else if (star.x == (((column_group + 1) * 8) - 1)) {
|
|
|
+ star.x--;
|
|
|
}
|
|
|
- if (star.y == (line * 8)) {
|
|
|
- star.y++;
|
|
|
- } else if (star.y == (((line + 1) * 8) - 1)) {
|
|
|
- star.y--;
|
|
|
+ if (star.y == (line * 8)) {
|
|
|
+ star.y++;
|
|
|
+ } else if (star.y == (((line + 1) * 8) - 1)) {
|
|
|
+ star.y--;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -389,10 +389,10 @@ static void animate_stars(void) {
|
|
|
twinkle_stars();
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
-#ifdef ENABLE_SHOOTING_STARS
|
|
|
-bool shooting_stars_setup = false;
|
|
|
+#ifdef ENABLE_SHOOTING_STARS
|
|
|
+bool shooting_stars_setup = false;
|
|
|
|
|
|
struct ShootingStar {
|
|
|
int x_1;
|
|
@@ -404,11 +404,11 @@ struct ShootingStar {
|
|
|
int delay;
|
|
|
};
|
|
|
|
|
|
-struct ShootingStar shooting_stars[MAX_NUMBER_OF_SHOOTING_STARS];
|
|
|
+struct ShootingStar shooting_stars[MAX_NUMBER_OF_SHOOTING_STARS];
|
|
|
|
|
|
static void setup_shooting_star(struct ShootingStar *shooting_star) {
|
|
|
int column_to_start = rand() % (WIDTH / 2);
|
|
|
- int row_to_start = rand() % (HEIGHT - 48);
|
|
|
+ int row_to_start = rand() % (HEIGHT - 48);
|
|
|
|
|
|
shooting_star->x_1 = column_to_start;
|
|
|
shooting_star->y_1 = row_to_start;
|
|
@@ -494,7 +494,7 @@ static void animate_shooting_stars(void) {
|
|
|
end_extra_stars(number_of_shooting_stars);
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
* Main rendering function
|
|
@@ -502,52 +502,53 @@ static void animate_shooting_stars(void) {
|
|
|
* Calls all different animations at different rates
|
|
|
*/
|
|
|
void render_stars(void) {
|
|
|
-
|
|
|
- if (timer_elapsed32(starry_night_anim_timer) > STARRY_NIGHT_ANIM_FRAME_DURATION) {
|
|
|
- starry_night_anim_timer = timer_read32();
|
|
|
- current_wpm = get_current_wpm();
|
|
|
+ current_wpm = get_current_wpm();
|
|
|
|
|
|
+ void render_stars_anim(void) {
|
|
|
#ifdef ENABLE_ISLAND
|
|
|
- animate_island();
|
|
|
+ animate_island();
|
|
|
#endif
|
|
|
|
|
|
#ifdef ENABLE_SHOOTING_STARS
|
|
|
- if (animation_counter % SHOOTING_STAR_ANIMATION_MODULATOR == 0) {
|
|
|
- animate_shooting_stars();
|
|
|
- }
|
|
|
+ if (animation_counter % SHOOTING_STAR_ANIMATION_MODULATOR == 0) {
|
|
|
+ animate_shooting_stars();
|
|
|
+ }
|
|
|
#endif
|
|
|
|
|
|
#ifdef ENABLE_STARS
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if (animation_counter % STAR_ANIMATION_MODULATOR == 0) {
|
|
|
- animate_stars();
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (animation_counter % STAR_ANIMATION_MODULATOR == 0) {
|
|
|
+ animate_stars();
|
|
|
+ }
|
|
|
#endif
|
|
|
|
|
|
#ifdef ENABLE_WAVE
|
|
|
- if (animation_counter % OCEAN_ANIMATION_MODULATOR == 0) {
|
|
|
- animate_waves();
|
|
|
- }
|
|
|
+ if (animation_counter % OCEAN_ANIMATION_MODULATOR == 0) {
|
|
|
+ animate_waves();
|
|
|
+ }
|
|
|
#endif
|
|
|
|
|
|
#ifdef ENABLE_MOON
|
|
|
- draw_moon();
|
|
|
+ draw_moon();
|
|
|
#endif
|
|
|
|
|
|
- animation_counter = increment_counter(animation_counter, NUMBER_OF_FRAMES);
|
|
|
+ animation_counter = increment_counter(animation_counter, NUMBER_OF_FRAMES);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if (current_wpm > 0) {
|
|
|
+
|
|
|
+
|
|
|
+ if (current_wpm > 0 && timer_elapsed32(starry_night_anim_timer) > STARRY_NIGHT_ANIM_FRAME_DURATION) {
|
|
|
+ starry_night_anim_timer = timer_read32();
|
|
|
oled_on();
|
|
|
+ render_stars_anim();
|
|
|
starry_night_anim_sleep = timer_read32();
|
|
|
} else if (timer_elapsed32(starry_night_anim_sleep) > OLED_TIMEOUT) {
|
|
|
oled_off();
|