Browse Source

Can configure debug output target

Thomas Buck 3 years ago
parent
commit
3f7d3f4e09
8 changed files with 137 additions and 119 deletions
  1. 27
    6
      Saitek-X52-PPM.ino
  2. 3
    3
      cppm.cpp
  3. 3
    1
      events.h
  4. 29
    28
      events_buttons.cpp
  5. 38
    44
      events_deadzone.cpp
  6. 1
    1
      frsky.cpp
  7. 7
    7
      parser.cpp
  8. 29
    29
      x52.cpp

+ 27
- 6
Saitek-X52-PPM.ino View File

@@ -21,7 +21,7 @@
21 21
 #include "frsky.h"
22 22
 
23 23
 #define ENABLE_SERIAL_PORT
24
-#define DEBUG_OUTPUT
24
+//#define DEBUG_OUTPUT Serial
25 25
 //#define DEBUG_MFD_UPTIME
26 26
 
27 27
 USB usb;
@@ -40,17 +40,24 @@ void setup() {
40 40
 #endif
41 41
 
42 42
 #ifdef DEBUG_OUTPUT
43
-    Serial.println("Start");
43
+    DEBUG_OUTPUT.println("Start");
44 44
 #endif
45 45
 
46
+    pinMode(13, OUTPUT);
47
+    digitalWrite(13, LOW);
48
+
46 49
     if (usb.Init() == -1) {
50
+        digitalWrite(13, HIGH);
47 51
 #ifdef DEBUG_OUTPUT
48
-        Serial.println("OSC did not start.");
52
+        DEBUG_OUTPUT.println("OSC did not start.");
49 53
 #endif
50 54
     }
51 55
 
52 56
     if (!hid.SetReportParser(0, &joy)) {
53
-        ErrorMessage<uint8_t >(PSTR("SetReportParser"), 1);
57
+        digitalWrite(13, HIGH);
58
+#ifdef DEBUG_OUTPUT
59
+        DEBUG_OUTPUT.println("Error adding report parser.");
60
+#endif
54 61
     }
55 62
 
56 63
     CPPM::instance().init();
@@ -61,6 +68,18 @@ void init_joystick() {
61 68
     x52.setMFDText(0, "Arduino X52 Host");
62 69
     x52.setMFDText(1, "should be ready!");
63 70
     x52.setMFDText(2, " OK for options ");
71
+
72
+    // Sometimes the first message is lost, so send again
73
+    if (joyButtons.getCurrentMode() == 1) {
74
+        x52.setLEDBrightness(2);
75
+        x52.setMFDBrightness(2);
76
+    } else if (joyButtons.getCurrentMode() == 2) {
77
+        x52.setLEDBrightness(1);
78
+        x52.setMFDBrightness(1);
79
+    } else if (joyButtons.getCurrentMode() == 3) {
80
+        x52.setLEDBrightness(0);
81
+        x52.setMFDBrightness(0);
82
+    }
64 83
 }
65 84
 
66 85
 void loop() {
@@ -71,9 +90,11 @@ void loop() {
71 90
     static uint8_t initialized = 0;
72 91
     if ((millis() - lastTime) >= 1000) {
73 92
         lastTime = millis();
74
-        if (!initialized) {
75
-            init_joystick();
93
+        if (initialized == 0) {
76 94
             initialized = 1;
95
+        } else if (initialized == 1) {
96
+            init_joystick();
97
+            initialized = 2;
77 98
         }
78 99
 
79 100
 #ifdef DEBUG_MFD_UPTIME

+ 3
- 3
cppm.cpp View File

@@ -14,13 +14,13 @@
14 14
 #include <Arduino.h>
15 15
 #include "cppm.h"
16 16
 
17
-//#define DEBUG_OUTPUT
17
+//#define DEBUG_OUTPUT Serial
18 18
 
19 19
 CPPM* CPPM::inst = NULL;
20 20
 
21 21
 void CPPM::init(void) {
22 22
 #ifdef DEBUG_OUTPUT
23
-    Serial.println("Initializing Timer...");
23
+    DEBUG_OUTPUT.println("Initializing Timer...");
24 24
 #endif
25 25
 
26 26
     state = 1;
@@ -45,7 +45,7 @@ void CPPM::init(void) {
45 45
 
46 46
 void CPPM::copy(uint16_t* d) {
47 47
 #ifdef DEBUG_OUTPUT
48
-    Serial.println("New CPPM data!");
48
+    DEBUG_OUTPUT.println("New CPPM data!");
49 49
 #endif
50 50
 
51 51
     cli();

+ 3
- 1
events.h View File

@@ -110,6 +110,8 @@ class JoystickEventsButtons : public JoystickEvents {
110 110
     JoystickEventsButtons(X52* x = 0, JoystickEvents* client = 0);
111 111
     virtual void OnButtonDown(uint8_t but_id);
112 112
 
113
+    uint8_t getCurrentMode() { return currentMode; }
114
+
113 115
   private:
114 116
     enum MenuState {
115 117
         NONE = 0,
@@ -164,7 +166,7 @@ class JoystickEventsButtons : public JoystickEvents {
164 166
     uint8_t index;
165 167
     uint16_t value;
166 168
     int16_t signedValue;
167
-    unsigned long menuTime;
169
+    uint8_t currentMode;
168 170
 };
169 171
 
170 172
 extern JoystickEventsCPPM joyCPPM;

+ 29
- 28
events_buttons.cpp View File

@@ -16,7 +16,7 @@
16 16
 #include "cppm.h"
17 17
 #include "events.h"
18 18
 
19
-//#define DEBUG_OUTPUT
19
+//#define DEBUG_OUTPUT Serial
20 20
 //#define DEBUG_BUTTON_MFD
21 21
 
22 22
 #define MENU_BUTTON_ENTER_1 29
@@ -30,7 +30,7 @@
30 30
 
31 31
 JoystickEventsButtons::JoystickEventsButtons(X52* x, JoystickEvents* client)
32 32
         : JoystickEvents(client), x52(x), state(NONE), index(0),
33
-        value(0), signedValue(0), menuTime(0) { }
33
+        value(0), signedValue(0), currentMode(0) { }
34 34
 
35 35
 void JoystickEventsButtons::printMenu() {
36 36
     static const char* mainMenu[] = {
@@ -91,8 +91,6 @@ void JoystickEventsButtons::printMenu() {
91 91
         uint8_t index = state - EDIT_TRIM_ROLL;
92 92
         printSignedValue(-100, 100, (String("Trim ") + axisMenu[index]).c_str());
93 93
     }
94
-
95
-    menuTime = millis();
96 94
 }
97 95
 
98 96
 void JoystickEventsButtons::OnButtonDown(uint8_t but_id) {
@@ -104,12 +102,15 @@ void JoystickEventsButtons::OnButtonDown(uint8_t but_id) {
104 102
     if (but_id == MODE_BUTTON_GREEN) {
105 103
         x52->setLEDBrightness(2);
106 104
         x52->setMFDBrightness(2);
105
+        currentMode = 1;
107 106
     } else if (but_id == MODE_BUTTON_YELLOW) {
108 107
         x52->setLEDBrightness(1);
109 108
         x52->setMFDBrightness(1);
109
+        currentMode = 2;
110 110
     } else if (but_id == MODE_BUTTON_RED) {
111 111
         x52->setLEDBrightness(0);
112 112
         x52->setMFDBrightness(0);
113
+        currentMode = 3;
113 114
     } else if ((but_id == MENU_BUTTON_ENTER_1) || (but_id == MENU_BUTTON_ENTER_2)) {
114 115
         if (state == NONE) {
115 116
             state = MAINMENU;
@@ -387,27 +388,27 @@ void JoystickEventsButtons::menuHelper(uint8_t count, const char** menu, const c
387 388
     }
388 389
 
389 390
 #ifdef DEBUG_OUTPUT
390
-    Serial.print("menuHelper() state=");
391
-    Serial.print(state);
392
-    Serial.print(" index=");
393
-    Serial.print(index);
394
-    Serial.print(" start=");
395
-    Serial.print(start);
396
-    Serial.print(" end=");
397
-    Serial.println(end);
391
+    DEBUG_OUTPUT.print("menuHelper() state=");
392
+    DEBUG_OUTPUT.print(state);
393
+    DEBUG_OUTPUT.print(" index=");
394
+    DEBUG_OUTPUT.print(index);
395
+    DEBUG_OUTPUT.print(" start=");
396
+    DEBUG_OUTPUT.print(start);
397
+    DEBUG_OUTPUT.print(" end=");
398
+    DEBUG_OUTPUT.println(end);
398 399
 #endif
399 400
 }
400 401
 
401 402
 void JoystickEventsButtons::printValue(uint16_t min, uint16_t max, const char* title) {
402 403
 #ifdef DEBUG_OUTPUT
403
-    Serial.print("printValue() state=");
404
-    Serial.print(state);
405
-    Serial.print(" index=");
406
-    Serial.print(index);
407
-    Serial.print(" min=");
408
-    Serial.print(min);
409
-    Serial.print(" max=");
410
-    Serial.println(max);
404
+    DEBUG_OUTPUT.print("printValue() state=");
405
+    DEBUG_OUTPUT.print(state);
406
+    DEBUG_OUTPUT.print(" index=");
407
+    DEBUG_OUTPUT.print(index);
408
+    DEBUG_OUTPUT.print(" min=");
409
+    DEBUG_OUTPUT.print(min);
410
+    DEBUG_OUTPUT.print(" max=");
411
+    DEBUG_OUTPUT.println(max);
411 412
 #endif
412 413
 
413 414
     if (value < min) {
@@ -424,14 +425,14 @@ void JoystickEventsButtons::printValue(uint16_t min, uint16_t max, const char* t
424 425
 
425 426
 void JoystickEventsButtons::printSignedValue(int16_t min, int16_t max, const char* title) {
426 427
 #ifdef DEBUG_OUTPUT
427
-    Serial.print("printSignedValue() state=");
428
-    Serial.print(state);
429
-    Serial.print(" index=");
430
-    Serial.print(index);
431
-    Serial.print(" min=");
432
-    Serial.print(min);
433
-    Serial.print(" max=");
434
-    Serial.println(max);
428
+    DEBUG_OUTPUT.print("printSignedValue() state=");
429
+    DEBUG_OUTPUT.print(state);
430
+    DEBUG_OUTPUT.print(" index=");
431
+    DEBUG_OUTPUT.print(index);
432
+    DEBUG_OUTPUT.print(" min=");
433
+    DEBUG_OUTPUT.print(min);
434
+    DEBUG_OUTPUT.print(" max=");
435
+    DEBUG_OUTPUT.println(max);
435 436
 #endif
436 437
 
437 438
     if (signedValue < min) {

+ 38
- 44
events_deadzone.cpp View File

@@ -10,13 +10,11 @@
10 10
  * published by the Free Software Foundation, version 2.
11 11
  */
12 12
 
13
-#include <usb.h>
14
-
15 13
 #include "data.h"
16 14
 #include "events.h"
17 15
 
18
-//#define DEBUG_OUTPUT_RAW
19
-//#define DEBUG_OUTPUT
16
+//#define DEBUG_OUTPUT_RAW Serial
17
+//#define DEBUG_OUTPUT Serial
20 18
 
21 19
 /*
22 20
  * Deadzone around the axis center, in both directions.
@@ -43,21 +41,20 @@ const uint8_t JoystickEventsDeadZone::centerMouseY = 0x07;
43 41
 
44 42
 void JoystickEventsDeadZone::OnGamePadChanged(const GamePadEventData& evt) {
45 43
 #ifdef DEBUG_OUTPUT_RAW
46
-    Serial.print("Raw X: ");
47
-    PrintHex<uint16_t > (evt.X, 0x80);
48
-    Serial.print(" Y: ");
49
-    PrintHex<uint16_t > (evt.Y, 0x80);
50
-    Serial.print(" Z: ");
51
-    PrintHex<uint8_t > (evt.Z, 0x80);
52
-    Serial.print(" Rx: ");
53
-    PrintHex<uint8_t > (evt.Rx, 0x80);
54
-    Serial.print(" Ry: ");
55
-    PrintHex<uint8_t > (evt.Ry, 0x80);
56
-    Serial.print(" Rz: ");
57
-    PrintHex<uint16_t > (evt.Rz, 0x80);
58
-    Serial.print(" S: ");
59
-    PrintHex<uint8_t > (evt.Slider, 0x80);
60
-    Serial.println("");
44
+    DEBUG_OUTPUT_RAW.print("Raw X: ");
45
+    DEBUG_OUTPUT_RAW.print(evt.X, HEX);
46
+    DEBUG_OUTPUT_RAW.print(" Y: ");
47
+    DEBUG_OUTPUT_RAW.print(evt.Y, HEX);
48
+    DEBUG_OUTPUT_RAW.print(" Z: ");
49
+    DEBUG_OUTPUT_RAW.print(evt.Z, HEX);
50
+    DEBUG_OUTPUT_RAW.print(" Rx: ");
51
+    DEBUG_OUTPUT_RAW.print(evt.Rx, HEX);
52
+    DEBUG_OUTPUT_RAW.print(" Ry: ");
53
+    DEBUG_OUTPUT_RAW.print(evt.Ry, HEX);
54
+    DEBUG_OUTPUT_RAW.print(" Rz: ");
55
+    DEBUG_OUTPUT_RAW.print(evt.Rz, HEX);
56
+    DEBUG_OUTPUT_RAW.print(" S: ");
57
+    DEBUG_OUTPUT_RAW.println(evt.Slider, HEX);
61 58
 #endif
62 59
 
63 60
     GamePadEventData newData = centerValue;
@@ -131,21 +128,20 @@ void JoystickEventsDeadZone::OnGamePadChanged(const GamePadEventData& evt) {
131 128
 
132 129
 #ifdef DEBUG_OUTPUT
133 130
     if (updated) {
134
-        Serial.print("X: ");
135
-        PrintHex<uint16_t > (newData.X, 0x80);
136
-        Serial.print(" Y: ");
137
-        PrintHex<uint16_t > (newData.Y, 0x80);
138
-        Serial.print(" Z: ");
139
-        PrintHex<uint8_t > (newData.Z, 0x80);
140
-        Serial.print(" Rx: ");
141
-        PrintHex<uint8_t > (newData.Rx, 0x80);
142
-        Serial.print(" Ry: ");
143
-        PrintHex<uint8_t > (newData.Ry, 0x80);
144
-        Serial.print(" Rz: ");
145
-        PrintHex<uint16_t > (newData.Rz, 0x80);
146
-        Serial.print(" S: ");
147
-        PrintHex<uint8_t > (newData.Slider, 0x80);
148
-        Serial.println("");
131
+        DEBUG_OUTPUT.print("X: ");
132
+        DEBUG_OUTPUT.print(newData.X, HEX);
133
+        DEBUG_OUTPUT.print(" Y: ");
134
+        DEBUG_OUTPUT.print(newData.Y, HEX);
135
+        DEBUG_OUTPUT.print(" Z: ");
136
+        DEBUG_OUTPUT.print(newData.Z, HEX);
137
+        DEBUG_OUTPUT.print(" Rx: ");
138
+        DEBUG_OUTPUT.print(newData.Rx, HEX);
139
+        DEBUG_OUTPUT.print(" Ry: ");
140
+        DEBUG_OUTPUT.print(newData.Ry, HEX);
141
+        DEBUG_OUTPUT.print(" Rz: ");
142
+        DEBUG_OUTPUT.print(newData.Rz, HEX);
143
+        DEBUG_OUTPUT.print(" S: ");
144
+        DEBUG_OUTPUT.println(newData.Slider, HEX);
149 145
     }
150 146
 #endif
151 147
 
@@ -156,11 +152,10 @@ void JoystickEventsDeadZone::OnGamePadChanged(const GamePadEventData& evt) {
156 152
 
157 153
 void JoystickEventsDeadZone::OnMouseMoved(uint8_t x, uint8_t y) {
158 154
 #ifdef DEBUG_OUTPUT_RAW
159
-    Serial.print("Raw Mouse X: ");
160
-    PrintHex<uint8_t >(x, 0x80);
161
-    Serial.print("\tY: ");
162
-    PrintHex<uint8_t >(y, 0x80);
163
-    Serial.println("");
155
+    DEBUG_OUTPUT_RAW.print("Raw Mouse X: ");
156
+    DEBUG_OUTPUT_RAW.print(x, HEX);
157
+    DEBUG_OUTPUT_RAW.print("\tY: ");
158
+    DEBUG_OUTPUT_RAW.println(y, HEX);
164 159
 #endif
165 160
 
166 161
     uint8_t newX = centerMouseX;
@@ -190,11 +185,10 @@ void JoystickEventsDeadZone::OnMouseMoved(uint8_t x, uint8_t y) {
190 185
 
191 186
 #ifdef DEBUG_OUTPUT
192 187
     if (updated) {
193
-        Serial.print("Mouse X: ");
194
-        PrintHex<uint8_t >(newX, 0x80);
195
-        Serial.print("\tY: ");
196
-        PrintHex<uint8_t >(newY, 0x80);
197
-        Serial.println("");
188
+        DEBUG_OUTPUT.print("Mouse X: ");
189
+        DEBUG_OUTPUT.print(newX, HEX);
190
+        DEBUG_OUTPUT.print("\tY: ");
191
+        DEBUG_OUTPUT.println(newY, HEX);
198 192
     }
199 193
 #endif
200 194
 

+ 1
- 1
frsky.cpp View File

@@ -12,7 +12,7 @@
12 12
 
13 13
 #include "frsky.h"
14 14
 
15
-#define DEBUG_OUTPUT Serial
15
+//#define DEBUG_OUTPUT Serial
16 16
 
17 17
 FrSky::FrSky(Stream* s) : serial(s), dataHandler(0),
18 18
         alarmThresholdHandler(0), userDataHandler(0), bufferIndex(0) {

+ 7
- 7
parser.cpp View File

@@ -13,7 +13,7 @@
13 13
 #include "events.h"
14 14
 #include "parser.h"
15 15
 
16
-//#define DEBUG_OUTPUT
16
+//#define DEBUG_OUTPUT Serial
17 17
 
18 18
 JoystickReportParser::JoystickReportParser(JoystickEvents* evt)
19 19
         : joyEvents(evt), oldHat(0), oldButtons(0), oldMouse(0), buffer(0) {
@@ -39,14 +39,14 @@ void JoystickReportParser::Parse(HID* hid, bool is_rpt_id, uint8_t len, uint8_t*
39 39
 
40 40
 #ifdef DEBUG_OUTPUT
41 41
     // Dump whole USB HID packet for debugging purposes
42
-    Serial.println("");
43
-    Serial.print("Packet: ");
42
+    DEBUG_OUTPUT.println("");
43
+    DEBUG_OUTPUT.print("Packet: ");
44 44
     for (uint8_t i = 0; i < (8 + len); i++) {
45
-        PrintHex<uint8_t >(buf[i], 0x80);
46
-        Serial.print(" ");
45
+        DEBUG_OUTPUT.print(buf[i], HEX);
46
+        DEBUG_OUTPUT.print(" ");
47 47
     }
48
-    Serial.println("");
49
-    Serial.println("");
48
+    DEBUG_OUTPUT.println("");
49
+    DEBUG_OUTPUT.println("");
50 50
 #endif
51 51
 
52 52
     // Checking if there are changes in report since the method was last called

+ 29
- 29
x52.cpp View File

@@ -12,7 +12,7 @@
12 12
 
13 13
 #include "x52.h"
14 14
 
15
-//#define DEBUG_OUTPUT
15
+//#define DEBUG_OUTPUT Serial
16 16
 
17 17
 #define TIME_24H_FORMAT
18 18
 
@@ -31,8 +31,8 @@ void X52::initialize() {
31 31
     uint8_t ret = usb->getDevDescr(hid->GetAddress(), 0, sizeof(USB_DEVICE_DESCRIPTOR), (uint8_t*)buf);
32 32
     if (ret) {
33 33
 #ifdef DEBUG_OUTPUT
34
-        Serial.print("Error getting descriptor: ");
35
-        Serial.println(ret, DEC);
34
+        DEBUG_OUTPUT.print("Error getting descriptor: ");
35
+        DEBUG_OUTPUT.println(ret, DEC);
36 36
 #endif
37 37
     }
38 38
 
@@ -40,10 +40,10 @@ void X52::initialize() {
40 40
     uint16_t pid = udd->idProduct;
41 41
 
42 42
 #ifdef DEBUG_OUTPUT
43
-        Serial.print("VID: ");
44
-        Serial.print(vid, DEC);
45
-        Serial.print(" PID: ");
46
-        Serial.println(pid, DEC);
43
+        DEBUG_OUTPUT.print("VID: ");
44
+        DEBUG_OUTPUT.print(vid, DEC);
45
+        DEBUG_OUTPUT.print(" PID: ");
46
+        DEBUG_OUTPUT.println(pid, DEC);
47 47
 #endif
48 48
 
49 49
     if ((vid == 0x06A3) && (pid == 0x0255)) {
@@ -54,7 +54,7 @@ void X52::initialize() {
54 54
         ready = 1;
55 55
     } else {
56 56
 #ifdef DEBUG_OUTPUT
57
-        Serial.println("No valid VID/PID found!");
57
+        DEBUG_OUTPUT.println("No valid VID/PID found!");
58 58
 #endif
59 59
     }
60 60
 }
@@ -67,8 +67,8 @@ void X52::setTime(uint8_t h, uint8_t m) {
67 67
             );
68 68
     if (ret) {
69 69
 #ifdef DEBUG_OUTPUT
70
-        Serial.print("Error setting time: ");
71
-        Serial.println(ret, DEC);
70
+        DEBUG_OUTPUT.print("Error setting time: ");
71
+        DEBUG_OUTPUT.println(ret, DEC);
72 72
 #endif
73 73
     }
74 74
 }
@@ -96,8 +96,8 @@ void X52::setTimeOffset(uint8_t cl, int16_t offset) {
96 96
             );
97 97
     if (ret) {
98 98
 #ifdef DEBUG_OUTPUT
99
-        Serial.print("Error setting offset: ");
100
-        Serial.println(ret, DEC);
99
+        DEBUG_OUTPUT.print("Error setting offset: ");
100
+        DEBUG_OUTPUT.println(ret, DEC);
101 101
 #endif
102 102
     }
103 103
 }
@@ -109,8 +109,8 @@ void X52::setDate(uint8_t dd, uint8_t mm, uint8_t yy) {
109 109
     }
110 110
     if (ret) {
111 111
 #ifdef DEBUG_OUTPUT
112
-        Serial.print("Error setting date: ");
113
-        Serial.println(ret, DEC);
112
+        DEBUG_OUTPUT.print("Error setting date: ");
113
+        DEBUG_OUTPUT.println(ret, DEC);
114 114
 #endif
115 115
     }
116 116
 }
@@ -119,8 +119,8 @@ void X52::setBlink(uint8_t state) {
119 119
     uint8_t ret = sendCommand(X52_BLINK_INDICATOR, state ? X52_BLINK_ON : X52_BLINK_OFF);
120 120
     if (ret != 0) {
121 121
 #ifdef DEBUG_OUTPUT
122
-        Serial.print("Error setting blink: ");
123
-        Serial.println(ret, DEC);
122
+        DEBUG_OUTPUT.print("Error setting blink: ");
123
+        DEBUG_OUTPUT.println(ret, DEC);
124 124
 #endif
125 125
     }
126 126
 }
@@ -129,8 +129,8 @@ void X52::setShift(uint8_t state) {
129 129
     uint8_t ret = sendCommand(X52_SHIFT_INDICATOR, state ? X52_SHIFT_ON : X52_SHIFT_OFF);
130 130
     if (ret != 0) {
131 131
 #ifdef DEBUG_OUTPUT
132
-        Serial.print("Error setting shift: ");
133
-        Serial.println(ret, DEC);
132
+        DEBUG_OUTPUT.print("Error setting shift: ");
133
+        DEBUG_OUTPUT.println(ret, DEC);
134 134
 #endif
135 135
     }
136 136
 }
@@ -144,8 +144,8 @@ void X52::setMFDText(uint8_t line, const char* text) {
144 144
 
145 145
     if (line >= 3) {
146 146
 #ifdef DEBUG_OUTPUT
147
-        Serial.print("Invalid line: ");
148
-        Serial.println(line, DEC);
147
+        DEBUG_OUTPUT.print("Invalid line: ");
148
+        DEBUG_OUTPUT.println(line, DEC);
149 149
 #endif
150 150
         return;
151 151
     }
@@ -153,8 +153,8 @@ void X52::setMFDText(uint8_t line, const char* text) {
153 153
     uint8_t ret = sendCommand(X52_MFD_CLEAR_LINE | lines[line], 0);
154 154
     if (ret) {
155 155
 #ifdef DEBUG_OUTPUT
156
-        Serial.print("Error clearing line: ");
157
-        Serial.println(ret, DEC);
156
+        DEBUG_OUTPUT.print("Error clearing line: ");
157
+        DEBUG_OUTPUT.println(ret, DEC);
158 158
 #endif
159 159
         return;
160 160
     }
@@ -173,8 +173,8 @@ void X52::setMFDText(uint8_t line, const char* text) {
173 173
         ret = sendCommand(X52_MFD_WRITE_LINE | lines[line], value);
174 174
         if (ret) {
175 175
 #ifdef DEBUG_OUTPUT
176
-            Serial.print("Error writing to line: ");
177
-            Serial.println(ret, DEC);
176
+            DEBUG_OUTPUT.print("Error writing to line: ");
177
+            DEBUG_OUTPUT.println(ret, DEC);
178 178
 #endif
179 179
             return;
180 180
         }
@@ -188,14 +188,14 @@ void X52::setMFDText(uint8_t line, const char* text) {
188 188
 uint8_t X52::sendCommand(uint16_t command, uint16_t val) {
189 189
     if (!ready) {
190 190
 #ifdef DEBUG_OUTPUT
191
-        Serial.println("Invalid state!");
191
+        DEBUG_OUTPUT.println("Invalid state!");
192 192
 #endif
193 193
         return 23;
194 194
     }
195 195
     
196 196
     if ((!usb) || (!hid)) {
197 197
 #ifdef DEBUG_OUTPUT
198
-        Serial.println("Invalid objects!");
198
+        DEBUG_OUTPUT.println("Invalid objects!");
199 199
 #endif
200 200
         return 42;
201 201
     }
@@ -204,7 +204,7 @@ uint8_t X52::sendCommand(uint16_t command, uint16_t val) {
204 204
     const uint8_t valHi = (val & 0xFF00) >> 8;
205 205
 
206 206
 #ifdef DEBUG_OUTPUT
207
-    Serial.println("Sending X52 Ctrl-Req...");
207
+    DEBUG_OUTPUT.println("Sending X52 Ctrl-Req...");
208 208
 #endif
209 209
 
210 210
     uint8_t ret = usb->ctrlReq(hid->GetAddress(), 0,
@@ -213,8 +213,8 @@ uint8_t X52::sendCommand(uint16_t command, uint16_t val) {
213 213
                               0, 0, NULL, NULL);
214 214
     if (ret != 0) {
215 215
 #ifdef DEBUG_OUTPUT
216
-        Serial.print("Ctrl-Req Error Code: ");
217
-        Serial.println(val, DEC);
216
+        DEBUG_OUTPUT.print("Ctrl-Req Error Code: ");
217
+        DEBUG_OUTPUT.println(val, DEC);
218 218
 #endif
219 219
     }
220 220
 

Loading…
Cancel
Save