/**
 * /TempLogger.h
 * @version 1.0
 * @desc Module for logging temperatures and saving them to Memory
 * @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 TEMPLOGGER_H_INCLUDED
#define TEMPLOGGER_H_INCLUDED

#include <Arduino.h>
#include <OneWire.h>
#include "DS18B20.h"

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

    //regular run
    void run();

    //get temperatures
    float getMin();
    float getMax();
    float getAvg();

    byte getCount();
    float getTemp(byte n);

    //get temp now
    float now();

protected:
    OneWire oneWire;
    DS18B20 sensor;
    byte sensorAddress[8];
    int lastSave;

private:
    //init everything
    void init();
    //add temp to log
    void saveTemp();
};

#endif // TEMPLOGGER_H_INCLUDED
