Colour picker using Node-Red Serially

Dependents:   noderedcolourpicker

node_red_parse.cpp

Committer:
rushabkarani
Date:
2017-03-30
Revision:
0:273a835b3148

File content as of revision 0:273a835b3148:

#include "mbed.h"


float led[5];

float* stringparsing(char* buffer)
{
    
    char * pch;
    pch = strtok (buffer,",\"");
//    printf("%s\n\r",pch);    
    int i = 0;
    while (pch != NULL)
    {
//        printf ("Inside function %s\n\r",pch);
        led[i] = atoi(pch);
        pch = strtok (NULL, ",\"");
        i++;
    }
    led[0] = 1-(led[0]/255.0);
    led[1] = 1-(led[1]/255.0);
    led[2] = 1-(led[2]/255.0); 
//    pc.printf("red %f\n\r",led[0]);    
    return led;
    
}