@@ -50,114 +50,19 @@ void dumpInfo() {
5050 Serial.println (" bits)" );
5151}
5252
53- // +=============================================================================
54- // Dump out the decode_results structure.
55- //
56- void dumpRaw () {
57- // Print Raw data
58- Serial.print (" Timing[" );
59- Serial.print (IrReceiver.results .rawlen - 1 , DEC);
60- Serial.println (" ]: " );
61-
62- for (unsigned int i = 1 ; i < IrReceiver.results .rawlen ; i++) {
63- unsigned long x = IrReceiver.results .rawbuf [i] * MICROS_PER_TICK;
64- if (!(i & 1 )) { // even
65- Serial.print (" -" );
66- if (x < 1000 ) {
67- Serial.print (" " );
68- }
69- if (x < 100 ) {
70- Serial.print (" " );
71- }
72- Serial.print (x, DEC);
73- } else { // odd
74- Serial.print (" " );
75- Serial.print (" +" );
76- if (x < 1000 ) {
77- Serial.print (" " );
78- }
79- if (x < 100 ) {
80- Serial.print (" " );
81- }
82- Serial.print (x, DEC);
83- if (i < IrReceiver.results .rawlen - 1 ) {
84- Serial.print (" , " ); // ',' not needed for last one
85- }
86- }
87- if (!(i % 8 )) {
88- Serial.println (" " );
89- }
90- }
91- Serial.println (" " ); // Newline
92- }
93-
94- // +=============================================================================
95- // Dump out the decode_results structure.
96- //
97- void dumpCode () {
98- // Start declaration
99- Serial.print (" unsigned int " ); // variable type
100- Serial.print (" rawData[" ); // array name
101- Serial.print (IrReceiver.results .rawlen - 1 , DEC); // array size
102- Serial.print (" ] = {" ); // Start declaration
103-
104- // Dump data
105- for (unsigned int i = 1 ; i < IrReceiver.results .rawlen ; i++) {
106- Serial.print (IrReceiver.results .rawbuf [i] * MICROS_PER_TICK, DEC);
107- if (i < IrReceiver.results .rawlen - 1 )
108- Serial.print (" ," ); // ',' not needed on last one
109- if (!(i & 1 ))
110- Serial.print (" " );
111- }
112-
113- // End declaration
114- Serial.print (" };" ); //
115-
116- // Comment
117- Serial.print (" // " );
118- IrReceiver.printResultShort (&Serial);
119-
120- // Newline
121- Serial.println (" " );
122-
123- // Now dump "known" codes
124- if (IrReceiver.results .decode_type != UNKNOWN) {
125-
126- // Some protocols have an address
127- if (IrReceiver.results .address != 0 ){
128- Serial.print (" unsigned int addr = 0x" );
129- Serial.print (IrReceiver.results .address , HEX);
130- Serial.println (" ;" );
131- }
132-
133- // All protocols have data
134- Serial.print (" unsigned int data = 0x" );
135- Serial.print (IrReceiver.results .value , HEX);
136- Serial.println (" ;" );
137- Serial.println ();
138- }
139- }
140-
141- // +=============================================================================
142- // Dump out the raw data as Pronto Hex.
143- //
144- void dumpPronto () {
145- Serial.print (" Pronto Hex: " );
146- IrReceiver.dumpPronto (Serial);
147- Serial.println ();
148- }
149-
15053// +=============================================================================
15154// The repeating section of the code
15255//
15356void loop () {
15457 if (IrReceiver.decode ()) { // Grab an IR code
155- dumpInfo (); // Output the results
156- dumpRaw (); // Output the results in RAW format
157- dumpCode (); // Output the results as source code
158- dumpPronto ();
159- Serial.println (); // 2 blank lines between entries
58+ dumpInfo (); // Output the results
59+ IrReceiver.printIRResultRawFormatted (&Serial); // Output the results in RAW format
60+ Serial.println (); // blank line between entries
61+ IrReceiver.printIRResultAsCArray (&Serial); // Output the results as source code array
62+ IrReceiver.printIRResultAsCVariables (&Serial); // Output address and data as source code variables
63+ IrReceiver.printIRResultAsPronto (&Serial);
64+ Serial.println (); // 2 blank lines between entries
16065 Serial.println ();
161- IrReceiver.resume (); // Prepare for the next value
66+ IrReceiver.resume (); // Prepare for the next value
16267 }
16368}
0 commit comments