This is an alternative way to control which channel is active. is saves only the channels that are active in a vector.
Fork of programmingtest by
Revision 0:5ab9f1abaf4d, committed 2016-02-28
- Comitter:
- Jamess
- Date:
- Sun Feb 28 15:54:13 2016 +0000
- Commit message:
- An alternative way to control which channels are active;
Changed in this revision
diff -r 000000000000 -r 5ab9f1abaf4d Canal.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Canal.cpp Sun Feb 28 15:54:13 2016 +0000 @@ -0,0 +1,21 @@ +#include "mbed.h" +#include "Canal.h" + +Canal::Canal(void){ + + state = 0; + + } + +bool Canal::getState(void){ + + return state; + + } + +void Canal::setState(bool newState){ + + state = newState; + + } +
diff -r 000000000000 -r 5ab9f1abaf4d Canal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Canal.h Sun Feb 28 15:54:13 2016 +0000 @@ -0,0 +1,19 @@ +#ifndef CANAL_H +#define CANAL_H + +#include <vector> +#include "mbed.h" + + +class Canal{ + public: + + Canal(); + bool getState(void); + void setState(bool); + private: + bool state; + + }; + +#endif \ No newline at end of file
diff -r 000000000000 -r 5ab9f1abaf4d Communication.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Communication.cpp Sun Feb 28 15:54:13 2016 +0000 @@ -0,0 +1,17 @@ +#include "mbed.h" +#include "Canal.h" + + +void sendActivityState(Serial* serialPort,vector<uint32_t> activeChannel){ + + serialPort->printf("the following channel are active"); + + for(uint32_t count = 0; count<activeChannel.size();count++){ + + + serialPort->printf("%d\t",activeChannel[count]); + } + + + +} \ No newline at end of file
diff -r 000000000000 -r 5ab9f1abaf4d Communication.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Communication.h Sun Feb 28 15:54:13 2016 +0000 @@ -0,0 +1,11 @@ +#ifndef COMMUNICATION_H +#define COMMUNICATION_H + +#include "mbed.h" +#include "Canal.h" +#include "Controler.h" + +void sendActivityState(Serial* serialPort, vector<uint32_t> activeChannel); + + +#endif
diff -r 000000000000 -r 5ab9f1abaf4d Controler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Controler.cpp Sun Feb 28 15:54:13 2016 +0000 @@ -0,0 +1,28 @@ +#include "Controler.h" + +std::vector<uint32_t> checkActivity(Canal newChannel[]){ + + vector<uint32_t> activeChannelVector; + + for(int count = 1; count<30;count++){ + + if(newChannel[count].getState() == 0){ + + //the chanel is not active + + + }else if(newChannel[count].getState() == 1){ + //the chanel is active + + activeChannelVector.push_back(count); + + }else{ + //error here + } + } + + + + return activeChannelVector; + + } \ No newline at end of file
diff -r 000000000000 -r 5ab9f1abaf4d Controler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Controler.h Sun Feb 28 15:54:13 2016 +0000 @@ -0,0 +1,16 @@ +#ifndef CONTROLER_H +#define CONTROLER_H + +#include "mbed.h" +#include "Canal.h" +#include <vector> + +std::vector<uint32_t> checkActivity(Canal newChannel[]); + /** + * check if the chanels are active and then returns an array with all the active channel in increasing order + * the first is the size, or, how many channels are active + **/ + + + +#endif \ No newline at end of file
diff -r 000000000000 -r 5ab9f1abaf4d main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Feb 28 15:54:13 2016 +0000 @@ -0,0 +1,30 @@ +#include "mbed.h" +#include "Controler.h" +#include "Canal.h" +#include "Communication.h" +#include <vector> + +DigitalOut myled(LED1); + +Canal ch[30]; + +Serial pc(USBTX,USBRX);; + +int main() { + + vector<uint32_t> activeChannel; + + while(1){ + + ch[1].setState(1); + ch[10].setState(1); + + activeChannel = checkActivity(ch); + + sendActivityState(&pc,activeChannel); + + + } +} + +
diff -r 000000000000 -r 5ab9f1abaf4d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Feb 28 15:54:13 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3 \ No newline at end of file