-
Notifications
You must be signed in to change notification settings - Fork 0
/
selftest.cpp
63 lines (53 loc) · 1.52 KB
/
selftest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <OneWire.h>
#include <LiquidCrystal.h>
#include <PrintEx.h>
#include "constants.h"
extern LiquidCrystal lcd;
extern PrintEx exSerial;
extern OneWire ow;
extern DallasTemperature sensors;
uint8_t findDevices(OneWire ow) {
uint8_t address[8];
uint8_t count = 0;
Serial.println("OneWire devices found:");
if (ow.search(address)) {
do {
count++;
Serial.print("{ ");
for (uint8_t i = 0; i < 8; i++) {
Serial.print("0x");
if (address[i] < 0x10) Serial.print("0");
Serial.print(address[i], HEX);
if (i < 7) Serial.print(", ");
}
Serial.println(" }");
} while (ow.search(address));
}
return count;
}
void testOutput(int pin, const char* name) {
exSerial.printf("Testing %s: on for 1 second\n", name);
digitalWrite(pin, LOW);
delay(1000);
exSerial.printf("Testing %s: off for 1 second\n", name);
digitalWrite(pin, HIGH);
delay(1000);
}
void selfTest() {
// test 0: serial port
exSerial.printf("========================\n");
exSerial.printf("RHEEM Controller rev %d\n", REVISION);
exSerial.printf("========================\n");
// test 1: LCD
lcd.print("RHEEM Controller");
lcd.setCursor(5,1);
lcd.print("rev:");
lcd.print(REVISION);
// test 2: temperature sensors
int count = findDevices(ow);
exSerial.printf("%d of %d devices found: %s\n", count, 4, count == 4 ? "OK" : "FAIL");
// test 3: relays
testOutput(pumpPin, "LED");
testOutput(compressorPin, "compressor relay");
testOutput(selectorPin, "selector relay");
}