Commit Graph
550 Commits
Author SHA1 Message Date
Laurens Valk b8505ff218 api/_common/Light: introduce pattern
Currently, Pybricks has system patterns for builtin lights.
This adds a user method to set such a pattern.

For example, an indefinite sine pattern could be specified by

def fade(time):
    return sin(time/2000/pi)*50+50

hub.light.pattern(fade, 1000)

or a blinking pattern using

def blink(time):
    if time >= 1000:
        return 100
    else:
        return 0

hub.light.pattern(blink, 2000)

or briefly:

hub.light.pattern(lambda t: 100 if t >= 1000 else 0, 2000)

This combines the best of simplicity and efficiency: The user doesn't
have to calculate and provide an expensive list of floating points, but
provide a clean and adaptable method instead.
By sampling, we maintain a fixed length pattern which we can preallocate
for the hub lights, and the samples are calculated only once and the
callable may be garbage collected if given as lambda. Also, any
exceptions will be caught immediately during the one-off evaluation.
2020-07-07 09:44:16 +02:00
Laurens Valk 20fec6461a api/_common/LightGrid: make image more efficient
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().
2020-07-07 09:44:16 +02:00
Laurens Valk d66e18b113 api/pupdevices: add TiltSensor
This class and its methods are subject to change when the complete
API for IMUs is introduced.
2020-07-01 13:33:36 +02:00
Laurens Valk 55fe666dac api/pupdevices: add InfraredSensor 2020-07-01 12:02:13 +02:00
David Lechner 3554814c86 config: add Pybricks favicon 2020-06-17 13:38:22 -05:00
David Lechner fd75e94824 config: drop python 3.5 in CI build
python 3.6 is required for certain features we are using.
2020-06-17 13:13:14 -05:00
David Lechner 70cc605b56 config: update version to 3.0
We are working on the v3.0 release now.
2020-06-17 13:04:06 -05:00
Laurens Valk 0779b8df16 doc/pupdevices: workaround to show class attribute
We are using an older version of Sphinx which does not support
autodoc of inherited class attributes yet. This works
around it by just referencing the EV3 attribute, which does work.
2020-06-14 15:39:04 +02:00
Laurens Valk ecc30c2d92 doc/start_pup: add imports to example
This reflects a firmware update that makes it more consistent with
pybricks-micropython for EV3. Making imports explicit is also more
Pythonic. This will make it clearer when some classes are not available
on some hubs.
2020-06-09 14:28:32 +02:00
Laurens Valk 80840396aa api/pupdevices: add Powered Up Light 2020-06-08 15:26:19 +02:00
David Lechner c536081dea doc/start_pup: fix line too long lint error 2020-06-06 13:47:28 -05:00
David Lechner 87a488e790 doc/start_pup: update chrome download link
A new dev build was released for all platforms yesterday with the required patches.
2020-06-06 11:15:41 -05:00
Laurens Valk 90647e25dd doc/start_pup: update chrome release schedule 2020-06-05 16:17:23 +02:00
Laurens Valk 01c6e29dd5 doc/start_pup: add note about password 2020-06-05 15:56:04 +02:00
Laurens Valk 1eac0972ac api/hubs: add CPlusHub 2020-06-05 15:56:04 +02:00
Laurens Valk ce087f5330 doc/index: fix pup link 2020-06-05 15:56:04 +02:00
Laurens Valk 9e06245860 doc/pup_start: basic run instructions 2020-06-05 15:56:04 +02:00
Laurens Valk 4b9cedb444 doc/start_pup: add install instructions 2020-06-05 15:56:04 +02:00
Laurens Valk a99c4328fc doc/start_pup: explain firmware restore 2020-06-05 15:56:04 +02:00
Laurens Valk 07b4b5b783 doc/start_pup: instructions for permanent program 2020-06-05 15:56:04 +02:00
Laurens Valk 13be26443b doc/start_pup: add firmware install video 2020-06-05 15:56:04 +02:00
Laurens Valk ce993900d1 api/pupdevices: update illuminate argument
match the implementation and simplify description
2020-05-27 13:58:30 +02:00
Laurens Valk f604dd321e api/pupdevices/UltrasonicSensor: drop silent
Like its EV3 counterpart, this does not work reliably enough, so remove.
2020-05-27 13:58:30 +02:00
Laurens Valk e0ac54ec0a api/pupdevices/ForceSensor: add methods 2020-05-27 13:58:30 +02:00
Laurens Valk 8273c00881 api/pupdevices/UltrasonicSensor: add methods
This is identical to the EV3 Ultrasonic Sensor methods.
2020-05-27 13:58:30 +02:00
Laurens Valk 4da7b456bb api/pupdevices: initial color sensor hsv api
Provide a simple yet powerful way to calibrate the color() method.
2020-05-27 13:58:30 +02:00
Laurens Valk 7498751ee3 doc/pupdevices: add diagrams with light indices
Make this clear once and for all.
This order comes from the sensor itself.
2020-05-27 13:58:30 +02:00
Laurens Valk a8b0306afe doc/pupdevices: flip ultrasonic sensor diagram 2020-05-27 13:58:30 +02:00
Laurens Valk 2dd133d5e5 api/pupdevices: add ForceSensor
Initial class without any methods for the SPIKE Force Sensor
2020-05-27 13:58:30 +02:00
Laurens Valk e67c048b18 api/pupdevices: add UltrasonicSensor
Initial class without any methods for the SPIKE Ultrasonic Sensor
2020-05-27 13:58:30 +02:00
Laurens Valk 10b6808037 api/pupdevices: add ColorSensor
Initial class without any methods for the SPIKE Color Sensor
2020-05-27 13:58:30 +02:00
Laurens Valk 2d3e85f531 api/_common.LightArray: merge on and array method
Make it simpler with only one method to turn the lights on.
2020-05-27 13:58:30 +02:00
David Lechner a48b77fea8 doc/hubs_ev3brick: fix typo 2020-05-19 12:31:25 -05:00
Laurens Valk e3e352fac8 doc/start_ev3_upgrade: note extension versions 2020-05-19 13:11:16 +02:00
Laurens Valk fe5dc3adee doc/ev3devices/GyroSensor: add speed/angle note 2020-05-19 13:02:20 +02:00
Laurens Valk b9432c96af doc/start_ev3: doc8 2020-05-19 12:39:56 +02:00
Laurens Valk 728835150d doc/start_ev3_upgrade: drop rst table
Use the list-table directive to keep us sane.

Also solves doc8 length.
2020-05-19 12:32:02 +02:00
Laurens Valk 6bc394bdcd doc/start_ev3_brick: doc8 2020-05-19 11:32:25 +02:00
Laurens Valk 10bceb970e doc/ev3: doc8 for inc files 2020-05-19 11:27:50 +02:00
Laurens Valk b0e5ae9f0f config: do not spell sphinx directives 2020-05-19 11:20:18 +02:00
Laurens Valk 164f353be3 config: doc8 for inc files
These files were not checked. Unfortunately adding it to setup.cfg does not work, so we have to add it here.
2020-05-19 11:11:47 +02:00
Laurens Valk 92745f1921 doc/start_ev3: add upgrade guide
Explain how existing users can benefit from the update
2020-05-19 10:49:04 +02:00
Laurens Valk 1580273265 pybricks-projects: include version headers 2020-05-19 10:49:04 +02:00
Laurens Valk a90cc4f10f config: fix spell check document types
Spell checking stopped working previously. This appears to fix it.
2020-05-19 10:48:45 +02:00
David Lechner cce1149db6 doc: fix latexpdf build
Building pdf was broken because of chinese characters in one of the
code snippets.

LaTeX stack exchange recommends use XeTeX engine instead but this
causes other formatting problems (like footer using wide font) so
just hacking this in for now.
2020-05-18 16:01:10 -05:00
David Lechner daeac6005e api: media.ev3dev.Image.draw_circle: fix r arg
This removes the default value from the `r` parameter (this was probably copy/paste error from the `draw_box` method). The actual implementation does not have a default value.
2020-05-18 13:26:28 -05:00
David Lechner 342e312abb v2.0.0 2020-05-06 15:19:54 -05:00
Laurens Valk dbbbe29201 doc/ev3_install: update download link 2020-05-05 17:19:39 +02:00
Laurens Valk 4c6984bf16 doc/index: add link to about Pybricks page 2020-05-05 15:37:40 +02:00
Laurens Valk 1c28b5821d doc/index: add basic welcome page 2020-05-05 15:23:49 +02:00