Usually, images are static, so they can be computed in advance instead of during runtime. This makes scripts smaller and much more memory efficient.
For example, now you can say:
HOUSE = 4685823
hub.grid.image(HOUSE)
since 4685823 =
```
0 0 1 0 0
0 1 1 1 0
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
```
We could also choose the binary format to allow for more generic screen sizes. If we allow a bit more space (2 words instead of 1), we could do 1 byte per row to allow screens up to 8x8. Right now, though, we choose 1 word < 31 bits which is a bit more efficient in MicroPython.
We can easily list numerous example in the docs or provide a simple visual calculator.
There is still a matrix method that takes a 2D matrix of intensities for full control during runtime, which is what the image() method was doing initially. This commit renames the old draft to matrix().
Intellisense in VS Code (both jedi and ms python language server) picks
up all imported names and suggests them with equal priority for
code completion. By adding a leading underscore, intellisense lists
these with a lower priority, so they don't get in the way.
Also rename from builtins to _common while we are touching this to
better reflect the intention of the module (it contains types shared
by multiple modules, not builtin types like int).
Because this module describes devices that can be built into a hub or other device.
Since this design is now explicitly shown in
the docs as well, we don't need to hide this
module in the package.
This makes the user code easier to read:
brick.buttons()
brick.buttons.pressed()
It also opens up possibility to add features in the future such as:
brick.buttons.released() # return which buttons are not pressed
brick.buttons.clicked() # return which buttons were clicked since we last checked
This follows the same style as the new light API: some devices have specific instances of a KeyPad class.
A good example that nicely demonstrates the concept is the LPF2 RemoteControl, which has instances of a ColorLight and a KeyPad. It's added in this commit.
Same result as in 92e3735d63, but now achieved by patching the Sphinx configuration instead of patching the API.
Now it doesn't break the API for the purpose of checking and autocomplete, etc.
This is an experimental method for adding lights to some sensors.
And add workaround to make it show up correctly in the docs.
Also some doc8 formatting