123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- /*
- * 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_FLOWRESET 600 //Wait time in ms to reset flow counter after the last received flow signal
- #define TIME_BUTTONLONGPRESS 3 //Time in s until a Signal for a long pressed button is sent
- #define BREW_MANUAL_TRIGGER 7500 //specifies the ms after which a brew_manual signal is triggered
- /*
- * 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 halFlowTimerHandler(void);
- void halIntFlow(void);
- void halIntPressure(void);
- void halStartHeatingTime(void);
- void halStopHeatingTime(void);
- void halIntProximity(void);
- uint64_t halGetTotalHeatingTime(void);
- void halSetTotalHeatingTime(uint64_t newTime);
- float halGetFlow(void);
- uint16_t halGetFlowTime(void);
- float halGetLastFlow(void);
- uint16_t halGetLastFlowTime(void);
- uint16_t halGetFlowResetTime(void);
- void halSetFlowResetTime(uint16_t val);
- 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);
- bool halIdle(HalSig value);
- void halResetIdleTimer(void);
- void halPumpOn();
- void halPumpOff(void);
- void timespec_diff(timespec *start, timespec *stop, timespec *result);
- void halTerminate(event_t *event);
- void halWriteBackCache(void);
- #endif /* HAL_H_ */
|