forked from cgwood/ArdustationMega
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardware.h
130 lines (106 loc) · 4.48 KB
/
hardware.h
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
124
125
126
127
128
// ASM hardware definitions
// Created 2012 By Colin G http://www.diydrones.com/profile/ColinG
// GPS type codes - use the names, not the numbers
#define GPS_PROTOCOL_NONE -1
#define GPS_PROTOCOL_NMEA 0
#define GPS_PROTOCOL_SIRF 1
#define GPS_PROTOCOL_UBLOX 2
#define GPS_PROTOCOL_IMU 3
#define GPS_PROTOCOL_MTK 4
#define GPS_PROTOCOL_HIL 5
#define GPS_PROTOCOL_MTK19 6
#define GPS_PROTOCOL_AUTO 7
#define GPS_PROTOCOL GPS_PROTOCOL_MTK19
// Button definitions
#define expander B0100000 // Address with three address pins grounded.
/// Buzzer pin
#define TONE_PIN A1
// ------------------------------------- LCD Definitions ------------------------------------- //
// ------------------------------------------------------------------------------------------- //
#define LCD_COLUMNS 20 ///< standard display for ArduStation
#define LCD_ROWS 8 ///< standard display for ArduStation
gText lcd = gText(0, 0, LCD_COLUMNS, LCD_ROWS, SystemFont5x7);
#define LCD_CHAR_LINK 0
#define LCD_CHAR_ROLL_LEFT 1
#define LCD_CHAR_ROLL_RIGHT 2
#define LCD_CHAR_UP_ARROW 3
#define LCD_CHAR_DOWN_ARROW 4
#define LCD_CHAR_MINUS_ONE 5
#define LCD_CHAR_BATTERY 6
#define LCD_CHAR_MODIFY 7
static uint8_t lcdCharRollLeft[] PROGMEM = {5, 8, 0x5C, 0x62, 0x72, 0x02, 0x0C};
static uint8_t lcdCharRollRight[] PROGMEM = {5, 8, 0x0C, 0x02, 0x72, 0x62, 0x5C};
static uint8_t lcdCharUpArrow[] PROGMEM = {5, 8, 0x04, 0x02, 0x3F, 0x02, 0x04};
static uint8_t lcdCharDownArrow[] PROGMEM = {5, 8, 0x10, 0x20, 0x7E, 0x20, 0x10};
static uint8_t lcdCharMinusOne[] PROGMEM = {5, 8, 0x02, 0x02, 0x09, 0x0F, 0x08};
static uint8_t lcdCharBattery[] PROGMEM = {5, 8, 0x7E, 0x53, 0x5B, 0x4B, 0x7E};
static uint8_t lcdCharModify[] PROGMEM = {5, 8, 0x00, 0x7F, 0x3E, 0x1C, 0x08};
static uint8_t lcdCharLinkWait[] PROGMEM = {5, 8, 0xFF, 0xFB, 0xAD, 0xF3, 0xFF};
static uint8_t lcdCharLinkOK[] PROGMEM = {5, 8, 0x24, 0x74, 0xBD, 0x2E, 0x24};
static uint8_t lcdCharLinkLost[] PROGMEM = {5, 8, 0xDF, 0xDF, 0x00, 0xDF, 0xDF};
// ------------------------------------- PID Definitions ------------------------------------- //
// ------------------------------------------------------------------------------------------- //
/// The PID Setup page for Roll Pitch and Yaw
// Header format 11111 22222 33333
PROGMEM const prog_char pidHeaderRPY[] = " Roll Pitch Yaw";
/// the PID / APM setup page confirmation message
PROGMEM const prog_char confirmMessage[] =
//01234567890123456789
"This will apply the\n"
"changes made to the\n"
" settings, press\n"
" OK to Upload";
// ----------------------------------- Tracker Definitions ----------------------------------- //
// ------------------------------------------------------------------------------------------- //
Servo Pan; ///< Pan servo
Servo Tilt; ///< Tilt servo
Tracker tracker; ///< Antenna tracker
// ----------------------------------- Encoder Definitions ----------------------------------- //
// ------------------------------------------------------------------------------------------- //
RotaryEncoder rotary(2, 3); ///< rotary encoder on digital 2 and 3, gnd on gnd // old : on A1/A2 gnd on A3
Buttons keypad;
Beep beep(TONE_PIN); ///< tune machine
void doEncoder() {
rotary.update();
}
// ------------------------------------- SD Definitions ------------------------------------- //
// ------------------------------------------------------------------------------------------ //
// set up variables using the SD utility library functions:
File root;
const int chipSelect = 53;
uint8_t
init_sdcard() {
lcd.CursorTo(0, 6);
pinMode(chipSelect, OUTPUT);
if (!SD.begin(chipSelect)) {
lcd.println("SD init fail!");
return 0;
}
lcd.println("SD init ok");
return 1;
}
void printDirectory(File dir, int numTabs) {
uint8_t ff=0;
while (ff<=8) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
// lcd.println("**nomorefiles**");
break;
}
for (uint8_t i=0; i<numTabs; i++) {
lcd.print('\t');
}
if (entry.isDirectory()) {
// lcd.println("/");
// printDirectory(entry, numTabs+1);
}
else {
lcd.println(entry.name());
ff++;
// files have sizes, directories do not
// lcd.print(" ");
// lcd.println(entry.size(), DEC);
}
}
}