striscia led
Dependencies: X_NUCLEO_LED61A1 mbed
Fork of HelloWorld_LED61A1 by
Revision 19:4b259f97c1e3, committed 2017-10-17
- Comitter:
- Davidroid
- Date:
- Tue Oct 17 13:03:29 2017 +0000
- Parent:
- 18:bef2ec6d10ab
- Commit message:
- Updating mbed library. Minor changes.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
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); } /**
diff -r bef2ec6d10ab -r 4b259f97c1e3 mbed.bld --- a/mbed.bld Thu Jul 13 16:15:24 2017 +0000 +++ b/mbed.bld Tue Oct 17 13:03:29 2017 +0000 @@ -1,1 +1,1 @@ -https://mbed.org/users/mbed_official/code/mbed/builds/22da6e220af6 \ No newline at end of file +https://mbed.org/users/mbed_official/code/mbed/builds/b484a57bc302 \ No newline at end of file