CoffeePi
Coffee machine control for Raspberry Pi
hal.h
Go to the documentation of this file.
1 /*
2  * hal.h
3  *
4  * Created on: Aug 3, 2016
5  * Author: sebastian
6  */
7 
8 #ifndef HAL_H_
9 #define HAL_H_
10 
11 #define RELAIS_HEAT 29
12 #define RELAIS_PUMP 25
13 #define RELAIS_POWER 28
14 #define PIN_PRESSURE_CTRL 7
15 #define PIN_PROXIMITY_SENSOR 6
16 #define PIN_INT0 2 // Top button
17 #define PIN_INT1 0 // Bottom button
18 #define PIN_FLOW 3 // Flow sensor
19 #define FLOW_ML_PULSE (1000.0/990) // Flow sensor: volume (ml) per pulse
20 
21 #define TIME_BUTTONLONGPRESS 3 //Time in s until a Signal for a long pressed button is sent
22 /*
23  * Explanation for the signal levels
24  * SigInt_Psh Button is pushed
25  * SigInt_Rls Button is released
26  * SigInt_RlsLong Button is pressed for more than TIME_BUTTONLONGPRESS seconds
27  * SigPressCls Pressure control is closed, System is heating
28  * SigPressOpn Pressure control is open, heating is off
29  * SigProxOpn Proximity Sensor is uncovered
30  * SigProxCvrd Proximity Sensor is covered
31  */
32 
33 /*
34  * Functions of the buttons, the letter in brackets defines if the event is triggered
35  * on push(P), release(R) or long pressing(RLong) of the button
36  * TOP Button: Turn machine on(R), start brewing(P),
37  *
38  * BOTTOM button: Stop brewing immediately(P), Turn machine off(RLong),
39  */
40 enum HalSig {
51  SigBrewOn = 11,
53 };
54 
55 void halInit(void);
56 void halRelaisOn(int relais);
57 void halRelaisOff(int relais);
58 void halRelaisSet(int relais, int state);
59 int halGetRelaisState(int relais);
60 void halInt0(void);
61 void halInt1(void);
62 void halIntFlow(void);
63 void halIntPressure(void);
64 void halIntProximity(void);
65 float halGetFlow(void);
66 void halResetFlow(void);
67 bool halIsHeating(void);
68 bool halProxSensorCovered(void);
69 int halGetInt0(void);
70 int halGetInt1(void);
71 void halSendSignal(int value);
72 void halMachineOn(void);
73 void halMachineOff(void);
74 void halInt0TimerHandler(void);
75 void halInt1TimerHandler(void);
76 
77 #endif /* HAL_H_ */
void halRelaisOn(int relais)
Switches relais on.
Definition: hal.cpp:80
void halResetFlow(void)
Resets the Flow counter.
Definition: hal.cpp:240
void halRelaisSet(int relais, int state)
Switches relais to state.
Definition: hal.cpp:97
Definition: hal.h:43
Definition: hal.h:46
Definition: hal.h:44
Definition: hal.h:45
bool halProxSensorCovered(void)
Returns status of the proximity switch.
Definition: hal.cpp:260
void halMachineOff(void)
Turn machine off.
Definition: hal.cpp:314
void halRelaisOff(int relais)
Switches relais off.
Definition: hal.cpp:88
HalSig
Definition: hal.h:40
void halMachineOn(void)
Turn machine on.
Definition: hal.cpp:304
Definition: hal.h:52
Definition: hal.h:41
float halGetFlow(void)
Returns total flow trough sensor in ml.
Definition: hal.cpp:233
void halInt0(void)
Interrupt routine for Int0 (Top button)
Definition: hal.cpp:133
int halGetRelaisState(int relais)
Returns the state of the relais relais Returns HIGH when Relais is ON.
Definition: hal.cpp:119
int halGetInt0(void)
Returns the value of the top button Int0 (low active)
Definition: hal.cpp:274
bool halIsHeating(void)
Reads the status of the Pressure Control.
Definition: hal.cpp:248
Definition: hal.h:47
void halInt1(void)
Interrupt routine for Int1 (Bottom button)
Definition: hal.cpp:164
void halIntFlow(void)
Interrupt routine for the flow sensor It counts the edgdes and stores the value in flowcnt...
Definition: hal.cpp:196
int halGetInt1(void)
Returns the value of the bottom button Int1 (low active)
Definition: hal.cpp:282
Definition: hal.h:42
Definition: hal.h:48
Definition: hal.h:49
void halInt1TimerHandler(void)
Definition: hal.cpp:182
void halInit(void)
Initializes HAL.
Definition: hal.cpp:30
Definition: hal.h:50
void halIntProximity(void)
Method to handle toggle of the proximity sensor.
Definition: hal.cpp:221
int state
Definition: coffee.cpp:27
void halSendSignal(int value)
send Signal to coffee thread
Definition: hal.cpp:290
void halIntPressure(void)
Interrupt routine for the pressure control.
Definition: hal.cpp:209
Definition: hal.h:51
void halInt0TimerHandler(void)
Definition: hal.cpp:151