coffee.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 TIME_PREINFUSION 2500
  45. #define AMOUNT_DBLESPRESSO 59.0 //Size of a double espresso in ml
  46. #define DIRTY_ESPRESSO 35 //Number of espressi until the next cleaning
  47. #define DIRTY_TIME 90 //Number of days until the next cleaning
  48. #define MENUTIMEOUT 30 //timeout of the menu when no input is received from the user (in seconds)
  49. void *coffeeThread(void *threadid);
  50. void coffeeHandler(int signum, siginfo_t *siginfo, void *context);
  51. bool SigValueEmpty(void);
  52. void changeState(coffee_status_t newState);
  53. void changeMode(coffee_mode_t newMode);
  54. void changePage(coffee_menuPage_t newPage);
  55. void leaveMenu(void);
  56. void enterMenu(void);
  57. coffee_status_t getState(void);
  58. int getSigValue(coffee_mode_t mode);
  59. uint16_t getBrewCounter(void);
  60. uint64_t getTotalHeatingTime(void);
  61. uint16_t getDescBrewCounter (void);
  62. time_t * getDescTimestamp (void);
  63. void brewTimeHandler(void);
  64. void menuTimeHandler(void);
  65. void writeBackCache(void);
  66. void coffeeTerminate(event_t *event);
  67. void coffeeNap (uint64_t sec, uint64_t nanosec);
  68. void coffeeBrew(void);
  69. void coffeeClean(void);
  70. void stopBrewing(void);
  71. void coffeeIncreaseBrewCounter(void);
  72. void coffeeIncreaseHeatingTime(uint64_t heatingTime);
  73. void checkDescaling(void);
  74. int16_t checkDirtyEspresso (void);
  75. int16_t checkDirtyTime (void);
  76. void updateDescaling(void);
  77. #endif /* COFFEE_H_ */