RGB led thing

Dependencies:   RGB-driver mbed

Files at this revision

API Documentation at this revision

Comitter:
arnedesmet
Date:
Mon Jan 18 20:49:44 2016 +0000
Parent:
0:4dc676502a4e
Commit message:
Committed the program

Changed in this revision

lib.lib Show annotated file Show diff for this revision Revisions of this file
lib/Color.cpp Show diff for this revision Revisions of this file
lib/Color.h Show diff for this revision Revisions of this file
lib/Effect.cpp Show diff for this revision Revisions of this file
lib/Effect.h Show diff for this revision Revisions of this file
lib/Heartbeat.cpp Show diff for this revision Revisions of this file
lib/Heartbeat.h Show diff for this revision Revisions of this file
lib/Police.cpp Show diff for this revision Revisions of this file
lib/Police.h Show diff for this revision Revisions of this file
lib/RGB.cpp Show diff for this revision Revisions of this file
lib/RGB.h Show diff for this revision Revisions of this file
diff -r 4dc676502a4e -r 5801c141ea90 lib.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib.lib	Mon Jan 18 20:49:44 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/arnedesmet/code/RGB-driver/#3d0652023458
diff -r 4dc676502a4e -r 5801c141ea90 lib/Color.cpp
--- a/lib/Color.cpp	Thu Nov 19 15:55:39 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-
-#include "Color.h"
-
-Color::Color(int red, int green, int blue){
-    this->red = red;
-    this->green = green;
-    this->blue = blue;
-}
-
-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 * MAX_COLOR_VALUE);
-}
-
-Color::Color(int Color){ //AABBCC
-    red   = (Color >> 16) & 0x0000FF;
-    green = (Color >> 8)  & 0x0000FF;
-    blue  =  Color        & 0x0000FF;
-}
-
-int Color::getHex(){
-    return (red >> 16) + (green >> 8) + (blue >> 0); //verander shift register
-}
-
-int Color::getRed(){
-    return red;
-}
-
-int Color::getGreen(){
-    return green;
-}
-
-int Color::getBlue(){
-    return blue;
-}
-
-
-
-
-
diff -r 4dc676502a4e -r 5801c141ea90 lib/Color.h
--- a/lib/Color.h	Thu Nov 19 15:55:39 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-
-#ifndef COLOR_H
-#define COLOR_H
-
-class Color{
-    
-    
-    int red, green, blue;
-    
-    int floatToColorValue(float value);
-    
-    static const int MAX_COLOR_VALUE = 255;
-    
-    public:
-    
-    enum colors {RED = 0xFF0000,
-                GREEN = 0x00FF00,
-                BLUE = 0x0000FF,
-                CYAN = 0x00FFFF,
-                MAGENTA = 0xFF00FF,
-                YELLOW = 0xFFFF00,
-                WHITE = 0xFFFFFF};
-    
-        Color(int red, int green, int blue);
-        Color(int color);
-        Color(float red, float green, float blue);
-        
-        int getHex();
-        
-        int getRed();
-        int getGreen();
-        int getBlue();
-        
-    
-};
-
-#endif
\ No newline at end of file
diff -r 4dc676502a4e -r 5801c141ea90 lib/Effect.cpp
--- a/lib/Effect.cpp	Thu Nov 19 15:55:39 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-
-#include "Effect.h"
-
-Effect::Effect(RGB* led){
-    this->led = led;
-}
-
-void Effect::run(){
-    
-}
\ No newline at end of file
diff -r 4dc676502a4e -r 5801c141ea90 lib/Effect.h
--- a/lib/Effect.h	Thu Nov 19 15:55:39 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-
-#ifndef EFFECT_H
-#define EFFECT_H
-#include "RGB.h"
-
-class Effect{
-    public:
-        Effect(RGB* led);
-        void run();
-    private:
-        RGB* led;
-        
-    
-};
-
-#endif
\ No newline at end of file
diff -r 4dc676502a4e -r 5801c141ea90 lib/Heartbeat.cpp
--- a/lib/Heartbeat.cpp	Thu Nov 19 15:55:39 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-
-#include "Heartbeat.h"
-
-Heartbeat::Heartbeat(RGB* led)
-    :Effect(led){
-    
-}
-
-void Heartbeat::run(){
-    while(1){
-    RGB* led = new RGB(p23,p24,p25);
-    led->setColor(Color::RED);
-    wait_ms(500);
-    
-    }
-}
\ No newline at end of file
diff -r 4dc676502a4e -r 5801c141ea90 lib/Heartbeat.h
--- a/lib/Heartbeat.h	Thu Nov 19 15:55:39 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-
-#ifndef HEARTBEAT_H
-#define HEARTBEAT_H
-#include "Effect.h"
-
-class Heartbeat: public Effect{
-    public:
-        Heartbeat(RGB* led);
-        void run();
-    private:
-        
-        
-    
-};
-
-#endif
\ No newline at end of file
diff -r 4dc676502a4e -r 5801c141ea90 lib/Police.cpp
--- a/lib/Police.cpp	Thu Nov 19 15:55:39 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-
-#include "Police.h"
-
-Police::Police(RGB* led)
-    :Effect(led){
-    
-}
-
-void Police::run(){
-    while(1){
-    RGB* led = new RGB(p23,p24,p25);
-    led->setColor(Color::RED);
-    wait_ms(500);
-    led->setColor(Color::BLUE);
-    wait_ms(500);
-    }
-}
\ No newline at end of file
diff -r 4dc676502a4e -r 5801c141ea90 lib/Police.h
--- a/lib/Police.h	Thu Nov 19 15:55:39 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-
-#ifndef POLICE_H
-#define POLICE_H
-#include "Effect.h"
-
-class Police: public Effect{
-    public:
-        Police(RGB* led);
-        void run();
-    private:
-        
-        
-    
-};
-
-#endif
\ No newline at end of file
diff -r 4dc676502a4e -r 5801c141ea90 lib/RGB.cpp
--- a/lib/RGB.cpp	Thu Nov 19 15:55:39 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-
-#include "RGB.h"
-
-RGB::RGB(PinName r_pin, PinName g_pin, PinName b_pin){
-    this->r_out = new PwmOut(r_pin);
-    this->g_out = new PwmOut(g_pin);
-    this->b_out = new PwmOut(b_pin);
-}
-
-float RGB::toFloat(int intValue){
-    return (float) ((255-intValue)/255);
-}
-
-void RGB::setColor(Color color){
-    
-    r_out->write(toFloat(color.getRed()));
-    g_out->write(toFloat(color.getGreen()));
-    b_out->write(toFloat(color.getBlue()));
-}
-
-void RGB::setColor(int red, int green, int blue){
-    r_out->write(toFloat(red));
-    g_out->write(toFloat(green));
-    b_out->write(toFloat(blue));
-}
-
-void RGB::setColor(int color){
-    Color kleur = Color(color);
-    r_out->write(toFloat(kleur.getRed()));
-    g_out->write(toFloat(kleur.getGreen()));
-    b_out->write(toFloat(kleur.getBlue()));
-}
-
-
-    
\ No newline at end of file
diff -r 4dc676502a4e -r 5801c141ea90 lib/RGB.h
--- a/lib/RGB.h	Thu Nov 19 15:55:39 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-
-#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 off();
-    private:
-        PwmOut* r_out;
-        PwmOut* g_out;
-        PwmOut* b_out;
-        
-        float toFloat(int intValue);
-        
-    
-};
-
-#endif
\ No newline at end of file