/*! * \file thermostat.h * \brief * Application wide data type declarations * * Author: Christos Choutouridis AEM: 8997 * email : */ #ifndef THERMOSTAT_H_ #define THERMOSTAT_H_ /* * Hard coded user settings */ #define MEAS_WINDOW (120) // [sec] #define MEAS_INTERVAL (5) // [sec] #define MEASUREMENTS (MEAS_WINDOW / MEAS_INTERVAL) // keep this integer #define UI_AVERAGE_TIME (10) // [sec] //#define UI_USER_TIME (10) typedef float float_t; //!< Select the floating point type for application typedef int int_t; //!< Select the integer type for application /*! * Thermostat mode enumerator */ typedef enum { HEATING =0, //!< HEATING COOLING //!< COOLING } mode_en; /*! * Application common data type */ typedef struct { float_t T[MEASUREMENTS]; //!< Temperature samples float_t Tav; //!< Average temperature uint32_t cur; //!< Cursor on sample array uint8_t flag_output; //!< Momentary flag to indicate the relay state uint8_t flag_init; //!< Momentary flag to indicate the end of initialization state uint8_t flag_proximity; //!< Momentary flag to indicate that the user is near uint8_t signal_cycle; //!< Acknolegable flag to indicate the end of measurement cycle } app_data_t; /*! * Settings struct */ typedef struct { mode_en mode; //!< Operational mode float_t Tset; //!< Target temperature float_t Thyst; //!< Target temperature hysteresis float_t Pset; //!< Proximity distance float_t Physt; //!< Proximity distance hysteresis } settings_t; /*! * User interface states */ typedef enum { ST_INIT =0, //!< ST_INIT: Still initializing ST_COUNT, //!< ST_COUNT: Measurement cycle ST_AVERAGE, //!< ST_AVERAGE: Display average ST_USER //!< ST_USER: Display when a user is near } state_en; /* * globals */ extern app_data_t app_data; extern state_en state; extern settings_t settings; /*! * Factory defaults */ #define _Init_settings(s) s = { \ .mode = HEATING, \ .Tset = 21.0, \ .Thyst = 2.0, \ .Pset = 75.0, \ .Physt = 10.0 \ } #endif /* THERMOSTAT_H_ */