coffee.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_DEMO,
  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. void *coffeeThread(void *threadid);
  52. void coffeeHandler(int signum, siginfo_t *siginfo, void *context);
  53. bool SigValueEmpty(void);
  54. void changeState(coffee_status_t newState);
  55. void changeMode(coffee_mode_t newMode);
  56. void changePage(coffee_menuPage_t newPage);
  57. void leaveMenu(void);
  58. coffee_status_t getState(void);
  59. uint16_t getLastBrewTime(void);
  60. int getSigValue(coffee_mode_t mode);
  61. uint16_t getBrewCounter(void);
  62. uint64_t getTotalHeatingTime(void);
  63. uint16_t getDescBrewCounter (void);
  64. time_t * getDescTimestamp (void);
  65. void brewTimeHandler(void);
  66. void writeBackCache(void);
  67. void coffeeTerminate(event_t *event);
  68. void coffeeNap (uint64_t sec, uint64_t nanosec);
  69. void coffeeBrew(void);
  70. void coffeeClean(void);
  71. void stopBrewing(void);
  72. void coffeeIncreaseBrewCounter(void);
  73. void coffeeIncreaseHeatingTime(uint64_t heatingTime);
  74. void checkDescaling(void);
  75. int16_t checkDirtyEspresso (void);
  76. int16_t checkDirtyTime (void);
  77. void updateDescaling(void);
  78. #endif /* COFFEE_H_ */