Kaynağa Gözat

added pressure control and proximitiy sensor to hal

pek72 8 yıl önce
ebeveyn
işleme
eae0f274f1
2 değiştirilmiş dosya ile 29 ekleme ve 1 silme
  1. 21 0
      CoffeeCode/hal.cpp
  2. 8 1
      CoffeeCode/hal.h

+ 21 - 0
CoffeeCode/hal.cpp

@@ -31,6 +31,8 @@ void halInit(void) {
 	pinMode(RELAIS_HEAT, OUTPUT);
 	pinMode(RELAIS_PUMP, OUTPUT);
 	pinMode(RELAIS_POWER, OUTPUT);
+	pinMode(PRESSURE_CTRL, INPUT);
+	pinMode(PROXIMITY_SENSOR, INPUT);
 	pinMode(HAL_INT0, INPUT);
 	pinMode(HAL_INT1, INPUT);
 	pinMode(HAL_FLOW, INPUT);
@@ -112,3 +114,22 @@ float halGetFlow(void) {
 	return flowcnt*FLOW_ML_PULSE;
 }
 
+/*
+ * Reads the status of the Pressure Control
+ * @return 1 for closed Pressure Control and 0 for open
+ */
+int halGetPressureCtrl(void) {
+	if (digitalRead(PRESSURE_CTRL)) {
+		return 0;
+	} else
+		return 1;
+}
+
+/*
+ * Returns status of the proximity switch
+ * @return 1 if the proximity switch is covered and 0 if uncovered
+ */
+int halGetProximitySensor(void){
+	return digitalRead(PROXIMITY_SENSOR);
+}
+

+ 8 - 1
CoffeeCode/hal.h

@@ -11,13 +11,18 @@
 #define RELAIS_HEAT		29
 #define RELAIS_PUMP		25
 #define RELAIS_POWER	28
+#define PRESSURE_CTRL	24
+#define PROXIMITY_SENSOR	6
 
-#define HAL_INT0		0 // buttom button
+#define HAL_INT0		0 // bottom button
 #define HAL_INT1		2 // top button
 #define HAL_FLOW		3 // flow sensor
 
+#define HAL_PROX_COVERED	1 //proximity sensor
+
 #define FLOW_ML_PULSE	(1000.0/990) // Flow sensor: volume (ml) per pulse
 
+
 void halInit(void);
 void halRelaisOn(int relais);
 void halRelaisOff(int relais);
@@ -26,6 +31,8 @@ void halInt0(void);
 void halInt1(void);
 void halIntFlow(void);
 float halGetFlow(void);
+int halGetPressureCtrl(void);
+int halGetProximitySensor(void);
 
 
 #endif /* HAL_H_ */