coffee.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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,
  34. PAGE_KILL,
  35. PAGE_STATS,
  36. PAGE_STATS2,
  37. PAGE_DESCALING,
  38. PAGE_TEMP,
  39. PAGE_CLEAN,
  40. PAGE_RESTART,
  41. PAGE_SETTINGS,
  42. PAGE_RESETKWH,
  43. PAGE_RESETKWH_VAL,
  44. PAGE_CHANGEPREINF,
  45. PAGE_CHANGEPREINF_VAL,
  46. PAGE_CHANGEBREWTIME,
  47. PAGE_CHANGEBREWTIME_VAL,
  48. PAGE_CHANGEBREWML,
  49. PAGE_CHANGEBREWML_VAL,
  50. PAGE_CHANGESOAKTIME,
  51. PAGE_CHANGESOAKTIME_VAL,
  52. PAGE_CHANGEAUTORESET,
  53. PAGE_CHANGEAUTORESET_VAL,
  54. PAGE_LEAVESETTINGS,
  55. PAGE_EXIT,
  56. PAGE_NULL
  57. //Entering new PAGES? Don't forget to update pagenames in coffee.cpp!
  58. } coffee_menuPage_t;
  59. struct coffeeConfig{
  60. uint16_t amount_preinfusion;
  61. uint16_t time_soak;
  62. uint16_t time_infusion;
  63. uint16_t amount_dblespresso;
  64. };
  65. #define AMOUNT_PREINFUSION 24 //Preinfusion amount in ml
  66. #define TIME_SOAK 5000 //Time between preinfusion and infusion in ms
  67. #define TIME_INFUSION 25000 //Infusion time in ms
  68. #define TIME_PREINFUSION 2500
  69. #define AMOUNT_DBLESPRESSO 59 //Size of a double espresso in ml
  70. #define DIRTY_ESPRESSO 35 //Number of espressi until the next cleaning
  71. #define DIRTY_TIME 90 //Number of days until the next cleaning
  72. #define MENUTIMEOUT 30 //timeout of the menu when no input is received from the user (in seconds)
  73. #define CLEANING_CYCLES 20 //Number of On-Off cycles during the cleaning phase
  74. extern const char* StateName[];
  75. extern const char* PageName[];
  76. extern coffeeConfig coffeeCFG;
  77. void *coffeeThread(void *threadid);
  78. void coffeeHandler(int signum, siginfo_t *siginfo, void *context);
  79. bool SigValueEmpty(void);
  80. void changeState(coffee_status_t newState);
  81. void changeMode(coffee_mode_t newMode);
  82. void changePage(coffee_menuPage_t newPage);
  83. void leaveMenu(void);
  84. void enterMenu(void);
  85. coffee_status_t getState(void);
  86. uint16_t getBrewTime(void);
  87. uint16_t getLastBrewTime(void);
  88. int getSigValue(coffee_mode_t mode);
  89. uint16_t getCurrentCleanCycle(void);
  90. uint16_t getBrewCounter(void);
  91. uint16_t getDescBrewCounter (void);
  92. time_t * getDescTimestamp (void);
  93. void brewTimerHandler(void);
  94. void menuTimerHandler(void);
  95. void writeBackCache(void);
  96. void coffeeTerminate(event_t *event);
  97. void coffeeNap (uint64_t sec, uint64_t nanosec);
  98. void coffeeManualBrewStart (void);
  99. void coffeeManualBrewStop (void);
  100. void coffeeBrew(void);
  101. void coffeeClean(void);
  102. void stopBrewing(void);
  103. void coffeeIncreaseBrewCounter(void);
  104. void checkDescaling(void);
  105. int16_t checkDirtyEspresso (void);
  106. int16_t checkDirtyTime (void);
  107. void updateDescaling(void);
  108. #endif /* COFFEE_H_ */