Skip to content

Commit 712f839

Browse files
committed
drv/led: new LED drivers
This consolidates the platform-specific light drivers into a couple of new LED drivers. Instead of color lookup tables, drivers can now show the full spectrum of hues in the HSV color model plus white. Currently, the same calibration values are used on all platforms. The values were derived from the Move/City hub LEDs so the colors are a bit off on the Control+ hub since it has a different LED. All LED PWM periods are now set to 10000 to match the Control+ hub. This way we don't have to have platform data for different periods on different devices. (Control+ hub shares LED PWMs with motor PWMs, so it can't be changed.)
1 parent 7453cf8 commit 712f839

File tree

34 files changed

+689
-706
lines changed

34 files changed

+689
-706
lines changed

bricks/ev3dev/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,11 @@ PYBRICKS_LIB_SRC_C = $(addprefix lib/,\
297297
pbio/drv/core.c \
298298
pbio/drv/counter/counter_core.c \
299299
pbio/drv/counter/counter_ev3dev_stretch_iio.c \
300-
pbio/drv/ev3dev_stretch/light.c \
301300
pbio/drv/ev3dev_stretch/motor.c \
302301
pbio/drv/ev3dev_stretch/serial.c \
303302
pbio/drv/ioport/ioport_ev3dev_stretch.c \
303+
pbio/drv/led/led_core.c \
304+
pbio/drv/led/led_ev3dev.c \
304305
pbio/platform/ev3dev_stretch/clock.c \
305306
pbio/src/color/conversion.c \
306307
pbio/src/control.c \

bricks/stm32/stm32.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ LIBFIXMATH_SRC_C = $(addprefix lib/libfixmath/libfixmath/,\
293293

294294
PBIO_SRC_C = $(addprefix lib/pbio/,\
295295
drv/$(PBIO_PLATFORM)/bluetooth.c \
296-
drv/$(PBIO_PLATFORM)/light.c \
297296
drv/$(PBIO_PLATFORM)/motor.c \
298297
drv/adc/adc_stm32_hal.c \
299298
drv/adc/adc_stm32f0.c \
@@ -307,6 +306,8 @@ PBIO_SRC_C = $(addprefix lib/pbio/,\
307306
drv/gpio/gpio_stm32f4.c \
308307
drv/gpio/gpio_stm32l4.c \
309308
drv/ioport/ioport_lpf2.c \
309+
drv/led/led_core.c \
310+
drv/led/led_pwm.c \
310311
drv/pwm/pwm_core.c \
311312
drv/pwm/pwm_stm32_tim.c \
312313
drv/uart/uart_stm32f0.c \

lib/pbio/doc/doxygen.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,6 +2103,7 @@ PREDEFINED = \
21032103
PBIO_CONFIG_LIGHT=1 \
21042104
PBIO_CONFIG_ENABLE_DEINIT \
21052105
PBIO_CONFIG_ENABLE_SYS \
2106+
PBDRV_CONFIG_LED=1
21062107
PBDRV_CONFIG_PWM=1
21072108
PBDRV_CONFIG_HAS_PORT_A=1 \
21082109
PBDRV_CONFIG_HAS_PORT_B=1 \

lib/pbio/drv/city_hub/light.c

Lines changed: 0 additions & 68 deletions
This file was deleted.

lib/pbio/drv/core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// SPDX-License-Identifier: MIT
22
// Copyright (c) 2020 The Pybricks Authors
33

4+
#include <pbdrv/led.h>
45
#include <pbdrv/pwm.h>
56

67
/** Initializes all enabled drivers. */
78
void pbdrv_init() {
9+
pbdrv_led_init();
810
pbdrv_pwm_init();
911
}

lib/pbio/drv/cplus_hub/light.c

Lines changed: 0 additions & 60 deletions
This file was deleted.

lib/pbio/drv/debug/light.c

Lines changed: 0 additions & 58 deletions
This file was deleted.

lib/pbio/drv/ev3dev_stretch/light.c

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)