Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HSI2RGBW_PWM mbed
Fork of KL25Z_HSI2RGBW_PWM by
Revision 3:d7de0bf4cd0c, committed 2014-02-02
- Comitter:
- frankvnk
- Date:
- Sun Feb 02 15:14:42 2014 +0000
- Parent:
- 2:34b0063fab4c
- Commit message:
- Initial release
Changed in this revision
| HSI2RGBW_PWM.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/HSI2RGBW_PWM.lib Mon Dec 30 11:26:47 2013 +0000 +++ b/HSI2RGBW_PWM.lib Sun Feb 02 15:14:42 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/frankvnk/code/HSI2RGBW_PWM/#dda6914d713f +http://mbed.org/users/frankvnk/code/HSI2RGBW_PWM/#a16b9c09561e
--- a/main.cpp Mon Dec 30 11:26:47 2013 +0000
+++ b/main.cpp Sun Feb 02 15:14:42 2014 +0000
@@ -44,13 +44,7 @@
Serial pc(USBTX, USBRX);
// HSI to RGBW conversion with direct output to PWM channels
-hsi2rgbw_pwm led(PTD4, PTA12, PTA4, PTA5);
-
-// Dummy ISR for disabling NMI on PTA4 - !! DO NOT REMOVE THIS !!
-// More info at https://mbed.org/questions/1387/How-can-I-access-the-FTFA_FOPT-register-/
-extern "C" void NMI_Handler() {
- DigitalIn test(PTA4);
-}
+hsi2rgbw_pwm led(LED_RED, LED_GREEN, LED_BLUE);
struct HSI {
float h;
@@ -90,6 +84,8 @@
void primary_colors() {
printf("briefly show RED - GREEN - BLUE using hsi2rgbw.\r\n");
+ color.s = 1;
+ color.i = 1;
for (color.h = 0 ; color.h < 360 ; color.h += 120)
{
led.hsi2rgbw(color.h, color.s, color.i);
@@ -99,7 +95,9 @@
void cycle_rgbw() {
float rgbw[4] = {0,0,0,0};
- printf("briefly show RED - GREEN - BLUE - WHITE using direct PWM output.\r\n");
+ color.s = 1;
+ color.i = 1;
+ printf("briefly show RED - GREEN - BLUE using direct PWM output.\r\n");
rgbw[0] = 1.0f;
led.pwm(rgbw);
wait(1);
@@ -111,10 +109,6 @@
rgbw[2] = 1.0f;
led.pwm(rgbw);
wait(1);
- rgbw[2] = 0.0f;
- rgbw[3] = 1.0f;
- led.pwm(rgbw);
- wait(1);
}
void sendcolor() {
@@ -129,7 +123,7 @@
}
void setup() {
- led.colorMode(RGBW);
+ led.invertpwm(1); //KL25Z RGB LED uses common anode.
color.h = 0;
color.s = maxsaturation;
color.i = 0;
@@ -150,8 +144,9 @@
int main() {
pc.baud (115200);
- printf("HSI to RGBW random fade.\r\n");
+ printf("HSI to RGB random fade.\r\n");
printf("Initialize.\r\n");
+
setup();
primary_colors();
cycle_rgbw();
