Microprocessor and peripheral 2 assignments for AUTH
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

thermostat.h 2.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*!
  2. * \file thermostat.h
  3. * \brief
  4. * Application wide data type declarations
  5. *
  6. * Author: Christos Choutouridis AEM: 8997
  7. * email : <cchoutou@ece.auth.gr>
  8. */
  9. #ifndef THERMOSTAT_H_
  10. #define THERMOSTAT_H_
  11. /*
  12. * Hard coded user settings
  13. */
  14. #define MEAS_WINDOW (120) // [sec]
  15. #define MEAS_INTERVAL (5) // [sec]
  16. #define MEASUREMENTS (MEAS_WINDOW / MEAS_INTERVAL) // keep this integer
  17. #define UI_AVERAGE_TIME (10) // [sec]
  18. //#define UI_USER_TIME (10)
  19. typedef float float_t; //!< Select the floating point type for application
  20. typedef int int_t; //!< Select the integer type for application
  21. /*!
  22. * Thermostat mode enumerator
  23. */
  24. typedef enum {
  25. HEATING =0, //!< HEATING
  26. COOLING //!< COOLING
  27. } mode_en;
  28. /*!
  29. * Application common data type
  30. */
  31. typedef struct {
  32. float_t T[MEASUREMENTS]; //!< Temperature samples
  33. float_t Tav; //!< Average temperature
  34. uint32_t cur; //!< Cursor on sample array
  35. uint8_t flag_output; //!< Momentary flag to indicate the relay state
  36. uint8_t flag_init; //!< Momentary flag to indicate the end of initialization state
  37. uint8_t flag_proximity; //!< Momentary flag to indicate that the user is near
  38. uint8_t signal_cycle; //!< Acknolegable flag to indicate the end of measurement cycle
  39. } app_data_t;
  40. /*!
  41. * Settings struct
  42. */
  43. typedef struct {
  44. mode_en mode; //!< Operational mode
  45. float_t Tset; //!< Target temperature
  46. float_t Thyst; //!< Target temperature hysteresis
  47. float_t Pset; //!< Proximity distance
  48. float_t Physt; //!< Proximity distance hysteresis
  49. } settings_t;
  50. /*!
  51. * User interface states
  52. */
  53. typedef enum {
  54. ST_INIT =0, //!< ST_INIT: Still initializing
  55. ST_COUNT, //!< ST_COUNT: Measurement cycle
  56. ST_AVERAGE, //!< ST_AVERAGE: Display average
  57. ST_USER //!< ST_USER: Display when a user is near
  58. } state_en;
  59. /*
  60. * globals
  61. */
  62. extern app_data_t app_data;
  63. extern state_en state;
  64. extern settings_t settings;
  65. /*!
  66. * Factory defaults
  67. */
  68. #define _Init_settings(s) s = { \
  69. .mode = HEATING, \
  70. .Tset = 21.0, \
  71. .Thyst = 2.0, \
  72. .Pset = 75.0, \
  73. .Physt = 10.0 \
  74. }
  75. #endif /* THERMOSTAT_H_ */