Commit Graph
258 Commits
Author SHA1 Message Date
Laurens Valk 08c55218fa api/parameters/Button: add bluetooth button 2020-12-30 12:36:37 +01:00
Laurens Valk 352bff564c api/parameters/Button: add remote buttons
Also clean up how it is displayed by reading the attributes from the API instead of copying them.
2020-12-30 12:27:12 +01:00
Laurens Valk 313a51219a api/pupdevices/Remote: add address
After connecting (automatically), this address can be printed so next time you can connect directly without scanning.

This is useful if you have more than one remote.
2020-12-29 20:16:34 +01:00
Laurens Valk c2d2884794 api/pupdevices/Remote: publish draft api 2020-12-29 19:51:48 +01:00
Laurens Valk a92eae867b typing/pupdevices: remove stray docstring 2020-12-29 09:32:11 +01:00
Laurens Valk 0a86e0a719 typing/common: fix Keypad return type
Follows 8a1716d5e2
2020-12-29 09:31:00 +01:00
Laurens Valk 7800ab05b2 typing/common: fix nonexistent scalar type 2020-12-29 09:29:47 +01:00
David Lechner db65f8d646 api: add type hints for v3
This updates the type hints for the current v3 API.
2020-12-28 18:47:11 -06:00
David Lechner 3a66b8e053 api: add type hints for v2
This adds PEP 561 style type hints for Pybricks v2 (just EV3).
2020-12-28 18:47:04 -06:00
Laurens Valk 8a1716d5e2 api/common/Keypad: change return type to tuple
This follows an implementation change that was made for performance reasons (https://github.com/pybricks/pybricks-micropython/commit/95741ac2f8f118396a517a38f4d0f7fb92136f82).
2020-12-23 11:45:37 +01:00
Laurens Valk abe4c1bc9a doc/common/Keypad: fix name
Keypad is one word, so the class is not spelled KeyPad.
2020-12-23 11:43:48 +01:00
Laurens Valk 84b882f8b8 api/hubs/InventorHub: add speaker instance 2020-12-18 13:35:19 +01:00
Laurens Valk c3fc818037 doc/common/Speaker: move note information back
We were hiding this under a toggle menu to reduce the page size of the hubs module. Now that each hub is on its own page, this is no longer necessary.

In turn, this makes it easier to document the same method for other hubs.
2020-12-18 13:32:18 +01:00
Laurens Valk 57ff8312f3 api/iodevices/PUPDevice: add info() method 2020-12-18 13:20:17 +01:00
Laurens Valk 1e751d6afc api/iodevices/LUMPDevice: drop write method
EV3 UART devices do not support writing.
2020-12-14 10:08:09 +01:00
Laurens Valk aaf98308f7 api/iodevices/PUPDevice: copy from LUMPDevice
Powered Up devices have many differences compared to EV3 UART devices, so it is better to split them to dedicated classes.

The biggest difference is that PUPDevice class will allow writing to sensors and toggling battery power to the device.
2020-12-14 10:07:13 +01:00
Laurens Valk 983562f7b8 doc/hubs/inventorhub: document light, display, buttons 2020-11-06 15:59:02 +01:00
Laurens Valk 1c9d0dd86f api/hubs/PrimeHub: enable buttons 2020-11-06 15:55:48 +01:00
Laurens Valk 22a057d6e3 doc/common/LightGrid: existing pixels do not re-orient
This is currently a limitation of the implementation, and may be changed later on.
2020-11-06 15:22:00 +01:00
Laurens Valk 8f21cea345 api/common: clean up Light Matrix
This renames the generic class from LightGrid to LightMatrix. The instance object is simply called display.

This makes user scripts easier to type and read.

This also cleans up most of the draft docstrings for this class and fixes a few argument typos.
2020-11-06 12:31:42 +01:00
Laurens Valk 4e9886dba8 api/geometry: add new module
This module will contain mathematical tools to deal with geometry and motion of robots. This includes a Matrix type for common matrix operations.
2020-11-06 12:31:42 +01:00
Laurens Valk cb91368b32 api/common/LightGrid: add orientation setter 2020-11-06 12:31:42 +01:00
Laurens Valk 70ed79076d api/parameters: add Side enum
This will be used to designate orientations of hubs/sensors/screens.
2020-11-04 10:19:35 +01:00
Laurens Valk eef4e9f672 api/hubs: add InventorHub
This is just the SPIKE Prime Hub with a different name and color.
2020-10-25 10:25:16 +01:00
Laurens Valk d4c44a292c api: add PrimeHub 2020-10-09 22:50:49 +02:00
Laurens Valk c3eb31d348 doc/common: fix cross references 2020-10-09 19:58:35 +02:00
Laurens Valk 24d35993e9 api: rename CPlusHub to TechnicHub
This reflects the newly adopted naming convention.

See https://github.com/pybricks/support/issues/119
2020-10-09 19:16:33 +02:00
Laurens Valk d6651fc3c5 api/pupdevices: replace color_map
This reclects the implementation update that changes how
color sensing is performed and interfaced with by the user.
2020-10-08 20:19:33 +02:00
Laurens Valk 6662862b43 api/parameters: Color divide value
This is the inverse of scaling by a constant through multiplication.
2020-10-07 09:17:02 +02:00
Laurens Valk 500bac9929 api/parameters/Color: allow scaling to alter hue
This makes it easy for users to vary brightness of the default colors without having to create a whole new object.
2020-08-26 21:12:48 +02:00
Laurens Valk 5e6a8c8334 api/parameters/Color: name is None by default
This is more consistent with the rest of our API.
2020-08-26 21:12:38 +02:00
Laurens Valk 4f27a465c4 api/common/LightGrid: drop on() method
This method is inconsistent with the on methods for other light related classes so it is better to delete it.
2020-08-25 16:27:19 +02:00
Laurens Valk f490a3b2c2 api/common/LightArray: add blink and animate 2020-08-25 16:27:19 +02:00
Laurens Valk 9ae4955344 api/parameters/Color: no name by default
When no name is given, the color remains untitled
2020-08-25 16:27:19 +02:00
Laurens Valk b89da4b061 api/common/ColorLight: add blink and animate
These are the generalizations of the corresponding methods for single color lights.
2020-08-25 13:38:09 +02:00
Laurens Valk b974ead0dc api/common/ColorLight: drop hsv function
The on() method takes a color type, which is an HSV color, so a separate hsv method is not needed.

hub.light.on(Color.GREEN)
hub.light.on(Color(120))
hub.light.on(Color(h=120, s=100, 50))
2020-08-25 13:38:09 +02:00
Laurens Valk 0427436df6 doc/common/LightGrid: clarify how blink and pattern relate
blink is just a simpler animation
2020-08-25 13:38:09 +02:00
Laurens Valk 4319b2fad8 api/common/Light: add blink and animate 2020-08-25 13:38:09 +02:00
Laurens Valk 0fb150be19 api/common/LightGrid: add animate method 2020-08-25 13:37:54 +02:00
Laurens Valk 6d0984f5fc api/common/LightGrid: simplify image method
Now it just displays a Matrix/2D list. We can omit manipulations like clear=False. Composing can be done by simply adding two matrices instead.

We also drop the compressed format. Instead we could have a helper function that gives you a
matrix based on a list of integers in the now-deleted format.
2020-08-25 12:42:14 +02:00
Laurens Valk b708fe283c api/common/LightGrid: rename char argument
This follows a change in the unreleased implementation.
2020-08-25 12:42:14 +02:00
Laurens Valk 74d59b43ac api/common/LightGrid: revise text method
Specify on and off time for consistency with future blink method.

Adding some off time helps reading text with subsequent charachters that are the same. For example, now "Hello" reads H e l l o instead of Helo.

Also drop wait argument for now because it is not currently implemented and may never be.
2020-08-25 12:42:10 +02:00
Laurens Valk 1eb75e24e7 api/parameters/Color: generalize color type
First step towards making a color type with HSV representation.

Colors such as Color.RED or Color.BLUE continue to exist, but now you
can also define your own colors:

DARK_RED = Color(h=0, s=100, v=50)
2020-08-12 12:18:24 +02:00
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 3488e1fb83 doc/pupdevices/UltrasonicSensor: document invalid
Document how invalid values are reported.
2020-07-10 12:32:52 +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