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.
Revision 0:ee2feb784400, committed 2015-02-03
- Comitter:
- csjc99
- Date:
- Tue Feb 03 01:10:35 2015 +0000
- Commit message:
- initial version
Changed in this revision
| KRGBLed.cpp | Show annotated file Show diff for this revision Revisions of this file |
| KRGBLed.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/KRGBLed.cpp Tue Feb 03 01:10:35 2015 +0000
@@ -0,0 +1,19 @@
+#include "KRGBLed.h"
+
+KRGBLed::KRGBLed(PinName redPin, PinName greenPin, PinName bluePin) :
+ red(redPin),
+ green(greenPin),
+ blue(bluePin)
+{
+}
+
+KRGBLed::~KRGBLed()
+{
+}
+
+void KRGBLed::set(Color color)
+{
+ red = !(color & Red);
+ green = !(color & Green);
+ blue = !(color & Blue);
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/KRGBLed.h Tue Feb 03 01:10:35 2015 +0000
@@ -0,0 +1,34 @@
+
+#pragma once
+#include <mbed.h>
+
+/**
+ * K64F RGB LED example:
+ * KRGBLed rgb(LED_RED, LED_GREEN, LED_BLUE);
+ * rgb.set(KRGBLed::Magenta);
+ */
+class KRGBLed
+{
+public:
+ typedef enum
+ {
+ Off = 0,
+ Red = 1,
+ Green = 2,
+ Blue = 4,
+ Yellow = (Red|Green),
+ Cyan = (Green|Blue), // @note more like a whiteish-blue
+ Magenta = (Blue|Red),
+ White = (Red|Green|Blue),
+ } Color;
+
+ KRGBLed(PinName redPin, PinName greenPin, PinName bluePin);
+ ~KRGBLed();
+
+ void set(Color color);
+
+private:
+ DigitalOut red;
+ DigitalOut green;
+ DigitalOut blue;
+};
\ No newline at end of file