-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
123 lines (83 loc) · 2.39 KB
/
main.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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "WProgram.h" //Include arduino headers
//#include "EEPROM/EEPROM.h"
#ifdef ETHERNET_INSTALLED
#include "Ethernet/Ethernet.h"
#include "Ethernet/EthernetUDP.h"
#include "Networking.h"
#endif
#include "SPI/SPI.h"
#include "RTC1307/RTClib.h"
#include "VirtualWire/VirtualWire.h"
#include "globals.h"
#include "types.h"
#include "Wire/Wire.h"
#include "Time.h"
#include "MessageProcessing.h"
#include "Logging.h"
#include "tasks.h"
#include "SerialLCD.h"
//#include "SD/SD.h"
#undef int
#undef abs
#undef double
#undef float
#undef round
//The onboard test LED is connected to pin number 13
const int ledPin = 13;
const int interval = 1000; //Milliseconds
const int SPI_SS_PIN = 53;
// Real Time Clock
RTC_DS1307 RTC;
//LiquidCrystal lcd(32, 31, 25, 24, 23, 22);
// how many messages we have that need processing
int msgCount = 0;
// array of the messages that need processing
char messages[MAX_MESSAGES][VW_MAX_MESSAGE_LEN];
///MAIN///
int main() {
//Initialize the Arduino library.
//Not doing so will prevent the delay function
//from working. Calling this functions is a must
//for all arduino projects.
init();
pinMode(SPI_SS_PIN, OUTPUT);
//Initialize the serial port. This will be used
//to send diagnostic information in this project.
Serial.begin(57600);
Serial.println("Starting...");
InitializeSerialLCD();
//Serial1.begin(115200);
Serial1.print("Starting...");
Wire.begin();
// Initialize the IO and ISR
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_rx_start();
// set up the LCD's number of rows and columns:
//lcd.begin(16, 2);
//
RTC.begin();
InitializeNetwork();
InitializeTime();
//Configure ledPin as an output
pinMode(ledPin, OUTPUT);
InitializeLogging();
InitializeTaskRunner();
//Announce the start of program. Usually a
//hyper-terminal is connected to the serial
//port on the PC so this message can be seen
//there
Serial.println("Ready.");
Serial1.print("Ready...");
Serial1.print("Awaiting First Message");
//Enter the infinite loop responsible for making
//the microcontroller do the same thing over and
//over again. (Almost every microcontroller has
//such a loop)
while (true) {
RunScheduledTasks();
}
//Unreachable code but it's required by
//the compiler
return 0;
}