Matt Lesslaw
/
MagicMixer
Fertiliser mixing station
peristaltics.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 Peristaltics { |
lawless | 1:a1f7cc753866 | 3 | private : |
lawless | 1:a1f7cc753866 | 4 | vector<Pump *>pumps; |
lawless | 1:a1f7cc753866 | 5 | |
lawless | 1:a1f7cc753866 | 6 | public: |
lawless | 1:a1f7cc753866 | 7 | |
lawless | 1:a1f7cc753866 | 8 | Peristaltics(int on_value) { |
lawless | 1:a1f7cc753866 | 9 | this->pumps.push_back(new Pump(p5, &led1, on_value)); |
lawless | 1:a1f7cc753866 | 10 | this->pumps.push_back(new Pump(p6, &led2, on_value)); |
lawless | 1:a1f7cc753866 | 11 | this->pumps.push_back(new Pump(p7, &led3, on_value)); |
lawless | 1:a1f7cc753866 | 12 | } |
lawless | 1:a1f7cc753866 | 13 | |
lawless | 1:a1f7cc753866 | 14 | void nutrient_a(unsigned int ml) { |
lawless | 1:a1f7cc753866 | 15 | led1 = 1; |
lawless | 1:a1f7cc753866 | 16 | this->pumps[0]->on(1.0 * ml); |
lawless | 1:a1f7cc753866 | 17 | } |
lawless | 1:a1f7cc753866 | 18 | |
lawless | 1:a1f7cc753866 | 19 | void nutrient_b(unsigned int ml) { |
lawless | 1:a1f7cc753866 | 20 | led2 = 1; |
lawless | 1:a1f7cc753866 | 21 | this->pumps[1]->on(1.0 * ml); |
lawless | 1:a1f7cc753866 | 22 | } |
lawless | 1:a1f7cc753866 | 23 | |
lawless | 1:a1f7cc753866 | 24 | void pH(unsigned int ml) { |
lawless | 1:a1f7cc753866 | 25 | led3 = 1; |
lawless | 1:a1f7cc753866 | 26 | this->pumps[2]->on(1.0 * ml); |
lawless | 1:a1f7cc753866 | 27 | } |
lawless | 1:a1f7cc753866 | 28 | |
lawless | 1:a1f7cc753866 | 29 | void all_off() { |
lawless | 1:a1f7cc753866 | 30 | for(int p = 0; p < pumps.size(); p++) |
lawless | 1:a1f7cc753866 | 31 | this->pumps[p]->off(); |
lawless | 1:a1f7cc753866 | 32 | led1 = 0; |
lawless | 1:a1f7cc753866 | 33 | led2 = 0; |
lawless | 1:a1f7cc753866 | 34 | led3 = 0; |
lawless | 1:a1f7cc753866 | 35 | } |
lawless | 1:a1f7cc753866 | 36 | |
lawless | 1:a1f7cc753866 | 37 | |
lawless | 1:a1f7cc753866 | 38 | ~Peristaltics() { |
lawless | 1:a1f7cc753866 | 39 | for(int p = 0; p < pumps.size(); p++) |
lawless | 1:a1f7cc753866 | 40 | delete this->pumps[p]; |
lawless | 1:a1f7cc753866 | 41 | |
lawless | 1:a1f7cc753866 | 42 | led1 = 0; |
lawless | 1:a1f7cc753866 | 43 | led2 = 0; |
lawless | 1:a1f7cc753866 | 44 | led3 = 0; |
lawless | 1:a1f7cc753866 | 45 | |
lawless | 1:a1f7cc753866 | 46 | } |
lawless | 1:a1f7cc753866 | 47 | }; |