coffee.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. } coffee_status_t;
  25. typedef enum {
  26. MODE_STATE,
  27. MODE_MENU,
  28. MODE_NULL
  29. } coffee_mode_t;
  30. typedef enum {
  31. PAGE_SOFTOFF,
  32. PAGE_KILL,
  33. PAGE_STATS,
  34. PAGE_STATS2,
  35. PAGE_DESCALING,
  36. PAGE_TEMP,
  37. PAGE_CLEAN,
  38. PAGE_RESTART,
  39. PAGE_EXIT,
  40. PAGE_NULL
  41. } coffee_menuPage_t;
  42. extern const char* StateName[];
  43. extern const char* PageName[];
  44. #define AMOUNT_PREINFUSION 24 //Preinfusion amount in ml
  45. #define TIME_SOAK 5000 //Time between preinfusion and infusion in ms
  46. #define TIME_INFUSION 25000 //Infusion time in ms
  47. #define TIME_PREINFUSION 2500
  48. #define AMOUNT_DBLESPRESSO 59.0 //Size of a double espresso in ml
  49. #define DIRTY_ESPRESSO 35 //Number of espressi until the next cleaning
  50. #define DIRTY_TIME 90 //Number of days until the next cleaning
  51. #define MENUTIMEOUT 30 //timeout of the menu when no input is received from the user (in seconds)
  52. #define CLEANING_CYCLES 20 //Number of On-Off cycles during the cleaning phase
  53. void *coffeeThread(void *threadid);
  54. void coffeeHandler(int signum, siginfo_t *siginfo, void *context);
  55. bool SigValueEmpty(void);
  56. void changeState(coffee_status_t newState);
  57. void changeMode(coffee_mode_t newMode);
  58. void changePage(coffee_menuPage_t newPage);
  59. void leaveMenu(void);
  60. void enterMenu(void);
  61. coffee_status_t getState(void);
  62. uint16_t getLastBrewTime(void);
  63. int getSigValue(coffee_mode_t mode);
  64. uint16_t getCurrentCleanCycle(void);
  65. uint16_t getBrewCounter(void);
  66. uint64_t getTotalHeatingTime(void);
  67. uint16_t getDescBrewCounter (void);
  68. time_t * getDescTimestamp (void);
  69. void brewTimeHandler(void);
  70. void menuTimeHandler(void);
  71. void writeBackCache(void);
  72. void coffeeTerminate(event_t *event);
  73. void coffeeNap (uint64_t sec, uint64_t nanosec);
  74. void coffeeBrew(void);
  75. void coffeeClean(void);
  76. void stopBrewing(void);
  77. void coffeeIncreaseBrewCounter(void);
  78. void coffeeIncreaseHeatingTime(uint64_t heatingTime);
  79. void checkDescaling(void);
  80. int16_t checkDirtyEspresso (void);
  81. int16_t checkDirtyTime (void);
  82. void updateDescaling(void);
  83. #endif /* COFFEE_H_ */