Commit Graph
583 Commits
Author SHA1 Message Date
Laurens Valk 4d88fbbbd2 api/pupdevices/PFMotor: DCMotor functionality
This replaces the on-off method in ColorDistanceSensor.remote()
with a PFMotor class that works just like the DCMotor class. This
provides much more functionality without having to invent a new API.
2020-08-11 12:05:53 +02:00
Laurens Valk 70ffbfa4f3 doc/parameters/Color: sort colors by hue/value 2020-08-10 11:39:56 +02:00
Laurens Valk c987bc2f80 api/parameters/Color: add CYAN, MAGENTA, GRAY 2020-08-10 11:34:58 +02:00
Laurens Valk 7b8a848c61 api/parameters/Color: remove BROWN
Brown has the same hue as orange, just with a lower value and/or
saturation,  so it does not need to have a separate Color instance.
It is also not supported by the color_map methods.

It was originally included in this list because the EV3 Color Sensor
can technically detect it. This is not reliable, however, as it is
also reports this value for orange objects at a slightly larger
distance. The implementation may be updated to return orange
in both cases. If the original values are required, the LUMPDevice
may be used to get the original color index.
2020-08-10 11:29:48 +02:00
Laurens Valk 0c5457a5f2 api/parameters/Color: rename PURPLE to VIOLET
The correct term for hue = 270 is violet.
Purple is just magenta with a lower brightness value.
2020-08-10 11:29:32 +02:00
Laurens Valk 6aa6059974 doc/pupdevices: add Motor action examples 2020-07-21 16:14:35 +02:00
Laurens Valk 98f247688e doc/pupdevices: add Motor measuring examples 2020-07-21 14:50:26 +02:00
Laurens Valk 51f9d916e0 doc/pupdevices: add Motor init examples 2020-07-21 14:50:26 +02:00
Laurens Valk 8a9386ffc5 doc/pupdevices: add DCMotor examples 2020-07-21 14:50:26 +02:00
Bert bcd44dad84 doc/start_pup: fix mixed http and https contents
Fixes #106.
2020-07-19 21:47:11 +02:00
Laurens Valk ac96985c71 doc/pupdevices/ForceSensor: add examples 2020-07-13 15:40:59 +02:00
Laurens Valk b98f487f3c doc/pupdevices/ColorSensor: add examples 2020-07-13 14:24:57 +02:00
Laurens Valk 42917f14ef doc/parameters: fix link to move hub
This is no longer a generic hub reference
2020-07-12 13:17:45 +02:00
Laurens Valk 938c62430f doc/hubs: remove content tabs
This caused links not to work to anything other than the default tab.
2020-07-12 13:11:38 +02:00
Laurens Valk 6132ae66da doc/pupdevices/ColorDistanceSensor: add examples 2020-07-11 19:40:00 +02:00
Laurens Valk a02c7023e5 doc/pupdevices/ColorDistanceSensor: group methods
We are already using a rubric for the lights, so add two more to better
group the many methods of this sensor.
2020-07-11 17:09:49 +02:00
Laurens Valk d15aa22131 doc/pupdevices/Light: and blink and fade examples 2020-07-11 13:00:28 +02:00
Laurens Valk 19009d1637 doc/pupdevices: InfraredSensor, TiltSensor example 2020-07-11 12:46:30 +02:00
Laurens Valk 4dbaf5f68e doc/pupdevices/UltrasonicSensor: math example 2020-07-10 13:06:22 +02:00
Laurens Valk af2b1c66c9 doc/pupdevices/UltrasonicSensor: add example 2020-07-10 12:42:20 +02:00
Laurens Valk 3488e1fb83 doc/pupdevices/UltrasonicSensor: document invalid
Document how invalid values are reported.
2020-07-10 12:32:52 +02:00
Laurens Valk f26d750fbf doc/ev3devices/InfraredSensor: document mode delay 2020-07-10 11:46:04 +02:00
Laurens Valk 6e6c8956b9 doc/start_pup: clean up custom firmware steps 2020-07-10 11:35:39 +02:00
Laurens Valk 80a426bc4f doc/start_pup: update instructions
- We no longer require a password
- We support more hubs
- Mention known key issues
- Simplify Chrome 85 discussion
- Add instructions to unplug cables prior to update
2020-07-10 11:21:12 +02:00
Laurens Valk 93da01c7ce api/pupdevices/ColorDistanceSensor: add hsv
The hsv and color_map methods are the same as for the SPIKE ColorSensor class, except for the surface kwarg.
2020-07-07 14:07:35 +02:00
Laurens Valk 55c4c86c23 api/_common: fix speaker file kwarg
In the implementation, the kwarg is called "file". Instead of fixing the implementation which is already released, we fix the docs.
2020-07-07 09:50:36 +02:00
Laurens Valk 82b16dc8de api/_common: fix DriveBase speed kwarg
In the implementation, the kwarg is called "speed". Instead of fixing the implementation which is already released, we fix the docs.
2020-07-07 09:50:30 +02:00
Laurens Valk 8078b6febb doc/_common/ColorLight: docstring clean up
This adds a (commented out) preview of the methods to the city hub light
2020-07-07 09:44:16 +02:00
Laurens Valk 8a43dc936a doc/signaltypes: add hue placeholder
We will have to add a helpful diagram, but having the placeholder allows us to link to it already.
2020-07-07 09:44:16 +02:00
Laurens Valk 7d1fbe9ce9 api/_common/Light: add reset to system behavior
This makes lights behave as they would if the user script did not use them at all.
2020-07-07 09:44:16 +02:00
Laurens Valk 38a1cf9712 api/_common/Light: drop repeat kwarg
The pattern will always repeat, for simplicity.
2020-07-07 09:44:16 +02:00
Laurens Valk 102039385a api/_common/ColorLight: add pattern
This adds the method equivalent to the recent addition of a single
color light. The only difference is that now a color is returned instead
of a single brightness. The provided color or HSV tuple will be stored
as RGB samples internally, as is already done for pbio light patterns.

In the simplest blinking form this could be:

hub.light.pattern(lambda t: Color.RED if t >= 1000 else None, 2000)

Or a fading, one-color sine:

def fade(time):
    v = sin(time/2000/pi)*50+50
    h = 360
    s = 100
    return (h, s, v)

hub.light.pattern(fade, 1000)
2020-07-07 09:44:16 +02:00
Laurens Valk e780a65007 api/_common/ColorLight: change rgb to hsv
This makes it much easier to have fine grained control
over colors and cycle through them easily (0--360).

This also makes it consistent with sensor APIs. Now you
can measure the color and plug it into this method.

We can make this change because none of
the implementations use this yet.

If we feel we miss out by dropping the RGB, it would be more fitting
to instead expose R, G, and B attributes which point to instances of
the Light class. However, this is using more memory for something that
isn't very useful.

We could also just provide generic color converters between rgb, hsv,
and perhaps hex html color strings, not tied to any particular light or
sensor.
2020-07-07 09:44:16 +02:00
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