/* * coffee.h * * Created on: Sep 25, 2017 * Author: Sebastian */ #ifndef COFFEE_H_ #define COFFEE_H_ #include #include "events.h" //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 } coffee_status_t; typedef enum { MODE_STATE, MODE_MENU, MODE_NULL } coffee_mode_t; typedef enum { PAGE_SOFTOFF, PAGE_KILL, PAGE_STATS, PAGE_STATS2, PAGE_DESCALING, PAGE_TEMP, PAGE_CLEAN, PAGE_RESTART, PAGE_EXIT, PAGE_NULL } coffee_menuPage_t; extern const char* StateName[]; extern const char* PageName[]; #define AMOUNT_PREINFUSION 24 //Preinfusion amount in ml #define TIME_SOAK 5000 //Time between preinfusion and infusion in ms #define TIME_INFUSION 25000 //Infusion time in ms #define TIME_PREINFUSION 2500 #define AMOUNT_DBLESPRESSO 59.0 //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 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 getLastBrewTime(void); int getSigValue(coffee_mode_t mode); uint16_t getCurrentCleanCycle(void); uint16_t getBrewCounter(void); uint64_t getTotalHeatingTime(void); uint16_t getDescBrewCounter (void); time_t * getDescTimestamp (void); void brewTimeHandler(void); void menuTimeHandler(void); void writeBackCache(void); void coffeeTerminate(event_t *event); void coffeeNap (uint64_t sec, uint64_t nanosec); void coffeeBrew(void); void coffeeClean(void); void stopBrewing(void); void coffeeIncreaseBrewCounter(void); void coffeeIncreaseHeatingTime(uint64_t heatingTime); void checkDescaling(void); int16_t checkDirtyEspresso (void); int16_t checkDirtyTime (void); void updateDescaling(void); #endif /* COFFEE_H_ */