Skip to content

Commit 4484552

Browse files
ArcaneNibbledlech
authored andcommitted
pbio/platform/ev3/platform: Calibrate LED scale factors
1 parent 13be96c commit 4484552

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/pbio/platform/ev3/platform.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,16 @@ const pbdrv_led_dual_platform_data_t pbdrv_led_dual_platform_data[PBDRV_CONFIG_L
8686
};
8787

8888
static const pbdrv_led_pwm_platform_color_t pbdrv_led_pwm_color = {
89-
// TODO: Calibrate these numbers, as well as .scale_factor
90-
.r_factor = 1000,
91-
.g_factor = 170,
92-
.b_factor = 200,
93-
.r_brightness = 174,
94-
.g_brightness = 1590,
95-
.b_brightness = 327,
89+
// The red LED is much stronger than the green one, so leave green at 1000
90+
// and adjust red until yellow looks good.
91+
.r_factor = 150,
92+
.g_factor = 1000,
93+
.b_factor = 0,
94+
// 1250 allows max brightness for an 8-bit PWM size (with scale_factor = 1).
95+
// Increase to limit max brightness. Going lower will cause overflow.
96+
.r_brightness = 1250,
97+
.g_brightness = 1250,
98+
.b_brightness = 0,
9699
};
97100

98101
const pbdrv_led_pwm_platform_data_t pbdrv_led_pwm_platform_data[PBDRV_CONFIG_LED_PWM_NUM_DEV] = {
@@ -106,8 +109,7 @@ const pbdrv_led_pwm_platform_data_t pbdrv_led_pwm_platform_data[PBDRV_CONFIG_LED
106109
// Blue not available.
107110
.b_id = PWM_DEV_0,
108111
.b_ch = PBDRV_LED_PWM_CHANNEL_INVALID,
109-
// TODO: PWM not yet implemented, so these values not used.
110-
.scale_factor = 35,
112+
.scale_factor = 1,
111113
},
112114
{
113115
.color = &pbdrv_led_pwm_color,
@@ -119,8 +121,7 @@ const pbdrv_led_pwm_platform_data_t pbdrv_led_pwm_platform_data[PBDRV_CONFIG_LED
119121
// Blue not available.
120122
.b_id = PWM_DEV_0,
121123
.b_ch = PBDRV_LED_PWM_CHANNEL_INVALID,
122-
// TODO: PWM not yet implemented, so these values not used.
123-
.scale_factor = 35,
124+
.scale_factor = 1,
124125
},
125126
};
126127

0 commit comments

Comments
 (0)