Fertiliser mixing station

Dependencies:   mbed

peristaltics.h

Committer:
lawless
Date:
2013-10-04
Revision:
1:a1f7cc753866

File content as of revision 1:a1f7cc753866:


class Peristaltics {
    private :
        vector<Pump *>pumps;

    public:
    
    Peristaltics(int on_value) {
        this->pumps.push_back(new Pump(p5, &led1, on_value));
        this->pumps.push_back(new Pump(p6, &led2, on_value));
        this->pumps.push_back(new Pump(p7, &led3, on_value));
    }
    
    void nutrient_a(unsigned int ml) {
led1 = 1;
        this->pumps[0]->on(1.0 * ml);
    }
    
    void nutrient_b(unsigned int ml) {
led2 = 1;
        this->pumps[1]->on(1.0 * ml);
    }
    
    void pH(unsigned int ml) {
led3 = 1;    
        this->pumps[2]->on(1.0 * ml);
    }
    
    void all_off() {
        for(int p = 0; p < pumps.size(); p++)
            this->pumps[p]->off();
led1 = 0;
led2 = 0;
led3 = 0;            
    }
    
    
    ~Peristaltics() {
        for(int p = 0; p < pumps.size(); p++)
            delete this->pumps[p];

led1 = 0;
led2 = 0;
led3 = 0;            
            
    }
};