Browse Source

Move M260_M261 to cpp

Scott Lahteine 7 years ago
parent
commit
d4d3d92f8a

+ 1
- 8
Marlin/src/Marlin.cpp View File

84
 
84
 
85
 #if ENABLED(EXPERIMENTAL_I2CBUS)
85
 #if ENABLED(EXPERIMENTAL_I2CBUS)
86
   #include "feature/twibus.h"
86
   #include "feature/twibus.h"
87
+  TWIBus i2c;
87
 #endif
88
 #endif
88
 
89
 
89
 #if ENABLED(I2C_POSITION_ENCODERS)
90
 #if ENABLED(I2C_POSITION_ENCODERS)
98
   CardReader card;
99
   CardReader card;
99
 #endif
100
 #endif
100
 
101
 
101
-#if ENABLED(EXPERIMENTAL_I2CBUS)
102
-  TWIBus i2c;
103
-#endif
104
-
105
 #if ENABLED(G38_PROBE_TARGET)
102
 #if ENABLED(G38_PROBE_TARGET)
106
   bool G38_move = false,
103
   bool G38_move = false,
107
        G38_endstop_hit = false;
104
        G38_endstop_hit = false;
355
   return false;
352
   return false;
356
 }
353
 }
357
 
354
 
358
-#if ENABLED(EXPERIMENTAL_I2CBUS)
359
-  #include "gcode/feature/i2c/M260_M261.h"
360
-#endif
361
-
362
 #if HAS_SERVOS
355
 #if HAS_SERVOS
363
   #include "gcode/control/M280.h"
356
   #include "gcode/control/M280.h"
364
 #endif
357
 #endif

+ 5
- 0
Marlin/src/Marlin.h View File

143
 
143
 
144
 #endif // !MIXING_EXTRUDER
144
 #endif // !MIXING_EXTRUDER
145
 
145
 
146
+#if ENABLED(EXPERIMENTAL_I2CBUS)
147
+  #include "feature/twibus.h"
148
+  extern TWIBus i2c;
149
+#endif
150
+
146
 #if ENABLED(G38_PROBE_TARGET)
151
 #if ENABLED(G38_PROBE_TARGET)
147
   extern bool G38_move,        // flag to tell the interrupt handler that a G38 command is being run
152
   extern bool G38_move,        // flag to tell the interrupt handler that a G38 command is being run
148
               G38_endstop_hit; // flag from the interrupt handler to indicate if the endstop went active
153
               G38_endstop_hit; // flag from the interrupt handler to indicate if the endstop went active

Marlin/src/gcode/feature/i2c/M260_M261.h → Marlin/src/gcode/feature/i2c/M260_M261.cpp View File

20
  *
20
  *
21
  */
21
  */
22
 
22
 
23
+#include "../../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(EXPERIMENTAL_I2CBUS)
26
+
27
+#include "../../gcode.h"
28
+
29
+#include "../../../Marlin.h" // for i2c
30
+
23
 /**
31
 /**
24
  * M260: Send data to a I2C slave device
32
  * M260: Send data to a I2C slave device
25
  *
33
  *
36
  *  M260 R1 ; Reset the buffer without sending data
44
  *  M260 R1 ; Reset the buffer without sending data
37
  *
45
  *
38
  */
46
  */
39
-void gcode_M260() {
47
+void GcodeSuite::M260() {
40
   // Set the target address
48
   // Set the target address
41
   if (parser.seen('A')) i2c.address(parser.value_byte());
49
   if (parser.seen('A')) i2c.address(parser.value_byte());
42
 
50
 
55
  *
63
  *
56
  * Usage: M261 A<slave device address base 10> B<number of bytes>
64
  * Usage: M261 A<slave device address base 10> B<number of bytes>
57
  */
65
  */
58
-void gcode_M261() {
66
+void GcodeSuite::M261() {
59
   if (parser.seen('A')) i2c.address(parser.value_byte());
67
   if (parser.seen('A')) i2c.address(parser.value_byte());
60
 
68
 
61
   uint8_t bytes = parser.byteval('B', 1);
69
   uint8_t bytes = parser.byteval('B', 1);
68
     SERIAL_ERRORLN("Bad i2c request");
76
     SERIAL_ERRORLN("Bad i2c request");
69
   }
77
   }
70
 }
78
 }
79
+
80
+#endif

+ 3
- 12
Marlin/src/gcode/gcode.cpp View File

121
 extern void gcode_M165();
121
 extern void gcode_M165();
122
 extern void gcode_M240();
122
 extern void gcode_M240();
123
 extern void gcode_M250();
123
 extern void gcode_M250();
124
-extern void gcode_M260();
125
-extern void gcode_M261();
126
 extern void gcode_M280();
124
 extern void gcode_M280();
127
 extern void gcode_M300();
125
 extern void gcode_M300();
128
 extern void gcode_M301();
126
 extern void gcode_M301();
602
       #endif // HAS_LCD_CONTRAST
600
       #endif // HAS_LCD_CONTRAST
603
 
601
 
604
       #if ENABLED(EXPERIMENTAL_I2CBUS)
602
       #if ENABLED(EXPERIMENTAL_I2CBUS)
605
-
606
-        case 260: // M260: Send data to an i2c slave
607
-          gcode_M260();
608
-          break;
609
-
610
-        case 261: // M261: Request data from an i2c slave
611
-          gcode_M261();
612
-          break;
613
-
614
-      #endif // EXPERIMENTAL_I2CBUS
603
+        case 260: M260(); break;  // M260: Send data to an i2c slave
604
+        case 261: M261(); break;  // M261: Request data from an i2c slave
605
+      #endif
615
 
606
 
616
       #if ENABLED(PREVENT_COLD_EXTRUSION)
607
       #if ENABLED(PREVENT_COLD_EXTRUSION)
617
         case 302: // M302: Allow cold extrudes (set the minimum extrude temperature)
608
         case 302: // M302: Allow cold extrudes (set the minimum extrude temperature)

Loading…
Cancel
Save