-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAquaBusDevice.ino
executable file
·108 lines (96 loc) · 3 KB
/
AquaBusDevice.ino
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// AquaBusDevice
// Copyright (C) 2017
//
// This software is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0
// International License.
//
// You can redistribute and/or modify this software for non-commerical purposes under the terms
// of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
//
// This software is provided "as is" without express or implied warranty.
// Debug related definitions
#define DEBUG
#ifdef DEBUG
#define DEBUG_SERIAL_BEGIN() Serial2.begin(57600)
#define DEBUG_LOG(string) Serial2.print(string)
#define DEBUG_LOG_LN(string) Serial2.println(string)
#else
#define DEBUG_SERIAL_BEGIN()
#define DEBUG_LOG(string)
#define DEBUG_LOG_LN(string)
#endif
#define DEBUG_LOG_FREE_RAM() DEBUG_LOG(F("Free RAM: ")); DEBUG_LOG_LN(FreeRam())
#define MAX3059_AQUABUS_ADAPTER
// Include header files
#include <EEPROM.h>
#include <SoftwareSerial.h>
#include <AquaBusDev.h>
#include <AquaBusLib.h>
// #include <EB8.h>
// #include <PM2.h>
// #include <PM1.h>
// #include <PM3.h>
// #include <VDM.h>
// Declare global variables
SoftwareSerial Serial2(8, 9); // 8 is RX, 9 is TX
AquaBusLib gAquaBusLib(1);
// EB8 gEB8(0x1234);
// PM2 gPM2(0x1234);
// PM1 gPM1(0x1234);
// PM3 gPM3(0x1234);
// VDM gVDM(0x1234);
int incomingByte = 0; // For incoming serial data
// Setup code
void setup()
{
// Initialize the serial communication for debugging
DEBUG_SERIAL_BEGIN();
DEBUG_LOG_LN(F("Starting Aqua Bus Device sketch ..."));
#ifdef MAX3059_AQUABUS_ADAPTER
// On MAX3059 based boards, drive RS pin LOW and TERM pin High to match Apex cofiguration
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
pinMode(3, OUTPUT);
digitalWrite(3, HIGH);
#endif
// AB Address Init
eeprom_update_byte(0, 0);
// PM1 Init
// eeprom_update_byte(3, 0);
// eeprom_update_word(4, 0xFFF2);
// eeprom_update_word(6, 0xFFF9);
// eeprom_update_word(8, 0xFFF0);
// eeprom_update_word(10, 0x0238);
// eeprom_update_word(12, 0x1000);
// eeprom_update_word(14, 0x0B55);
// eeprom_update_word(16, 0x0E60);
// eeprom_update_word(18, 0x1086);
// PM2 Init
// eeprom_update_byte(3, (CONDUCTIVITY_PROBE_RANGE_SALINITY << 1));
// eeprom_update_word(4, 0xFFF2);
// eeprom_update_word(6, 0xFFF9);
// eeprom_update_word(8, 0xFFF0);
// eeprom_update_word(10, 0x0238);
// eeprom_update_word(12, 0x1000);
// eeprom_update_word(14, 0x0B55);
// eeprom_update_word(16, 0x0E60);
// eeprom_update_word(18, 0x1086);
// PM3 Init
// eeprom_update_byte(3, (DO_PROBE_RANGE_TYPE_SAT << 1));
// eeprom_update_word(4, 0xFFF2);
// eeprom_update_word(6, 0xFFF9);
// eeprom_update_word(8, 0xFFF0);
// eeprom_update_word(10, 0x0238);
// eeprom_update_word(12, 0x1000);
// eeprom_update_word(14, 0x0B55);
// eeprom_update_word(16, 0x0E60);
// eeprom_update_word(18, 0x1086);
// Initialize the AquaBus library
gAquaBusLib.setup();
}
// Main cod
void loop()
{
// Call the AquaBus library loop function
gAquaBusLib.loop();
}