docs: Add an Application Library chapter
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
parent
7015dc0023
commit
06f1ed36b0
6 changed files with 80 additions and 24 deletions
39
docs/apps.rst
Normal file
39
docs/apps.rst
Normal file
|
@ -0,0 +1,39 @@
|
|||
.. _Application Library:
|
||||
|
||||
Application Library
|
||||
===================
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Built-in
|
||||
--------
|
||||
|
||||
The built-in application are summarised below but since these apps are
|
||||
considers to be examples they are described in detail as part of the
|
||||
:ref:`Wasp-os Reference Manual`:
|
||||
|
||||
* :py:class:`.ClockApp`
|
||||
* :py:class:`.FlashlightApp`
|
||||
* :py:class:`.LauncherApp`
|
||||
* :py:class:`.PagerApp`
|
||||
* :py:class:`.TestApp`
|
||||
* :py:class:`.TemplateApp``
|
||||
|
||||
Watch faces
|
||||
-----------
|
||||
|
||||
.. automodule:: apps.fibonacci_clock
|
||||
|
||||
This is enabled by default in the simulator. The app is bundled in the
|
||||
firmware image but it is disabled by default to keep RAM available for
|
||||
user developed applications. It can be enabled by modifying ``main.py``.
|
||||
|
||||
Games
|
||||
-----
|
||||
|
||||
.. automodule:: apps.gameoflife
|
||||
|
||||
This is enabled by default in the simulator. The app is bundled in the
|
||||
firmware image but it is disabled by default to keep RAM available for
|
||||
user developed applications. It can be enabled by modifying ``main.py``.
|
|
@ -12,6 +12,7 @@ Welcome to WASP-OS's documentation!
|
|||
|
||||
README
|
||||
install
|
||||
apps
|
||||
appguide
|
||||
wasp
|
||||
contributing
|
||||
|
|
|
@ -63,9 +63,6 @@ Applications
|
|||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. automodule:: apps.fibonacci_clock
|
||||
:members:
|
||||
|
||||
.. automodule:: apps.flashlight
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
|
|
@ -9,6 +9,11 @@ mathematician Fibonacci in the 13th century. This is a sequence starting with
|
|||
1 and 1, where each subsequent number is the sum of the previous two. For the
|
||||
clock I used the first 5 terms: 1, 1, 2, 3 and 5.
|
||||
|
||||
.. figure:: res/FiboApp.png
|
||||
:width: 179
|
||||
|
||||
Screenshot of the fibonacci clock application
|
||||
|
||||
The screen of the clock is made up of five squares whose side lengths match
|
||||
the first five Fibonacci numbers: 1, 1, 2, 3 and 5. The hours are displayed
|
||||
using red and the minutes using green. When a square is used to display both
|
||||
|
@ -51,12 +56,7 @@ icon = (
|
|||
)
|
||||
|
||||
class FibonacciClockApp():
|
||||
"""Displays the time as a Fibonacci Clock
|
||||
|
||||
.. figure:: res/FiboApp.png
|
||||
:width: 179
|
||||
|
||||
Screenshot of the fibonacci clock application
|
||||
"""Displays the time as a Fibonacci Clock.
|
||||
"""
|
||||
NAME = 'Fibo'
|
||||
ICON = icon
|
||||
|
|
|
@ -1,6 +1,28 @@
|
|||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
# Copyright (C) 2020 Daniel Thompson
|
||||
"""Conway's Game of Life.
|
||||
"""Conway's Game of Life
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The Game of Life is a "no player game" played on a two dimensional grid
|
||||
where the rules interact to make interesting patterns.
|
||||
|
||||
.. figure:: res/LifeApp.png
|
||||
:width: 179
|
||||
|
||||
Screenshot of the Game of Life application
|
||||
|
||||
The game is based on four simple rules:
|
||||
|
||||
1. Death by isolation: a cell dies if has fewer than two live neighbours.
|
||||
|
||||
2. Death by overcrowding: a cell dies if it has more than three live
|
||||
neighbours.
|
||||
|
||||
3. Survival: a living cell continues to survive if it has two or three
|
||||
neighbours.
|
||||
|
||||
4. Reproduction: a dead cell comes alive if it has exactly three
|
||||
neighbours.
|
||||
|
||||
On 11 April 2020 John H. Conway who, among many, many other
|
||||
achievements, devised the rule set for his Game of Life, died of
|
||||
|
@ -71,20 +93,10 @@ def set_cell(board, stride: int, x: int, y: int, v: bool):
|
|||
def game_of_life(b, xmax: int, ymax: int, nb):
|
||||
"""Run a single generation of Conway's Game of Life
|
||||
|
||||
1. Death by isolation: a cell dies if has fewer than two live neighbours.
|
||||
|
||||
2. Death by overcrowding: a cell dies if it has more than three live
|
||||
neighbours.
|
||||
|
||||
3. Survival: a living cell continues to survive if it has two or three
|
||||
neighbours.
|
||||
|
||||
4. Reproduction: a dead cell comes alive if it has exactly three
|
||||
neighbours.
|
||||
|
||||
In the code below we have simplified the above rules to "a cell is
|
||||
alive it has three live neighbours or if it was previously alive
|
||||
and has two neighbours, otherwise it is dead.".
|
||||
In the code below we have simplified the rules described at the top
|
||||
of this file to "a cell is alive it has three live neighbours or if
|
||||
it was previously alive and has two neighbours, otherwise it is
|
||||
dead.".
|
||||
"""
|
||||
board = ptr32(b)
|
||||
next_board = ptr32(nb)
|
||||
|
|
|
@ -2,4 +2,11 @@
|
|||
# Copyright (C) 2020 Daniel Thompson
|
||||
|
||||
import wasp
|
||||
|
||||
from apps.fibonacci_clock import FibonacciClockApp
|
||||
wasp.system.register(FibonacciClockApp())
|
||||
|
||||
from apps.gameoflife import GameOfLifeApp
|
||||
wasp.system.register(GameOfLifeApp())
|
||||
|
||||
wasp.system.run()
|
||||
|
|
Loading…
Reference in a new issue