/* * coffee.h * * Created on: Sep 25, 2017 * Author: Sebastian */ #ifndef COFFEE_H_ #define COFFEE_H_ #include #include "events.h" #include //define status typedef enum { STATE_OFF, STATE_HEATING, STATE_INITALHEATING, STATE_IDLE, STATE_BREW, STATE_BREWMANUAL, STATE_CLEANING, STATE_ERROR, STATE_WAIT_OFF, STATE_FULLTANK, STATE_NULL //Entering new States? Don't forget to update statenames in coffee.cpp! } coffee_status_t; typedef enum { MODE_STATE, MODE_MENU, MODE_NULL } coffee_mode_t; typedef enum { PAGE_SOFTOFF=0, PAGE_KILL, PAGE_SINGLEESPRESSO, PAGE_STATS, PAGE_STATS2, PAGE_DESCALING, PAGE_TEMP, PAGE_CLEAN, PAGE_REBOOT, PAGE_SETTINGS, PAGE_RESETKWH, PAGE_RESETKWH_VAL, PAGE_CHANGEPREINF, PAGE_CHANGEPREINF_VAL, PAGE_CHANGEBREWTIME, PAGE_CHANGEBREWTIME_VAL, PAGE_CHANGEBREWML, PAGE_CHANGEBREWML_VAL, PAGE_CHANGESOAKTIME, PAGE_CHANGESOAKTIME_VAL, PAGE_CHANGEAUTORESET, PAGE_CHANGEAUTORESET_VAL, PAGE_LEAVESETTINGS, PAGE_EXIT, PAGE_NULL //Entering new PAGES? Don't forget to update pagenames in coffee.cpp! } coffee_menuPage_t; typedef struct coffeeConfig{ uint16_t amount_preinfusion; uint16_t time_soak; uint16_t time_infusion; uint16_t amount_espresso; }coffeeConfig; #define AMOUNT_PREINFUSION 24 //Preinfusion amount in ml #define TIME_PREINFUSION 2500 //Time for the preinfusion in ms #define TIME_SOAK 5000 //Time between preinfusion and infusion in ms #define TIME_INFUSION 25000 //Infusion time in ms #define AMOUNT_DBLESPRESSO 59 //Size of a double espresso in ml #define DIRTY_ESPRESSO 35 //Number of espressi until the next cleaning #define DIRTY_TIME 90 //Number of days until the next cleaning #define MENUTIMEOUT 30 //timeout of the menu when no input is received from the user (in seconds) #define CLEANING_CYCLES 20 //Number of On-Off cycles during the cleaning phase extern const char* StateName[]; extern const char* PageName[]; extern coffeeConfig coffeeCFG; void *coffeeThread(void *threadid); void coffeeHandler(int signum, siginfo_t *siginfo, void *context); bool SigValueEmpty(void); void changeState(coffee_status_t newState); void changeMode(coffee_mode_t newMode); void changePage(coffee_menuPage_t newPage); void leaveMenu(void); void enterMenu(void); coffee_status_t getState(void); uint16_t getBrewTime(void); uint16_t getLastBrewTime(void); int getSigValue(coffee_mode_t mode); uint16_t getCurrentCleanCycle(void); uint16_t getBrewCounter(void); uint16_t getDescBrewCounter (void); time_t * getDescTimestamp (void); coffeeConfig* getCoffeeCfg (void); void brewTimerHandler(void); void menuTimerHandler(void); void writeBackCache(void); void coffeeTerminate(event_t *event); void coffeeNap (uint64_t sec, uint64_t nanosec); void coffeeManualBrewStart (void); void coffeeManualBrewStop (void); void coffeeBrew(uint16_t amount_preinfusion, uint16_t time_soak, uint16_t time_infusion, uint16_t amount_espresso); void coffeeClean(void); void stopBrewing(void); void coffeeIncreaseBrewCounter(void); void checkDescaling(void); int16_t checkDirtyEspresso (void); int16_t checkDirtyTime (void); void updateDescaling(void); #endif /* COFFEE_H_ */