Browse Source

Can configure debug output target

Thomas Buck 7 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
 #include "frsky.h"
21
 #include "frsky.h"
22
 
22
 
23
 #define ENABLE_SERIAL_PORT
23
 #define ENABLE_SERIAL_PORT
24
-#define DEBUG_OUTPUT
24
+//#define DEBUG_OUTPUT Serial
25
 //#define DEBUG_MFD_UPTIME
25
 //#define DEBUG_MFD_UPTIME
26
 
26
 
27
 USB usb;
27
 USB usb;
40
 #endif
40
 #endif
41
 
41
 
42
 #ifdef DEBUG_OUTPUT
42
 #ifdef DEBUG_OUTPUT
43
-    Serial.println("Start");
43
+    DEBUG_OUTPUT.println("Start");
44
 #endif
44
 #endif
45
 
45
 
46
+    pinMode(13, OUTPUT);
47
+    digitalWrite(13, LOW);
48
+
46
     if (usb.Init() == -1) {
49
     if (usb.Init() == -1) {
50
+        digitalWrite(13, HIGH);
47
 #ifdef DEBUG_OUTPUT
51
 #ifdef DEBUG_OUTPUT
48
-        Serial.println("OSC did not start.");
52
+        DEBUG_OUTPUT.println("OSC did not start.");
49
 #endif
53
 #endif
50
     }
54
     }
51
 
55
 
52
     if (!hid.SetReportParser(0, &joy)) {
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
     CPPM::instance().init();
63
     CPPM::instance().init();
61
     x52.setMFDText(0, "Arduino X52 Host");
68
     x52.setMFDText(0, "Arduino X52 Host");
62
     x52.setMFDText(1, "should be ready!");
69
     x52.setMFDText(1, "should be ready!");
63
     x52.setMFDText(2, " OK for options ");
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
 void loop() {
85
 void loop() {
71
     static uint8_t initialized = 0;
90
     static uint8_t initialized = 0;
72
     if ((millis() - lastTime) >= 1000) {
91
     if ((millis() - lastTime) >= 1000) {
73
         lastTime = millis();
92
         lastTime = millis();
74
-        if (!initialized) {
75
-            init_joystick();
93
+        if (initialized == 0) {
76
             initialized = 1;
94
             initialized = 1;
95
+        } else if (initialized == 1) {
96
+            init_joystick();
97
+            initialized = 2;
77
         }
98
         }
78
 
99
 
79
 #ifdef DEBUG_MFD_UPTIME
100
 #ifdef DEBUG_MFD_UPTIME

+ 3
- 3
cppm.cpp View File

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

+ 3
- 1
events.h View File

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

+ 29
- 28
events_buttons.cpp View File

16
 #include "cppm.h"
16
 #include "cppm.h"
17
 #include "events.h"
17
 #include "events.h"
18
 
18
 
19
-//#define DEBUG_OUTPUT
19
+//#define DEBUG_OUTPUT Serial
20
 //#define DEBUG_BUTTON_MFD
20
 //#define DEBUG_BUTTON_MFD
21
 
21
 
22
 #define MENU_BUTTON_ENTER_1 29
22
 #define MENU_BUTTON_ENTER_1 29
30
 
30
 
31
 JoystickEventsButtons::JoystickEventsButtons(X52* x, JoystickEvents* client)
31
 JoystickEventsButtons::JoystickEventsButtons(X52* x, JoystickEvents* client)
32
         : JoystickEvents(client), x52(x), state(NONE), index(0),
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
 void JoystickEventsButtons::printMenu() {
35
 void JoystickEventsButtons::printMenu() {
36
     static const char* mainMenu[] = {
36
     static const char* mainMenu[] = {
91
         uint8_t index = state - EDIT_TRIM_ROLL;
91
         uint8_t index = state - EDIT_TRIM_ROLL;
92
         printSignedValue(-100, 100, (String("Trim ") + axisMenu[index]).c_str());
92
         printSignedValue(-100, 100, (String("Trim ") + axisMenu[index]).c_str());
93
     }
93
     }
94
-
95
-    menuTime = millis();
96
 }
94
 }
97
 
95
 
98
 void JoystickEventsButtons::OnButtonDown(uint8_t but_id) {
96
 void JoystickEventsButtons::OnButtonDown(uint8_t but_id) {
104
     if (but_id == MODE_BUTTON_GREEN) {
102
     if (but_id == MODE_BUTTON_GREEN) {
105
         x52->setLEDBrightness(2);
103
         x52->setLEDBrightness(2);
106
         x52->setMFDBrightness(2);
104
         x52->setMFDBrightness(2);
105
+        currentMode = 1;
107
     } else if (but_id == MODE_BUTTON_YELLOW) {
106
     } else if (but_id == MODE_BUTTON_YELLOW) {
108
         x52->setLEDBrightness(1);
107
         x52->setLEDBrightness(1);
109
         x52->setMFDBrightness(1);
108
         x52->setMFDBrightness(1);
109
+        currentMode = 2;
110
     } else if (but_id == MODE_BUTTON_RED) {
110
     } else if (but_id == MODE_BUTTON_RED) {
111
         x52->setLEDBrightness(0);
111
         x52->setLEDBrightness(0);
112
         x52->setMFDBrightness(0);
112
         x52->setMFDBrightness(0);
113
+        currentMode = 3;
113
     } else if ((but_id == MENU_BUTTON_ENTER_1) || (but_id == MENU_BUTTON_ENTER_2)) {
114
     } else if ((but_id == MENU_BUTTON_ENTER_1) || (but_id == MENU_BUTTON_ENTER_2)) {
114
         if (state == NONE) {
115
         if (state == NONE) {
115
             state = MAINMENU;
116
             state = MAINMENU;
387
     }
388
     }
388
 
389
 
389
 #ifdef DEBUG_OUTPUT
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
 #endif
399
 #endif
399
 }
400
 }
400
 
401
 
401
 void JoystickEventsButtons::printValue(uint16_t min, uint16_t max, const char* title) {
402
 void JoystickEventsButtons::printValue(uint16_t min, uint16_t max, const char* title) {
402
 #ifdef DEBUG_OUTPUT
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
 #endif
412
 #endif
412
 
413
 
413
     if (value < min) {
414
     if (value < min) {
424
 
425
 
425
 void JoystickEventsButtons::printSignedValue(int16_t min, int16_t max, const char* title) {
426
 void JoystickEventsButtons::printSignedValue(int16_t min, int16_t max, const char* title) {
426
 #ifdef DEBUG_OUTPUT
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
 #endif
436
 #endif
436
 
437
 
437
     if (signedValue < min) {
438
     if (signedValue < min) {

+ 38
- 44
events_deadzone.cpp View File

10
  * published by the Free Software Foundation, version 2.
10
  * published by the Free Software Foundation, version 2.
11
  */
11
  */
12
 
12
 
13
-#include <usb.h>
14
-
15
 #include "data.h"
13
 #include "data.h"
16
 #include "events.h"
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
  * Deadzone around the axis center, in both directions.
20
  * Deadzone around the axis center, in both directions.
43
 
41
 
44
 void JoystickEventsDeadZone::OnGamePadChanged(const GamePadEventData& evt) {
42
 void JoystickEventsDeadZone::OnGamePadChanged(const GamePadEventData& evt) {
45
 #ifdef DEBUG_OUTPUT_RAW
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
 #endif
58
 #endif
62
 
59
 
63
     GamePadEventData newData = centerValue;
60
     GamePadEventData newData = centerValue;
131
 
128
 
132
 #ifdef DEBUG_OUTPUT
129
 #ifdef DEBUG_OUTPUT
133
     if (updated) {
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
 #endif
146
 #endif
151
 
147
 
156
 
152
 
157
 void JoystickEventsDeadZone::OnMouseMoved(uint8_t x, uint8_t y) {
153
 void JoystickEventsDeadZone::OnMouseMoved(uint8_t x, uint8_t y) {
158
 #ifdef DEBUG_OUTPUT_RAW
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
 #endif
159
 #endif
165
 
160
 
166
     uint8_t newX = centerMouseX;
161
     uint8_t newX = centerMouseX;
190
 
185
 
191
 #ifdef DEBUG_OUTPUT
186
 #ifdef DEBUG_OUTPUT
192
     if (updated) {
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
 #endif
193
 #endif
200
 
194
 

+ 1
- 1
frsky.cpp View File

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

+ 7
- 7
parser.cpp View File

13
 #include "events.h"
13
 #include "events.h"
14
 #include "parser.h"
14
 #include "parser.h"
15
 
15
 
16
-//#define DEBUG_OUTPUT
16
+//#define DEBUG_OUTPUT Serial
17
 
17
 
18
 JoystickReportParser::JoystickReportParser(JoystickEvents* evt)
18
 JoystickReportParser::JoystickReportParser(JoystickEvents* evt)
19
         : joyEvents(evt), oldHat(0), oldButtons(0), oldMouse(0), buffer(0) {
19
         : joyEvents(evt), oldHat(0), oldButtons(0), oldMouse(0), buffer(0) {
39
 
39
 
40
 #ifdef DEBUG_OUTPUT
40
 #ifdef DEBUG_OUTPUT
41
     // Dump whole USB HID packet for debugging purposes
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
     for (uint8_t i = 0; i < (8 + len); i++) {
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
 #endif
50
 #endif
51
 
51
 
52
     // Checking if there are changes in report since the method was last called
52
     // Checking if there are changes in report since the method was last called

+ 29
- 29
x52.cpp View File

12
 
12
 
13
 #include "x52.h"
13
 #include "x52.h"
14
 
14
 
15
-//#define DEBUG_OUTPUT
15
+//#define DEBUG_OUTPUT Serial
16
 
16
 
17
 #define TIME_24H_FORMAT
17
 #define TIME_24H_FORMAT
18
 
18
 
31
     uint8_t ret = usb->getDevDescr(hid->GetAddress(), 0, sizeof(USB_DEVICE_DESCRIPTOR), (uint8_t*)buf);
31
     uint8_t ret = usb->getDevDescr(hid->GetAddress(), 0, sizeof(USB_DEVICE_DESCRIPTOR), (uint8_t*)buf);
32
     if (ret) {
32
     if (ret) {
33
 #ifdef DEBUG_OUTPUT
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
 #endif
36
 #endif
37
     }
37
     }
38
 
38
 
40
     uint16_t pid = udd->idProduct;
40
     uint16_t pid = udd->idProduct;
41
 
41
 
42
 #ifdef DEBUG_OUTPUT
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
 #endif
47
 #endif
48
 
48
 
49
     if ((vid == 0x06A3) && (pid == 0x0255)) {
49
     if ((vid == 0x06A3) && (pid == 0x0255)) {
54
         ready = 1;
54
         ready = 1;
55
     } else {
55
     } else {
56
 #ifdef DEBUG_OUTPUT
56
 #ifdef DEBUG_OUTPUT
57
-        Serial.println("No valid VID/PID found!");
57
+        DEBUG_OUTPUT.println("No valid VID/PID found!");
58
 #endif
58
 #endif
59
     }
59
     }
60
 }
60
 }
67
             );
67
             );
68
     if (ret) {
68
     if (ret) {
69
 #ifdef DEBUG_OUTPUT
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
 #endif
72
 #endif
73
     }
73
     }
74
 }
74
 }
96
             );
96
             );
97
     if (ret) {
97
     if (ret) {
98
 #ifdef DEBUG_OUTPUT
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
 #endif
101
 #endif
102
     }
102
     }
103
 }
103
 }
109
     }
109
     }
110
     if (ret) {
110
     if (ret) {
111
 #ifdef DEBUG_OUTPUT
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
 #endif
114
 #endif
115
     }
115
     }
116
 }
116
 }
119
     uint8_t ret = sendCommand(X52_BLINK_INDICATOR, state ? X52_BLINK_ON : X52_BLINK_OFF);
119
     uint8_t ret = sendCommand(X52_BLINK_INDICATOR, state ? X52_BLINK_ON : X52_BLINK_OFF);
120
     if (ret != 0) {
120
     if (ret != 0) {
121
 #ifdef DEBUG_OUTPUT
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
 #endif
124
 #endif
125
     }
125
     }
126
 }
126
 }
129
     uint8_t ret = sendCommand(X52_SHIFT_INDICATOR, state ? X52_SHIFT_ON : X52_SHIFT_OFF);
129
     uint8_t ret = sendCommand(X52_SHIFT_INDICATOR, state ? X52_SHIFT_ON : X52_SHIFT_OFF);
130
     if (ret != 0) {
130
     if (ret != 0) {
131
 #ifdef DEBUG_OUTPUT
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
 #endif
134
 #endif
135
     }
135
     }
136
 }
136
 }
144
 
144
 
145
     if (line >= 3) {
145
     if (line >= 3) {
146
 #ifdef DEBUG_OUTPUT
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
 #endif
149
 #endif
150
         return;
150
         return;
151
     }
151
     }
153
     uint8_t ret = sendCommand(X52_MFD_CLEAR_LINE | lines[line], 0);
153
     uint8_t ret = sendCommand(X52_MFD_CLEAR_LINE | lines[line], 0);
154
     if (ret) {
154
     if (ret) {
155
 #ifdef DEBUG_OUTPUT
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
 #endif
158
 #endif
159
         return;
159
         return;
160
     }
160
     }
173
         ret = sendCommand(X52_MFD_WRITE_LINE | lines[line], value);
173
         ret = sendCommand(X52_MFD_WRITE_LINE | lines[line], value);
174
         if (ret) {
174
         if (ret) {
175
 #ifdef DEBUG_OUTPUT
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
 #endif
178
 #endif
179
             return;
179
             return;
180
         }
180
         }
188
 uint8_t X52::sendCommand(uint16_t command, uint16_t val) {
188
 uint8_t X52::sendCommand(uint16_t command, uint16_t val) {
189
     if (!ready) {
189
     if (!ready) {
190
 #ifdef DEBUG_OUTPUT
190
 #ifdef DEBUG_OUTPUT
191
-        Serial.println("Invalid state!");
191
+        DEBUG_OUTPUT.println("Invalid state!");
192
 #endif
192
 #endif
193
         return 23;
193
         return 23;
194
     }
194
     }
195
     
195
     
196
     if ((!usb) || (!hid)) {
196
     if ((!usb) || (!hid)) {
197
 #ifdef DEBUG_OUTPUT
197
 #ifdef DEBUG_OUTPUT
198
-        Serial.println("Invalid objects!");
198
+        DEBUG_OUTPUT.println("Invalid objects!");
199
 #endif
199
 #endif
200
         return 42;
200
         return 42;
201
     }
201
     }
204
     const uint8_t valHi = (val & 0xFF00) >> 8;
204
     const uint8_t valHi = (val & 0xFF00) >> 8;
205
 
205
 
206
 #ifdef DEBUG_OUTPUT
206
 #ifdef DEBUG_OUTPUT
207
-    Serial.println("Sending X52 Ctrl-Req...");
207
+    DEBUG_OUTPUT.println("Sending X52 Ctrl-Req...");
208
 #endif
208
 #endif
209
 
209
 
210
     uint8_t ret = usb->ctrlReq(hid->GetAddress(), 0,
210
     uint8_t ret = usb->ctrlReq(hid->GetAddress(), 0,
213
                               0, 0, NULL, NULL);
213
                               0, 0, NULL, NULL);
214
     if (ret != 0) {
214
     if (ret != 0) {
215
 #ifdef DEBUG_OUTPUT
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
 #endif
218
 #endif
219
     }
219
     }
220
 
220
 

Loading…
Cancel
Save