Matt Lesslaw
/
MagicMixer
Fertiliser mixing station
flow_controlled.h@1:a1f7cc753866, 2013-10-04 (annotated)
- Committer:
- lawless
- Date:
- Fri Oct 04 22:15:50 2013 +0000
- Revision:
- 1:a1f7cc753866
Pumps set with a auto-off timeout. Call it with a number of seconds and it switches itself off afterwards.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lawless | 1:a1f7cc753866 | 1 | |
lawless | 1:a1f7cc753866 | 2 | class Flow_Controlled { |
lawless | 1:a1f7cc753866 | 3 | private : |
lawless | 1:a1f7cc753866 | 4 | vector<Pump *>pumps; |
lawless | 1:a1f7cc753866 | 5 | DigitalOut *enable; |
lawless | 1:a1f7cc753866 | 6 | DigitalIn *flow; |
lawless | 1:a1f7cc753866 | 7 | |
lawless | 1:a1f7cc753866 | 8 | public: |
lawless | 1:a1f7cc753866 | 9 | |
lawless | 1:a1f7cc753866 | 10 | Flow_Controlled(int on_value) { |
lawless | 1:a1f7cc753866 | 11 | this->enable = new DigitalOut(p17); |
lawless | 1:a1f7cc753866 | 12 | this->pumps.push_back(new Pump(p18, &led1, on_value)); |
lawless | 1:a1f7cc753866 | 13 | this->pumps.push_back(new Pump(p19, &led2, on_value)); |
lawless | 1:a1f7cc753866 | 14 | this->flow = new DigitalIn(p20); |
lawless | 1:a1f7cc753866 | 15 | } |
lawless | 1:a1f7cc753866 | 16 | |
lawless | 1:a1f7cc753866 | 17 | void raw_water(unsigned int litres) { |
lawless | 1:a1f7cc753866 | 18 | this->pumps[0]->on(0.7 * litres); |
lawless | 1:a1f7cc753866 | 19 | } |
lawless | 1:a1f7cc753866 | 20 | |
lawless | 1:a1f7cc753866 | 21 | void recycled_water(unsigned int litres) { |
lawless | 1:a1f7cc753866 | 22 | this->pumps[1]->on(0.7 * litres); |
lawless | 1:a1f7cc753866 | 23 | } |
lawless | 1:a1f7cc753866 | 24 | |
lawless | 1:a1f7cc753866 | 25 | void all_off() { |
lawless | 1:a1f7cc753866 | 26 | for(int p = 0; p < pumps.size(); p++) |
lawless | 1:a1f7cc753866 | 27 | this->pumps[p]->off(); |
lawless | 1:a1f7cc753866 | 28 | this->enable->write(0); |
lawless | 1:a1f7cc753866 | 29 | } |
lawless | 1:a1f7cc753866 | 30 | |
lawless | 1:a1f7cc753866 | 31 | ~Flow_Controlled() { |
lawless | 1:a1f7cc753866 | 32 | for(int p = 0; p < pumps.size(); p++) |
lawless | 1:a1f7cc753866 | 33 | delete this->pumps[p]; |
lawless | 1:a1f7cc753866 | 34 | delete this->enable; |
lawless | 1:a1f7cc753866 | 35 | delete this->flow; |
lawless | 1:a1f7cc753866 | 36 | |
lawless | 1:a1f7cc753866 | 37 | } |
lawless | 1:a1f7cc753866 | 38 | }; |