coffee.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. } coffee_status_t;
  24. typedef enum {
  25. MODE_STATE,
  26. MODE_MENU
  27. } coffee_mode_t;
  28. typedef enum {
  29. PAGE_SOFTOFF,
  30. PAGE_KILL,
  31. PAGE_STATS,
  32. PAGE_STATS2,
  33. PAGE_DESCALING,
  34. PAGE_TEMP,
  35. PAGE_CLEAN,
  36. PAGE_DEMO,
  37. PAGE_EXIT
  38. } coffee_menuPage_t;
  39. extern const char* StateName[];
  40. extern const char* PageName[];
  41. #define AMOUNT_PREINFUSION 24 //Preinfusion amount in ml
  42. #define TIME_SOAK 5000 //Time between preinfusion and infusion in ms
  43. #define TIME_INFUSION 25000 //Infusion time in ms
  44. #define AMOUNT_DBLESPRESSO 59.0 //Size of a double espresso in ml
  45. #define DIRTY_ESPRESSO 35 //Number of espressi until the next cleaning
  46. #define DIRTY_TIME 90 //Number of days until the next cleaning
  47. void *coffeeThread(void *threadid);
  48. void coffeeHandler(int signum, siginfo_t *siginfo, void *context);
  49. bool SigValueEmpty(void);
  50. void changeState(coffee_status_t newState);
  51. void changeMode(coffee_mode_t newMode);
  52. void changePage(coffee_menuPage_t newPage);
  53. void leaveMenu(void);
  54. coffee_status_t getState(void);
  55. int getSigValue(coffee_mode_t mode);
  56. uint16_t getBrewCounter(void);
  57. uint64_t getTotalHeatingTime(void);
  58. uint16_t getDescBrewCounter (void);
  59. time_t * getDescTimestamp (void);
  60. void brewTimeHandler(void);
  61. void writeBackCache(void);
  62. void coffeeTerminate(event_t *event);
  63. void coffeeBrew(void);
  64. void coffeeClean(void);
  65. void stopBrewing(void);
  66. void coffeeIncreaseBrewCounter(void);
  67. void coffeeIncreaseHeatingTime(uint64_t heatingTime);
  68. void checkDescaling(void);
  69. int16_t checkDirtyEspresso (void);
  70. int16_t checkDirtyTime (void);
  71. void updateDescaling(void);
  72. #endif /* COFFEE_H_ */