/* * hal.h * * Created on: Aug 3, 2016 * Author: sebastian */ #ifndef HAL_H_ #define HAL_H_ #include "events.h" //these are the wPi numberings #define RELAIS_HEAT 29 #define RELAIS_PUMP 25 #define RELAIS_POWER 28 #define PIN_PRESSURE_CTRL 7 #define PIN_PROXIMITY_SENSOR 6 #define PIN_INT0 2 // Top button #define PIN_INT1 0 // Bottom button #define PIN_FLOW 3 // Flow sensor #define PIN_DISP 4 #define FLOW_ML_PULSE (1000.0/2219) // Flow sensor: volume (ml) per pulse #define PIN_ROTARY1 15 #define PIN_ROTARY2 16 #define ROTARY_RESOLUTION 127 #define ROTARY_STEPSIZE 15 #define TIME_BUTTONLONGPRESS 3 //Time in s until a Signal for a long pressed button is sent #define BREW_MANUAL_TRIGGER 25 //specifies the flow ticks after which a brew_manual signal is triggered (25 eq. approx. 11ml) /* * Explanation for the signal levels * SigInt_Psh Button is pushed * SigInt_Rls Button is released * SigInt_RlsLong Button is pressed for more than TIME_BUTTONLONGPRESS seconds * SigPressCls Pressure control is closed, System is heating * SigPressOpn Pressure control is open, heating is off * SigProxOpn Proximity Sensor is uncovered * SigProxCvrd Proximity Sensor is covered */ /* * Functions of the buttons, the letter in brackets defines if the event is triggered * on push(P), release(R) or long pressing(RLong) of the button * TOP Button: Turn machine on(R), start brewing(P), * * BOTTOM button: Stop brewing immediately(P), Turn machine off(RLong), */ enum HalSig { SigInt0Psh = 1, SigInt0Rls = 2, SigInt0RlsLong = 3, SigInt1Psh = 4, SigInt1Rls = 5, SigInt1RlsLong = 6, SigPressCls = 7, SigPressOpn = 8, SigProxOpn = 9, SigProxCvrd = 10, SigBrewOn = 11, SigBrewOff = 12, SigPowerUp = 13, SigPowerDown = 14, SigRotCW = 15, SigRotCCW = 16 }; extern const char* SigName[]; void halInit(void); void halDisplayOff(); void halDisplayOn(); void halRelaisOn(int relais); void halRelaisOff(int relais); void halRelaisSet(int relais, int state); int halGetRelaisState(int relais); void halIntRotary(void); void halInt0(void); void halInt1(void); void flowResetTimerHandler(void); void halIntFlow(void); void halIntPressure(void); double halgetHeatingTime(void); void halIntProximity(void); float halGetFlow(void); float halGetLastFlow(void); void halResetFlow(void); bool halIsHeating(void); bool halProxSensorCovered(void); int halGetInt0(void); int halGetInt1(void); void halSendSignal(HalSig value); void halMachineOn(void); void halMachineOff(void); void halInt0TimerHandler(void); void halInt1TimerHandler(void); void halIdleTimerHandler(void); void halEnterIdle (void); void halLeaveIdle (void); void halPumpOn(); void halPumpOff(void); void halIncreaseLogCycleCounter(void); double halGetPumpTime(void); void timespec_diff(timespec *start, timespec *stop, timespec *result); void halTerminate(event_t *event); void halWriteBackCache(void); #endif /* HAL_H_ */