Scott Lahteine пре 7 година
родитељ
комит
d4d3d92f8a
4 измењених фајлова са 21 додато и 22 уклоњено
  1. 1
    8
      Marlin/src/Marlin.cpp
  2. 5
    0
      Marlin/src/Marlin.h
  3. 12
    2
      Marlin/src/gcode/feature/i2c/M260_M261.cpp
  4. 3
    12
      Marlin/src/gcode/gcode.cpp

+ 1
- 8
Marlin/src/Marlin.cpp Прегледај датотеку

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

+ 5
- 0
Marlin/src/Marlin.h Прегледај датотеку

@@ -143,6 +143,11 @@ void manage_inactivity(bool ignore_stepper_queue = false);
143 143
 
144 144
 #endif // !MIXING_EXTRUDER
145 145
 
146
+#if ENABLED(EXPERIMENTAL_I2CBUS)
147
+  #include "feature/twibus.h"
148
+  extern TWIBus i2c;
149
+#endif
150
+
146 151
 #if ENABLED(G38_PROBE_TARGET)
147 152
   extern bool G38_move,        // flag to tell the interrupt handler that a G38 command is being run
148 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 Прегледај датотеку

@@ -20,6 +20,14 @@
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 32
  * M260: Send data to a I2C slave device
25 33
  *
@@ -36,7 +44,7 @@
36 44
  *  M260 R1 ; Reset the buffer without sending data
37 45
  *
38 46
  */
39
-void gcode_M260() {
47
+void GcodeSuite::M260() {
40 48
   // Set the target address
41 49
   if (parser.seen('A')) i2c.address(parser.value_byte());
42 50
 
@@ -55,7 +63,7 @@ void gcode_M260() {
55 63
  *
56 64
  * Usage: M261 A<slave device address base 10> B<number of bytes>
57 65
  */
58
-void gcode_M261() {
66
+void GcodeSuite::M261() {
59 67
   if (parser.seen('A')) i2c.address(parser.value_byte());
60 68
 
61 69
   uint8_t bytes = parser.byteval('B', 1);
@@ -68,3 +76,5 @@ void gcode_M261() {
68 76
     SERIAL_ERRORLN("Bad i2c request");
69 77
   }
70 78
 }
79
+
80
+#endif

+ 3
- 12
Marlin/src/gcode/gcode.cpp Прегледај датотеку

@@ -121,8 +121,6 @@ extern void gcode_M164();
121 121
 extern void gcode_M165();
122 122
 extern void gcode_M240();
123 123
 extern void gcode_M250();
124
-extern void gcode_M260();
125
-extern void gcode_M261();
126 124
 extern void gcode_M280();
127 125
 extern void gcode_M300();
128 126
 extern void gcode_M301();
@@ -602,16 +600,9 @@ void GcodeSuite::process_next_command() {
602 600
       #endif // HAS_LCD_CONTRAST
603 601
 
604 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 607
       #if ENABLED(PREVENT_COLD_EXTRUSION)
617 608
         case 302: // M302: Allow cold extrudes (set the minimum extrude temperature)

Loading…
Откажи
Сачувај