Colour picker using Node-Red Serially
Dependents: noderedcolourpicker
node_red_parse.cpp@0:273a835b3148, 2017-03-30 (annotated)
- Committer:
- rushabkarani
- Date:
- Thu Mar 30 12:36:05 2017 +0000
- Revision:
- 0:273a835b3148
Node-Red Colour picker using PWM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rushabkarani | 0:273a835b3148 | 1 | #include "mbed.h" |
rushabkarani | 0:273a835b3148 | 2 | |
rushabkarani | 0:273a835b3148 | 3 | |
rushabkarani | 0:273a835b3148 | 4 | float led[5]; |
rushabkarani | 0:273a835b3148 | 5 | |
rushabkarani | 0:273a835b3148 | 6 | float* stringparsing(char* buffer) |
rushabkarani | 0:273a835b3148 | 7 | { |
rushabkarani | 0:273a835b3148 | 8 | |
rushabkarani | 0:273a835b3148 | 9 | char * pch; |
rushabkarani | 0:273a835b3148 | 10 | pch = strtok (buffer,",\""); |
rushabkarani | 0:273a835b3148 | 11 | // printf("%s\n\r",pch); |
rushabkarani | 0:273a835b3148 | 12 | int i = 0; |
rushabkarani | 0:273a835b3148 | 13 | while (pch != NULL) |
rushabkarani | 0:273a835b3148 | 14 | { |
rushabkarani | 0:273a835b3148 | 15 | // printf ("Inside function %s\n\r",pch); |
rushabkarani | 0:273a835b3148 | 16 | led[i] = atoi(pch); |
rushabkarani | 0:273a835b3148 | 17 | pch = strtok (NULL, ",\""); |
rushabkarani | 0:273a835b3148 | 18 | i++; |
rushabkarani | 0:273a835b3148 | 19 | } |
rushabkarani | 0:273a835b3148 | 20 | led[0] = 1-(led[0]/255.0); |
rushabkarani | 0:273a835b3148 | 21 | led[1] = 1-(led[1]/255.0); |
rushabkarani | 0:273a835b3148 | 22 | led[2] = 1-(led[2]/255.0); |
rushabkarani | 0:273a835b3148 | 23 | // pc.printf("red %f\n\r",led[0]); |
rushabkarani | 0:273a835b3148 | 24 | return led; |
rushabkarani | 0:273a835b3148 | 25 | |
rushabkarani | 0:273a835b3148 | 26 | } |