You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

258 lines
11 KiB

  1. # Ocean Dream
  2. Tapping away at your IMX Corne with Box Jades, you feel yourself
  3. drifting off, into a soundscape of waves and rustling leaves.
  4. You open your eyes only to find yourself in an _Ocean Dream_.
  5. Introducing, **Ocean Dream**, an animation for keyboards with tall OLED
  6. screens. Built for 128x32 screens, this animation should work for 128x64
  7. at least, though it hasn't been tested there.
  8. Completely customizable, you can change everything about the animation,
  9. from the number of falling stars, to how likely a star is to twinkle, and
  10. even if the moon has phases or not.
  11. # Installation
  12. Installation is easy.
  13. 1. Add `ocean.h` and `ocean.c` to your keyboard folder or userspace.
  14. 2. In your `keymap.c` or wherever you handle your oled code, add
  15. ```c
  16. # ifdef OCEAN_DREAM_ENABLE
  17. render_stars();
  18. # endif
  19. ```
  20. to `oled_task_user(void)`, where you would like (see [my keymap](../../keyboards/crkbd/keymaps/snowe/keymap.c) for an example)
  21. 3. In your `keymap.c` or wherever you handle your process_record code,
  22. add an event that sets `is_calm` when you press `ctrl`
  23. ```c
  24. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  25. switch (keycode) {
  26. case KC_LCTL:
  27. case KC_RCTL:
  28. #ifdef OCEAN_DREAM_ENABLE
  29. is_calm = (record->event.pressed) ? true : false;
  30. #endif
  31. break;
  32. }
  33. return true;
  34. }
  35. ```
  36. 4. In your `rules.mk` to make it easier to turn the animation on/off, add
  37. ```makefile
  38. ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
  39. #... your code here...
  40. ifdef OCEAN_DREAM_ENABLE
  41. ifeq ($(strip $(OCEAN_DREAM_ENABLE)), yes)
  42. SRC += ocean_dream.c
  43. OPT_DEFS += -DOCEAN_DREAM_ENABLE
  44. endif
  45. endif
  46. ifndef OCEAN_DREAM_ENABLE
  47. SRC += ocean_dream.c
  48. OPT_DEFS += -DOCEAN_DREAM_ENABLE
  49. endif
  50. endif
  51. ```
  52. You're done! Now you can enable **Ocean Dream** by simply turning on the OLED feature
  53. ```makefile
  54. OLED_DRIVER_ENABLE = yes
  55. ```
  56. And if you want to disable it without turning off the OLED Driver you can simply set
  57. ```makefile
  58. OCEAN_DREAM_ENABLE = no
  59. ```
  60. # Settings
  61. **Ocean Dream** comes with several different animations, all individually configurable:
  62. * 🌌 Stars that twinkle
  63. * 🌠 Meteor showers that get more vibrant the faster you type
  64. * 🌊 Waves that get rougher the faster you type
  65. * 🏝 An island with a palm tree that blows in the wind the faster you type
  66. * 🌗 A moon that goes through the moon phases (or not, your choice!)
  67. Each feature can be individually turned on and off, with a simple `#define`.
  68. You can see all the options and more documentation by looking at `ocean_dream.h`.
  69. All options come enabled by default.
  70. ## Global Flags:
  71. ### Toggles:
  72. You can toggle on/off any features using these flags:
  73. * `ENABLE_MOON` // Uses 182 bytes
  74. * `ENABLE_WAVE` // Uses 844 bytes
  75. * `ENABLE_SHOOTING_STARS` // Uses 872 bytes
  76. * `ENABLE_ISLAND`
  77. * `ENABLE_STARS` // Uses 606 bytes
  78. ### Global Configuration:
  79. * `STARRY_NIGHT_ANIM_FRAME_DURATION` - configures how long each frame lasts in ms
  80. * `NUMBER_OF_FRAMES` - configures the number of frames that constitute a single 'round trip' of animation.
  81. Enables keeping animations in sync/timed with each other.
  82. Probably shouldn't touch this, not sure how stuff will work if it's changed.
  83. If changed should probably be multiple of 1, 2, 3, 4, and 5
  84. * `WIDTH` - for vertical displays, configures the width (the shortest measurement of your display). defaults to `OLED_DISPLAY_HEIGHT`
  85. * `HEIGHT` - for vertical displays, configures the height (the longest measurement of your display). defaults to `OLED_DISPLAY_WIDTH`
  86. ## Stars
  87. ### Description
  88. The 🌌 stars animation is a background of slowly twinkling stars.
  89. The stars are built on a grid of sorts, where each cell of the grid
  90. is 8x8 pixels with 1 star per cell. There is a probability of any
  91. star twinkling on any given frame, decided by the corresponding flags.
  92. ### Flags
  93. Enabled with the `#define ENABLE_STARS` directive.
  94. The stars come with several configuration options:
  95. * `STARS_PER_LINE` - configures the number of stars per line. Defaulting to 4, this would
  96. mean that you have 4 stars across each line (8x32 on a 128x32 display), where each star
  97. is in a 8x8 grid
  98. * `NUMBER_OF_STAR_LINES` - configures the number of lines to fill up with stars.
  99. Defaults to 16, filling the whole display.
  100. * `TWINKLE_PROBABILITY` - configures the probability of a star twinkling on a given frame.
  101. * `STAR_ANIMATION_SPEED` - configures the number of frames you want to animate the star at.
  102. Must be equal to or lower than `NUMBER_OF_FRAMES`.
  103. Example:
  104. ```c
  105. #define NUMBER_OF_FRAMES 20
  106. #define STAR_ANIMATION_SPEED 5
  107. ```
  108. would result in the star animation happening every 4 frames. 20 would result in every frame,
  109. 1 would be once every 20 frames. This essentially changes how fast stars will twinkle, but
  110. does not change the probability of the stars twinkling.
  111. ## Moon
  112. ### Description
  113. The 🌗 moon animation is an 8x8 animation of a moon, or, if you are running out of program memory, you
  114. can set it to just a static crescent moon, with no animation.
  115. ### Flags
  116. Enabled with the `#define ENABLE_MOON` directive.
  117. The moon comes with only a few configuration options:
  118. * `STATIC_MOON` - include this directive if you want your moon to have no animation. It will simply be a static crescent
  119. moon, only taking up 6 bytes of space. If you do not include this directive, then the moon will have an animation.
  120. The default is a moon with animation.
  121. * `MOON_LINE` - defines the line that the moon sits on. Default is `4`. (see [reference](#reference))
  122. * `MOON_COLUMN` - defines the column that the moon sits at. Default is `4`. (see [reference](#reference))
  123. * `ANIMATE_MOON_EVERY_N_FRAMES` - only enabled when `STATIC_MOON` is disabled, this affects how often the moon changes phases.
  124. Example:
  125. ```c
  126. #define STARRY_NIGHT_ANIM_FRAME_DURATION 30
  127. #ifndef STATIC_MOON
  128. # define ANIMATE_MOON_EVERY_N_FRAMES 100
  129. #endif
  130. ```
  131. would result in the moon changing phases every 3000ms, or every 3 seconds.
  132. ## Ocean
  133. ### Description
  134. The 🌊 ocean animation is a full width animation of ocean waves, where the waves get rougher the faster you type.
  135. You can configure the boundaries for each degree of _wave ferocity_ as well as how fast the ocean/waves move.
  136. ### Flags
  137. * `OCEAN_LINE` - where to render the ocean at. Defaults to `14`. (see [reference](#reference))
  138. * `OCEAN_ANIMATION_SPEED` - configures the number of frames you want to animate the ocean at.
  139. Must be equal to or lower than `NUMBER_OF_FRAMES`.
  140. Example:
  141. ```c
  142. #define NUMBER_OF_FRAMES 20
  143. #define OCEAN_ANIMATION_SPEED 5
  144. ```
  145. would result in the ocean animation happening every 4 frames. 20 would result in every frame,
  146. 1 would be once every 20 frames. This essentially changes how fast the waves will move.
  147. * `WAVE_CALM` - Defines the WPM at which the _Wave Ferocity_ kicks up.
  148. At any WPM between `WAVE_CALM` and `WAVE_HEAVY_STORM`, the waves will be just tiny ripples.
  149. * `WAVE_HEAVY_STORM` - Defines the WPM at which the _Wave Ferocity_ kicks up to medium.
  150. At any WPM between `WAVE_HEAVY_STORM` and `WAVE_HURRICANE`, the waves will be medium sized waves.
  151. * `WAVE_HURRICANE` - Defines the WPM at which the _Wave Ferocity_ kicks up to the last notch.
  152. At any WPM above `WAVE_HURRICANE`, the waves will be torrential.
  153. ## Shooting Stars
  154. The 🌠 shooting star animation is a full screen animation that renders a meteor shower based on your typing speed. The
  155. faster you type, the more shooting stars there are!
  156. You can configure many parts of the shooting stars, from shower size, to speed, to length of each trail, to how spaced
  157. out they are.
  158. Note: Each frame of a shooting star is only 2 pixels in length. This is a design decision, and could probably be changed
  159. with a decent amount of work, but was chosen for looks and memory constraints.
  160. ### Flags
  161. * `SHOOTING_STAR_DELAY` - Decides number of frames to delay, based on modulus, e.g. 12 means 0-11 frames of delay between each shooting star
  162. * `SHOOTING_STAR_FRAMES` - how long each shooting star will be. A size of `16` will result in shooting stars that are 32 pixels long
  163. * `MAX_NUMBER_OF_SHOOTING_STARS` - maximum number of shooting stars that can be on screen at the same time
  164. * `SHOOTING_STAR_WPM_INCREMENT` - every n WPM increase, add an extra star, up to MAX_NUMBER_OF_SHOOTING_STARS
  165. Example: an increment of 5 would result in 1 shooting star at 5-9wpm, 2 at 10-14, etc.
  166. * `SHOOTING_STAR_ANIMATION_SPEED` - configures the number of frames you want to animate the shooting stars at.
  167. Must be equal to or lower than `NUMBER_OF_FRAMES`.
  168. Example:
  169. ```c
  170. #define NUMBER_OF_FRAMES 20
  171. #define SHOOTING_STAR_ANIMATION_SPEED 5
  172. ```
  173. would result in the shooting star animation happening every 4 frames. 20 would result in every frame,
  174. 1 would be once every 20 frames. This essentially changes how fast the stars move through the sky.
  175. ## Island
  176. The 🏝 island animation is a 32w x 16h animation of a small island with a single palm tree blowing in the wind. The faster
  177. you type the harder the palm tree blows in the wind!
  178. Since this animation has significant black space to the left side of the tree, certain design decisions were made to allow the
  179. shooting stars to still show up in the sky there. This animation should work on any size screen >=32 pixels wide, and you
  180. can place it anywhere on the screen, but above the ocean is recommended.
  181. ### Flags
  182. * `ISLAND_LINE` - where to render the island at. Defaults to `12`. The island is 2 lines tall. (see [reference](#reference))
  183. * `ISLAND_COLUMN` - where to render the island at. Defaults to `0`. The island is 32 pixels wide. (see [reference](#reference))
  184. * `ISLAND_CALM` - Defines the WPM at which the _Storm Ferocity_ kicks up.
  185. At any WPM between `ISLAND_CALM` and `ISLAND_HEAVY_STORM`, the palm tree will just calmly blow in the wind.
  186. * `ISLAND_HEAVY_STORM` - Defines the WPM at which the _Storm Ferocity_ kicks up.
  187. At any WPM between `ISLAND_HEAVY_STORM` and `ISLAND_HURRICANE`, the palm tree will be blowing hard in the wind
  188. * `ISLAND_HURRICANE` - Defines the WPM at which the _Storm Ferocity_ kicks up.
  189. At any WPM above `ISLAND_HURRICANE`, the palm tree will almost be torn from its roots!
  190. # Reference
  191. Any reference to `_LINE` or `COLUMN` refers to setting a cursor position using `oled_set_cursor()`, which uses
  192. `OLED_FONT_WIDTH` and `OLED_FONT_HEIGHT` internally.
  193. This will be the top-leftmost pixel of the image, so `_LINE 1` would start at the 9th pixel down and `_COLUMN 1`
  194. would be the 7th pixel to the right, starting from the topleftmost pixel on the screen.
  195. This code has been untested with different font heights/widths, so you might have to adjust a bit to make it work if you
  196. have modified those values.
  197. # ToDo
  198. - [ ] don't require `is_calm` as a keyboard event. Not sure if the code will work without it currently.
  199. - [ ] make all the stars twinkle brightly based on keypresses rather than timed. Not just a movement twinkle, but a larger
  200. 'full' twinkle, where the star actually gets bigger. This will be quite difficult, thus is left out of the v1.