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:ff4d23667e75, committed 2015-10-23
- Comitter:
- de_geeter_alexander
- Date:
- Fri Oct 23 08:36:18 2015 +0000
- Commit message:
- lol
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/color.cpp Fri Oct 23 08:36:18 2015 +0000
@@ -0,0 +1,39 @@
+#include "color.h"
+
+Color::Color(int red, int green, int blue) {
+ this->red=red;
+ this->green=green;
+ this->blue=blue;
+}
+
+Color::Color(int color) {
+ this->red= (color <<16) & 0x0000FF;
+ this->green= (color << 8) &0x0000FF;
+ this->blue= (color << 8) & 0x0000FF;
+}
+
+Color::Color(float red, float green, float blue) {
+ this->red= floatToColorValue(red);
+ this->green= floatToColorValue(green);
+ this->blue= floatToColorValue(blue);
+}
+
+int Color::floatToColorValue(float value) {
+ return (int) (value*255);
+}
+
+int Color::getRed(void) {
+ return red;
+}
+
+int Color::getGreen(void) {
+ return green;
+}
+
+int Color::getBlue(void) {
+ return blue;
+}
+
+int Color::getHex(void) {
+ return (red<<16)+(green<<8)+(blue<<0);
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/color.h Fri Oct 23 08:36:18 2015 +0000
@@ -0,0 +1,36 @@
+
+
+#ifndef COLOR_H
+#define COLOR_H
+
+class Color {
+
+
+ public:
+ Color(int red, int green, int blue);
+ Color(int color);
+ Color(float red, float green, float blue);
+ int getRed();
+ int getGreen();
+ int getBlue();
+ int getHex();
+ int floatToColorValue(float value);
+ static const int MAX_COLOR = 255;
+ enum colors {
+ RED = 0xFF0000,
+ GREEN= 0x00FF00,
+ BLUE= 0x0000FF,
+ CYAN= 0xFFFF00,
+ MAGENTA= 0xFF00FF,
+ YELLOW= 0xFFFF00,
+ WHITE= 0xFFFFFF,
+ PINK=0xFF69B4
+ };
+ private:
+ int red, green, blue;
+
+
+
+};
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/rgb.cpp Fri Oct 23 08:36:18 2015 +0000
@@ -0,0 +1,15 @@
+#include "rgb.h"
+
+
+Rgb::Rgb(PinName r_pin, PinName g_pin, PinName b_pin) {
+
+ rout = new PwmOut(r_pin);
+ gout = new PwmOut(g_pin);
+ bout = new PwmOut(b_pin);
+}
+
+void Rgb::setColor(int red, int green, int blue) {
+ rout->write(255-red);
+ gout->write(255-green);
+ bout->write(255-blue);
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/rgb.h Fri Oct 23 08:36:18 2015 +0000
@@ -0,0 +1,33 @@
+#ifndef RGB_H
+#define RGB_H
+
+#include "mbed.h"
+#include "color.h"
+
+class Rgb {
+ public:
+ Rgb(PinName r_pin, PinName g_pin, PinName b_pin);
+ //void setColor(Color* color);
+ void setColor(int red, int green, int blue);
+ void setColor(int color);
+ //Color* getColor(void);
+ void off(void);
+
+ private:
+ /*
+ PinName r_pin;
+ PinName g_pin;
+ PinName b_pin;
+ */
+ PwmOut* rout;
+ PwmOut* gout;
+ PwmOut* bout;
+ int Pwmout;
+ /*
+ int Rout;
+ int Gout;
+ int Bout;
+ */
+};
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Oct 23 08:36:18 2015 +0000
@@ -0,0 +1,17 @@
+#include "rgb.h"
+
+Rgb* rgb;
+
+int main() {
+ Rgb* rgb = new Rgb(p23, p24, p25);
+ while(1) {
+
+ rgb->setColor(0,0,255);
+ wait_ms(1000);
+ rgb->setColor(255,0,0);
+ wait_ms(1000);
+ rgb->setColor(0,255,0);
+ wait_ms(1000);
+ //delay(1000);
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Oct 23 08:36:18 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68 \ No newline at end of file