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.

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