|
@@ -8,19 +8,23 @@
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
#include <errno.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <string.h>
|
|
|
|
+#include "lcd.h"
|
|
#include "hal.h"
|
|
#include "hal.h"
|
|
#include "global.h"
|
|
#include "global.h"
|
|
#include "logger.h"
|
|
#include "logger.h"
|
|
|
|
|
|
|
|
+int flowcnt = 0;
|
|
|
|
+
|
|
void halInit(void) {
|
|
void halInit(void) {
|
|
- halRelaisOff(RELAIS_HEAT);
|
|
|
|
|
|
+ halRelaisOn(RELAIS_HEAT);
|
|
halRelaisOff(RELAIS_PUMP);
|
|
halRelaisOff(RELAIS_PUMP);
|
|
- halRelaisOff(RELAIS_POWER);
|
|
|
|
|
|
+ halRelaisOn(RELAIS_POWER);
|
|
pinMode(RELAIS_HEAT, OUTPUT);
|
|
pinMode(RELAIS_HEAT, OUTPUT);
|
|
pinMode(RELAIS_PUMP, OUTPUT);
|
|
pinMode(RELAIS_PUMP, OUTPUT);
|
|
pinMode(RELAIS_POWER, OUTPUT);
|
|
pinMode(RELAIS_POWER, OUTPUT);
|
|
pinMode(HAL_INT0, INPUT);
|
|
pinMode(HAL_INT0, INPUT);
|
|
pinMode(HAL_INT1, INPUT);
|
|
pinMode(HAL_INT1, INPUT);
|
|
|
|
+ pinMode(HAL_FLOW, INPUT);
|
|
if (wiringPiISR(HAL_INT0, INT_EDGE_FALLING, &halInt0) < 0) {
|
|
if (wiringPiISR(HAL_INT0, INT_EDGE_FALLING, &halInt0) < 0) {
|
|
logger_error("Unable to setup ISR0: %s\n", strerror(errno));
|
|
logger_error("Unable to setup ISR0: %s\n", strerror(errno));
|
|
return;
|
|
return;
|
|
@@ -29,6 +33,10 @@ void halInit(void) {
|
|
logger_error("Unable to setup ISR1: %s\n", strerror(errno));
|
|
logger_error("Unable to setup ISR1: %s\n", strerror(errno));
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ if (wiringPiISR(HAL_FLOW, INT_EDGE_FALLING, &halIntFlow) < 0) {
|
|
|
|
+ logger_error("Unable to setup ISRFLOW: %s\n", strerror(errno));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
void halRelaisOn(int relais) {
|
|
void halRelaisOn(int relais) {
|
|
halRelaisSet(relais, LOW);
|
|
halRelaisSet(relais, LOW);
|
|
@@ -51,12 +59,29 @@ void halRelaisSet(int relais, int state) {
|
|
}
|
|
}
|
|
|
|
|
|
void halInt0(void) {
|
|
void halInt0(void) {
|
|
- halRelaisOn(RELAIS_POWER);
|
|
|
|
|
|
+ //halRelaisOn(RELAIS_POWER);
|
|
logger(V_BASIC, "Int0 triggered\n");
|
|
logger(V_BASIC, "Int0 triggered\n");
|
|
|
|
+ flowcnt = 0;
|
|
|
|
+ halRelaisOn(RELAIS_PUMP);
|
|
}
|
|
}
|
|
|
|
|
|
void halInt1(void) {
|
|
void halInt1(void) {
|
|
- halRelaisOff(RELAIS_POWER);
|
|
|
|
|
|
+ //halRelaisOff(RELAIS_POWER);
|
|
logger(V_BASIC, "Int1 triggered\n");
|
|
logger(V_BASIC, "Int1 triggered\n");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void halIntFlow(void) {
|
|
|
|
+ //halRelaisOff(RELAIS_POWER);
|
|
|
|
+ logger(V_BASIC, "IntFlow triggered #%d total: %f\n", flowcnt, halGetFlow());
|
|
|
|
+ lcdPosition(lcd, 0, 0);
|
|
|
|
+ lcdPrintf(lcd, "ml = %.2f ", halGetFlow());
|
|
|
|
+ if (flowcnt == 99) {
|
|
|
|
+ halRelaisOff(RELAIS_PUMP);
|
|
|
|
+ }
|
|
|
|
+ flowcnt++;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+float halGetFlow(void) {
|
|
|
|
+ return flowcnt*FLOW_ML_PULSE;
|
|
|
|
+}
|
|
|
|
+
|