rsp to mbed
Dependencies: mbed neopixels_spi
Fork of RSP_receivefunction by
main.cpp
- Committer:
- el12moe
- Date:
- 2015-05-02
- Revision:
- 0:3f93f42809e5
- Child:
- 1:bcb384b83f54
File content as of revision 0:3f93f42809e5:
#include "mbed.h" Serial pi(USBTX, USBRX);// Initialse USB serial port void mbedReceive(void); void modeActivated(void); void security(void); void brightness(void); void colour(void); void festive(void); void sleep(void); void presetBrightness(void); void presetColour(void); void christmas(void); void hunika(void); void akwansa(void); void rainbow(void); void rgb(void); void christmas2(void); void hunika2(void); void akwansa2(void); void rainbow2(void); void rgb2(void); int room=0; int mode=0; int red=0; int green=0; int blue=0; int main() { while(1) { if(pi.readable()){ modeActivated(); //mbedReceive(); } } } // function to receive stuff from pi void mbedReceive(void){ int section = pi.getc(); if (section==1){ security(); //activate security mode } else if (section==2){ room = pi.getc(); mode = pi.getc(); red = pi.getc(); green = pi.getc(); blue = pi.getc(); } else if (section==0){ //normal lights function a way of stopping different light modes } } void modeActivated(void){ mbedReceive(); if (mode==1){ brightness(); } if (mode==2){ colour(); } if (mode==3){ festive(); } if (mode==4){ sleep(); } if (mode==5){ presetBrightness(); } if (mode==6){ presetColour(); } } void security(void){ } void brightness(void){ if (room==1){ // setRGBStrip1(red, green, blue); } if (room==2){ // setRGBStrip2(red, green, blue); } } void colour(void){ if (room==1){ // setRGBStrip1(red, green, blue); } if (room==2){ // setRGBStrip2(red, green, blue); } } void festive(void){ if (room==1){ if(red==1){ christmas(); } if(red==2){ hunika(); } if(red==3){ akwansa(); } if(red==4){ rainbow(); } if(red==5){ rgb(); } } else if (room==2){ if(red==1){ christmas2(); } if(red==2){ hunika2(); } if(red==3){ akwansa2(); } if(red==4){ rainbow2(); } if(red==5){ rgb2(); } } } void sleep(void){ if (room==1){ // setRGBStrip1(red, green, blue); sleep pattern for strip1 } if (room==2){ // setRGBStrip2(red, green, blue);sleep pattern for strip1 } } void presetBrightness(void){ } void presetColour(void){ } void christmas(void){ } void hunika(void){ } void akwansa(void){ } void rainbow(void){ } void rgb(void){ } void christmas2(void){ } void hunika2(void){ } void akwansa2(void){ } void rainbow2(void){ } void rgb2(void){ }