coffee.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. //define status
  12. typedef enum {
  13. STATE_OFF,
  14. STATE_HEATING,
  15. STATE_INITALHEATING,
  16. STATE_IDLE,
  17. STATE_BREW,
  18. STATE_BREWMANUAL,
  19. STATE_CLEANING,
  20. STATE_ERROR,
  21. STATE_WAIT_OFF,
  22. STATE_FULLTANK,
  23. STATE_NULL
  24. //Entering new States? Don't forget to update statenames in coffee.cpp!
  25. } coffee_status_t;
  26. typedef enum {
  27. MODE_STATE,
  28. MODE_MENU,
  29. MODE_NULL
  30. } coffee_mode_t;
  31. typedef enum {
  32. PAGE_SOFTOFF,
  33. PAGE_KILL,
  34. PAGE_STATS,
  35. PAGE_STATS2,
  36. PAGE_DESCALING,
  37. PAGE_TEMP,
  38. PAGE_CLEAN,
  39. PAGE_RESTART,
  40. PAGE_SETTINGS,
  41. PAGE_RESETKWH,
  42. PAGE_CHANGEPREINF,
  43. PAGE_CHANGEBREWTIME,
  44. PAGE_CHANGEBREWML,
  45. PAGE_CHANGESOAKTIME,
  46. PAGE_LEAVESETTINGS,
  47. PAGE_EXIT,
  48. PAGE_NULL
  49. //Entering new PAGES? Don't forget to update pagenames in coffee.cpp!
  50. } coffee_menuPage_t;
  51. extern const char* StateName[];
  52. extern const char* PageName[];
  53. #define AMOUNT_PREINFUSION 24 //Preinfusion amount in ml
  54. #define TIME_SOAK 5000 //Time between preinfusion and infusion in ms
  55. #define TIME_INFUSION 25000 //Infusion time in ms
  56. #define TIME_PREINFUSION 2500
  57. #define AMOUNT_DBLESPRESSO 59.0 //Size of a double espresso in ml
  58. #define DIRTY_ESPRESSO 35 //Number of espressi until the next cleaning
  59. #define DIRTY_TIME 90 //Number of days until the next cleaning
  60. #define MENUTIMEOUT 30 //timeout of the menu when no input is received from the user (in seconds)
  61. #define CLEANING_CYCLES 20 //Number of On-Off cycles during the cleaning phase
  62. void *coffeeThread(void *threadid);
  63. void coffeeHandler(int signum, siginfo_t *siginfo, void *context);
  64. bool SigValueEmpty(void);
  65. void changeState(coffee_status_t newState);
  66. void changeMode(coffee_mode_t newMode);
  67. void changePage(coffee_menuPage_t newPage);
  68. void leaveMenu(void);
  69. void enterMenu(void);
  70. coffee_status_t getState(void);
  71. uint16_t getBrewTime(void);
  72. uint16_t getLastBrewTime(void);
  73. int getSigValue(coffee_mode_t mode);
  74. uint16_t getCurrentCleanCycle(void);
  75. uint16_t getBrewCounter(void);
  76. uint16_t getDescBrewCounter (void);
  77. time_t * getDescTimestamp (void);
  78. void brewTimerHandler(void);
  79. void menuTimerHandler(void);
  80. void writeBackCache(void);
  81. void coffeeTerminate(event_t *event);
  82. void coffeeNap (uint64_t sec, uint64_t nanosec);
  83. void coffeeManualBrewStart (void);
  84. void coffeeManualBrewStop (void);
  85. void coffeeBrew(void);
  86. void coffeeClean(void);
  87. void stopBrewing(void);
  88. void coffeeIncreaseBrewCounter(void);
  89. void checkDescaling(void);
  90. int16_t checkDirtyEspresso (void);
  91. int16_t checkDirtyTime (void);
  92. void updateDescaling(void);
  93. #endif /* COFFEE_H_ */