test

Dependencies:   LM75B Color mbed yeswecancoap Rgb

Files at this revision

API Documentation at this revision

Comitter:
de_geeter_alexander
Date:
Tue Jan 19 00:13:37 2016 +0000
Parent:
1:e0a4afdbbffb
Commit message:
Final version

Changed in this revision

Color.lib Show annotated file Show diff for this revision Revisions of this file
Rgb.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/rgb.cpp Show diff for this revision Revisions of this file
lib/rgb.h Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Color.lib	Tue Jan 19 00:13:37 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/de_geeter_alexander/code/Color/#8625ec7a9a67
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Rgb.lib	Tue Jan 19 00:13:37 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/de_geeter_alexander/code/Rgb/#b6d24e2f118b
--- a/lib/color.cpp	Fri Oct 23 14:48:16 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +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=(int) (red*255);
-    this->green=(int) (green*255);
-    this->blue=(int) (blue*255);
-    }
-    
-    Color::Color(int color){ //0xAABBCC
-        this->red=(color>>16) & 0x0000FF;
-        this->green=(color>>8) & 0x0000FF;
-        this->blue=(color>>0) & 0x0000FF;
-        }
-    
-int Color::floatToColorValue(float value){
-    return (int) (value*MAX_COLOR_VALUE);
-    }
-    
-int Color::getRed(){
-    return red;
-    }
-
-int Color::getGreen(){
-    return green;
-    }
-
-int Color::getBlue(){
-    return blue;
-    }    
-
-int Color::getHex(){
-    return (red <<16) + (green<<8) + (blue<<0);
-    }
\ No newline at end of file
--- a/lib/color.h	Fri Oct 23 14:48:16 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +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=0x00FF00, MAGENTA=0xFF00FF, YELLOW=0x00FFFF, 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
--- a/lib/rgb.cpp	Fri Oct 23 14:48:16 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +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);
-    setColor(0,0,0);
-    }
-
-void RGB::setColor(int red, int green, int blue){
-    r_out->write(1.0-toFloat(red));
-    g_out->write(1.0-toFloat(green));
-    b_out->write(1.0-toFloat(blue));
-    }
-
-void RGB::setColor(int color){
-    Color kleur=Color(color);
-    r_out->write(1.0-toFloat(kleur.getRed()));
-    g_out->write(1.0-toFloat(kleur.getGreen()));
-    b_out->write(1.0-toFloat(kleur.getBlue()));
-    }
-
-void RGB::setColor(Color color){
-    r_out->write(toFloat(color.getRed()));
-    g_out->write(toFloat(color.getGreen()));
-    b_out->write(toFloat(color.getBlue()));
-    }
-    
-
-float RGB::toFloat (int floater){
-    return (float) ((floater)/255.0f);
-    }
\ No newline at end of file
--- a/lib/rgb.h	Fri Oct 23 14:48:16 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-#ifndef RGB_H
-#define RGB_H
-#include "mbed.h"
-#include "color.h"
-#include "LM75B.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);
-    void off();
-    
-    private:
-    PwmOut* r_out;
-    PwmOut* g_out;
-    PwmOut* b_out;
-    float toFloat(int floater);
-    };
-
-#endif
\ No newline at end of file
--- a/main.cpp	Fri Oct 23 14:48:16 2015 +0000
+++ b/main.cpp	Tue Jan 19 00:13:37 2016 +0000
@@ -1,14 +1,19 @@
+//include the libary's
+
 #include "mbed.h"
 #include "coap.h"
 #include "rgb.h"
 #include "LM75B.h"
 
+//initialise serial en the temperature sensor
 Serial pc(USBTX, USBRX);
 LM75B sensor(p28,p27);
+//make a object from the class RGB
 RGB* rgb;
 
-
-void get_hello(Request* req, Response* res)
+//the methode to send the value of the temp sensor
+//this methode is called by a get methode
+void get_temp(Request* req, Response* res)
 {
     if(req->hasContent()) {
            
@@ -21,11 +26,14 @@
     res -> setCode(CONTENT);   
 }
 
+//this methode receive the value of the LED 
+//
 void post_led(Request* req, Response* res)
 {
     if(req->hasContent()) {
-        //rgb->setColor(req,req,req);
+        //receive the coap data
         char* test = req->getContent();
+        
         pc.printf(test);
         uint32_t hex = strtol(req->getContent(), NULL, 16);
         rgb->setColor(hex);
@@ -38,7 +46,7 @@
 int main()
 {
     Server server;
-    server.add("/led", &get_hello, GET);
+    server.add("/led", &get_temp, GET);
     server.add("/led", &post_led, POST);
     
     rgb = new RGB(p23, p24, p25);