/**
 * /Memory.h
 * @version 1.0
 * @desc Class for managing the EEPROM storage in a convincing manner
 * @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
 * @copy 2018 Fándly Gergő Zoltán
 * License:
    Firmware for the Profile F1 fertilizer machine.
    Copyright (C) 2018  Fándly Gergő Zoltán

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 **/

#ifndef MEMORY_H_INCLUDED
#define MEMORY_H_INCLUDED

#include <Arduino.h>
#include <EEPROM.h>
#include "defaults.h"
#include "CheapMCPStepper.h"

struct Timer{
    byte hour;
    byte minute;
    byte pump[5];
    byte switches;
    Timer(){
        hour=0;
        minute=0;
        pump[0]=0;
        pump[1]=0;
        pump[2]=0;
        pump[3]=0;
        pump[4]=0;
        switches=0;
    }
    Timer(byte _hour, byte _minute, byte _pump0, byte _pump1, byte _pump2, byte _pump3, byte _pump4, byte _switches){
        hour=_hour;
        minute=_minute;
        pump[0]=_pump0;
        pump[1]=_pump1;
        pump[2]=_pump2;
        pump[3]=_pump3;
        pump[4]=_pump4;
        switches=_switches;
    }
};

class Memory{
public:
    //constructor
    Memory();

    //get methods
    byte getMotorCount();
    byte getLCDBrightness();
    byte getTimerCount();
    Timer getTimer(byte n);
    byte getTempCount();
    float getTemp(byte n);

    //set methods
    void setMotorCount(byte a);
    void setLCDBrightness(byte a);
    void addTimer(Timer t);
    void deleteTimer(byte n);
    void addTemp(float t);

protected:
    Timer* timers;

private:
    Timer getTimer_eeprom(byte n);
    void loadTimers();
};

#endif // MEMORY_H_INCLUDED
