-
Notifications
You must be signed in to change notification settings - Fork 1
/
falcon.ino
99 lines (82 loc) · 1.74 KB
/
falcon.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
#include "falconcommon.h"
#include <Arduino.h>
#include <EEPROM.h>
#ifdef RC_TRANSMITTER
#include <SPI.h>
#include <Wire.h>
#include "UI.h"
#include "U8glib.h"
U8GLIB_SSD1306_128X64 g_OLED(U8G_I2C_OPT_NO_ACK);
UI g_UI;
#endif
// COMMON INCLUDES
#include "EEPROMAnything.h"
//#include "DEVICE_COMMON.h"
//#include "DEVICE_SERIAL_TRANSMITTER.h"
//#include "DEVICE_SERIAL_RECEIVER.h"
//#include "DEVICE_RC_TRANSMITTER.h"
//#include "DEVICE_LIDAR_CONTROLLER.h"
#ifdef UART_RC_BRIDGE
#include "DEVICE_UART_RC_BRIDGE.h"
DEVICE_UART_RC_BRIDGE g_Device;
#endif
#ifdef LIDAR_LOCKER_2560
#include "DEVICE_LIDAR_LOCKER_2560.h"
DEVICE_LIDAR_LOCKER_2560 g_Device;
//
//IMU
//
//indicates whether MPU interrupt pin has gone high
volatile bool mpuInterrupt = false;
void dmpDataReady()
{
//mpuInterrupt=true;
g_Device.m_bMpuInterrupt = true;
}
//
//PPM Input
//
void ppmInt()
{
g_Device.m_PPMInput.ppmInt();
}
#endif
//
//INITIAL SETUP
//
void setup()
{
//Setting up Serial
g_Device.m_pUSBSerial = &Serial;
#ifndef ATMEGA_A328
g_Device.m_pRFSerial = &Serial1;
#endif
#ifdef LIDAR_LOCKER_2560
// Read Config or fill with default settings
if (EEPROM.read(0) == VERSION)
{
EEPROM_readAnything(0, g_Device.m_config);
}
else
{
g_Device.setDefaultParameters();
EEPROM_writeAnything(0, g_Device.m_config);
}
// enable Arduino interrupt detection
attachInterrupt(6, dmpDataReady, RISING);
//Init PPM output
PPM_init(g_Device.m_config.PPMframeLength, g_Device.m_config.PPMPulseLength);
attachInterrupt(PPM_INPUT_INT, ppmInt, RISING);
//2,3 for I2C, 4 or 5 for GPS port, this is the Arduino INT, not the Atmega2560 INT!
g_Device.m_PPMInput.m_pPPMOut = g_ppm;
#endif
g_Device.deviceSetup();
}
//
//MAIN PROGRAM LOOP
//
void loop()
{
g_Device.deviceLoop();
}