Danius Kalvaitis
/
danBed_communicate
Communicate with danBed via UART
Revision 2:4e81ddaec100, committed 2015-03-10
- Comitter:
- DaniusKalv
- Date:
- Tue Mar 10 15:26:54 2015 +0000
- Parent:
- 1:1d18a2a3e9a0
- Commit message:
- Communicate with danBed via UART and control its pins
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 1d18a2a3e9a0 -r 4e81ddaec100 main.cpp --- a/main.cpp Thu Feb 19 12:01:30 2015 +0000 +++ b/main.cpp Tue Mar 10 15:26:54 2015 +0000 @@ -36,8 +36,8 @@ PwmOut GREEN(LED3); DigitalOut RGB(LED4); -//Serial pc(p28, p27); -Serial pc(USBTX, USBRX); +Serial pc(p28, p27); +//Serial pc(USBTX, USBRX); void receive(); void extractCommand(char *buffer, int &value); @@ -84,68 +84,58 @@ else pc.printf("\r\nRGB turned OFF\r\n"); } else if(strcmp(buffer, "RED") == 0){ - float tmp = ((float) value) / 255; + float tmp = ((float) (255 - value)) / 255; RED = tmp; pc.printf("\r\nRED value %i\r\n", value); } else if(strcmp(buffer, "GREEN") == 0){ - float tmp = ((float) value) / 255; + float tmp = ((float) (255 - value)) / 255; GREEN = tmp; pc.printf("\r\nGREEN value %i\r\n", value); } else if(strcmp(buffer, "BLUE") == 0){ - float tmp = ((float) value) / 255; + float tmp = ((float) (255 - value)) / 255; BLUE = tmp; pc.printf("\r\nBLUE value %i\r\n", value); } else if(strcmp(buffer, "P5") == 0){ - float tmp = ((float) value) / 255; - P5 = tmp; + P5 = value; pc.printf("\r\nP5 value %i\r\n", value); } else if(strcmp(buffer, "P6") == 0){ - float tmp = ((float) value) / 255; - P6 = tmp; + P6 = value; pc.printf("\r\nP6 value %i\r\n", value); } else if(strcmp(buffer, "P7") == 0){ - float tmp = ((float) value) / 255; - P7 = tmp; + P7 = value; pc.printf("\r\nP7 value %i\r\n", value); } else if(strcmp(buffer, "P8") == 0){ - float tmp = ((float) value) / 255; - P8 = tmp; + P8 = value; pc.printf("\r\nP8 value %i\r\n", value); } else if(strcmp(buffer, "P9") == 0){ - float tmp = ((float) value) / 255; - P9 = tmp; + P9 = value; pc.printf("\r\nP9 value %i\r\n", value); } else if(strcmp(buffer, "P10") == 0){ - float tmp = ((float) value) / 255; - P10 = tmp; + P10 = value; pc.printf("\r\nP10 value %i\r\n", value); } else if(strcmp(buffer, "P11") == 0){ - float tmp = ((float) value) / 255; - P11 = tmp; + P11 = value; pc.printf("\r\nP11 value %i\r\n", value); } else if(strcmp(buffer, "P12") == 0){ - float tmp = ((float) value) / 255; - P12 = tmp; + P12 = value; pc.printf("\r\nP12 value %i\r\n", value); } else if(strcmp(buffer, "P13") == 0){ - float tmp = ((float) value) / 255; - P13 = tmp; + P13 = value; pc.printf("\r\nP13 value %i\r\n", value); } else if(strcmp(buffer, "P14") == 0){ - float tmp = ((float) value) / 255; - P14 = tmp; + P14 = value; pc.printf("\r\nP14 value %i\r\n", value); } else if(strcmp(buffer, "P15") == 0){ @@ -197,23 +187,19 @@ pc.printf("\r\nP26 value %i\r\n", value); } else if(strcmp(buffer, "P27") == 0){ - float tmp = ((float) value) / 255; - P27 = tmp; + P27 = value; pc.printf("\r\nP27 value %i\r\n", value); } else if(strcmp(buffer, "P28") == 0){ - float tmp = ((float) value) / 255; - P28 = tmp; + P28 = value; pc.printf("\r\nP28 value %i\r\n", value); } else if(strcmp(buffer, "P29") == 0){ - float tmp = ((float) value) / 255; - P29 = tmp; + P29 = value; pc.printf("\r\nP29 value %i\r\n", value); } else if(strcmp(buffer, "P30") == 0){ - float tmp = ((float) value) / 255; - P30 = tmp; + P30 = value; pc.printf("\r\nP30 value %i\r\n", value); } else pc.printf("\r\nCommand not recognised!\r\n");