Matt Lesslaw / Mbed 2 deprecated MagicMixer

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers flow_controlled.h Source File

flow_controlled.h

00001 
00002 class Flow_Controlled {
00003     private :
00004         vector<Pump *>pumps;
00005         DigitalOut *enable;
00006         DigitalIn *flow;
00007 
00008     public:
00009     
00010     Flow_Controlled(int on_value) {    
00011         this->enable = new DigitalOut(p17);
00012         this->pumps.push_back(new Pump(p18, &led1, on_value));
00013         this->pumps.push_back(new Pump(p19, &led2, on_value));
00014         this->flow = new DigitalIn(p20);
00015     }
00016     
00017     void raw_water(unsigned int litres) {
00018         this->pumps[0]->on(0.7 * litres);
00019     }
00020     
00021     void recycled_water(unsigned int litres) {
00022         this->pumps[1]->on(0.7 * litres);
00023     }
00024     
00025     void all_off() {
00026         for(int p = 0; p < pumps.size(); p++)
00027             this->pumps[p]->off();
00028         this->enable->write(0);        
00029     }
00030     
00031     ~Flow_Controlled() {
00032         for(int p = 0; p < pumps.size(); p++)
00033             delete this->pumps[p];
00034         delete this->enable;
00035         delete this->flow;
00036         
00037     }
00038 };