coffee.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * coffee.h
  3. *
  4. * Created on: Sep 25, 2017
  5. * Author: Sebastian
  6. */
  7. #ifndef COFFEE_H_
  8. #define COFFEE_H_
  9. #include <csignal>
  10. #include "events.h"
  11. #include <stdint.h>
  12. //define status
  13. typedef enum {
  14. STATE_OFF,
  15. STATE_HEATING,
  16. STATE_INITALHEATING,
  17. STATE_IDLE,
  18. STATE_BREW,
  19. STATE_BREWMANUAL,
  20. STATE_CLEANING,
  21. STATE_ERROR,
  22. STATE_WAIT_OFF,
  23. STATE_FULLTANK,
  24. STATE_NULL
  25. //Entering new States? Don't forget to update statenames in coffee.cpp!
  26. } coffee_status_t;
  27. typedef enum {
  28. MODE_STATE,
  29. MODE_MENU,
  30. MODE_NULL
  31. } coffee_mode_t;
  32. typedef enum {
  33. PAGE_SOFTOFF=0,
  34. PAGE_KILL,
  35. PAGE_SINGLEESPRESSO,
  36. PAGE_STATS,
  37. PAGE_STATS2,
  38. PAGE_DESCALING,
  39. PAGE_TEMP,
  40. PAGE_CLEAN,
  41. PAGE_REBOOT,
  42. PAGE_SETTINGS,
  43. PAGE_RESETKWH,
  44. PAGE_RESETKWH_VAL,
  45. PAGE_CHANGEPREINF,
  46. PAGE_CHANGEPREINF_VAL,
  47. PAGE_CHANGEBREWTIME,
  48. PAGE_CHANGEBREWTIME_VAL,
  49. PAGE_CHANGEBREWML,
  50. PAGE_CHANGEBREWML_VAL,
  51. PAGE_CHANGESOAKTIME,
  52. PAGE_CHANGESOAKTIME_VAL,
  53. PAGE_CHANGEAUTORESET,
  54. PAGE_CHANGEAUTORESET_VAL,
  55. PAGE_LEAVESETTINGS,
  56. PAGE_EXIT,
  57. PAGE_NULL
  58. //Entering new PAGES? Don't forget to update pagenames in coffee.cpp!
  59. } coffee_menuPage_t;
  60. typedef struct coffeeConfig{
  61. uint16_t amount_preinfusion;
  62. uint16_t time_soak;
  63. uint16_t time_infusion;
  64. uint16_t amount_espresso;
  65. }coffeeConfig;
  66. #define AMOUNT_PREINFUSION 24 //Preinfusion amount in ml
  67. #define TIME_PREINFUSION 2500 //Time for the preinfusion in ms
  68. #define TIME_SOAK 5000 //Time between preinfusion and infusion in ms
  69. #define TIME_INFUSION 25000 //Infusion time in ms
  70. #define AMOUNT_DBLESPRESSO 59 //Size of a double espresso in ml
  71. #define DIRTY_ESPRESSO 35 //Number of espressi until the next cleaning
  72. #define DIRTY_TIME 90 //Number of days until the next cleaning
  73. #define MENUTIMEOUT 30 //timeout of the menu when no input is received from the user (in seconds)
  74. #define CLEANING_CYCLES 20 //Number of On-Off cycles during the cleaning phase
  75. extern const char* StateName[];
  76. extern const char* PageName[];
  77. extern coffeeConfig coffeeCFG;
  78. void *coffeeThread(void *threadid);
  79. void coffeeHandler(int signum, siginfo_t *siginfo, void *context);
  80. bool SigValueEmpty(void);
  81. void changeState(coffee_status_t newState);
  82. void changeMode(coffee_mode_t newMode);
  83. void changePage(coffee_menuPage_t newPage);
  84. void leaveMenu(void);
  85. void enterMenu(void);
  86. coffee_status_t getState(void);
  87. uint16_t getBrewTime(void);
  88. uint16_t getLastBrewTime(void);
  89. int getSigValue(coffee_mode_t mode);
  90. uint16_t getCurrentCleanCycle(void);
  91. uint16_t getBrewCounter(void);
  92. uint16_t getDescBrewCounter (void);
  93. time_t * getDescTimestamp (void);
  94. coffeeConfig* getCoffeeCfg (void);
  95. void brewTimerHandler(void);
  96. void menuTimerHandler(void);
  97. void writeBackCache(void);
  98. void coffeeTerminate(event_t *event);
  99. void coffeeNap (uint64_t sec, uint64_t nanosec);
  100. void coffeeManualBrewStart (void);
  101. void coffeeManualBrewStop (void);
  102. void coffeeBrew(uint16_t amount_preinfusion, uint16_t time_soak, uint16_t time_infusion, uint16_t amount_espresso);
  103. void coffeeClean(void);
  104. void stopBrewing(void);
  105. void coffeeIncreaseBrewCounter(void);
  106. void checkDescaling(void);
  107. int16_t checkDirtyEspresso (void);
  108. int16_t checkDirtyTime (void);
  109. void updateDescaling(void);
  110. #endif /* COFFEE_H_ */