Simple test application for the STMicroelectronics X-NUCLEO-LED61A1 LED Control Expansion Board.
Dependencies: X_NUCLEO_LED61A1 mbed
Fork of HelloWorld_LED61A1 by
LED Control with the X-NUCLEO-LED61A1 Expansion Board
This application provides a simple example of usage of the X-NUCLEO-LED61A1 LED Control Expansion Board.
It shows how to control a LED stripe load connected to the board by means of a sinusoidal wave form injected into the PWM dimming control pin.
Diff: main.cpp
- Revision:
- 19:4b259f97c1e3
- Parent:
- 18:bef2ec6d10ab
diff -r bef2ec6d10ab -r 4b259f97c1e3 main.cpp
--- a/main.cpp Thu Jul 13 16:15:24 2017 +0000
+++ b/main.cpp Tue Oct 17 13:03:29 2017 +0000
@@ -57,7 +57,7 @@
#define LOOP_PERIOD_us (5E5) /* 0.5 seconds. */
/* Sin period in micro-seconds. */
-#define PWM_SIN_PERIOD_us (1E7) /* 10 seconds. */
+#define LED_SIN_PERIOD_us (1E7) /* 10 seconds. */
/* Variables -----------------------------------------------------------------*/
@@ -85,19 +85,20 @@
static int tick = 0;
/* Handling the LED dimming when powered ON. */
- float pwm_dimming = 0.5f * sin(2 * M_PI * (tick++ * LOOP_PERIOD_us) / PWM_SIN_PERIOD_us) + 0.5f;
- tick %= (int) (PWM_SIN_PERIOD_us / LOOP_PERIOD_us);
+ float dimming = 0.5f * sin(2 * M_PI * (tick++ * LOOP_PERIOD_us) / LED_SIN_PERIOD_us) + 0.5f;
+ tick %= (int) (LED_SIN_PERIOD_us / LOOP_PERIOD_us);
/* Printing to the console. */
- printf("Sinusoidal PWM Dimming --> %0.2f\r", pwm_dimming);
+ printf("Sinusoidal PWM Dimming --> %0.2f\r", dimming);
/*
Writing PWM dimming values to the LED.
Notes:
- + Replace "set_pwm_dimming()" with "set_analog_dimming()" for an analog control.
+ + Use "set_pwm_dimming()" for a PWM control, or "set_analog_dimming()"
+ for an analog control.
*/
- led->set_pwm_dimming(pwm_dimming);
+ led->set_analog_dimming(dimming);
}
/**

X-NUCLEO-LED61A1 LED Driver