Move M260_M261 to cpp

This commit is contained in:
Scott Lahteine 2017-09-17 02:49:13 -05:00
parent 3e761696a0
commit d4d3d92f8a
4 changed files with 21 additions and 22 deletions

View File

@ -84,6 +84,7 @@
#if ENABLED(EXPERIMENTAL_I2CBUS) #if ENABLED(EXPERIMENTAL_I2CBUS)
#include "feature/twibus.h" #include "feature/twibus.h"
TWIBus i2c;
#endif #endif
#if ENABLED(I2C_POSITION_ENCODERS) #if ENABLED(I2C_POSITION_ENCODERS)
@ -98,10 +99,6 @@
CardReader card; CardReader card;
#endif #endif
#if ENABLED(EXPERIMENTAL_I2CBUS)
TWIBus i2c;
#endif
#if ENABLED(G38_PROBE_TARGET) #if ENABLED(G38_PROBE_TARGET)
bool G38_move = false, bool G38_move = false,
G38_endstop_hit = false; G38_endstop_hit = false;
@ -355,10 +352,6 @@ bool pin_is_protected(const int8_t pin) {
return false; return false;
} }
#if ENABLED(EXPERIMENTAL_I2CBUS)
#include "gcode/feature/i2c/M260_M261.h"
#endif
#if HAS_SERVOS #if HAS_SERVOS
#include "gcode/control/M280.h" #include "gcode/control/M280.h"
#endif #endif

View File

@ -143,6 +143,11 @@ void manage_inactivity(bool ignore_stepper_queue = false);
#endif // !MIXING_EXTRUDER #endif // !MIXING_EXTRUDER
#if ENABLED(EXPERIMENTAL_I2CBUS)
#include "feature/twibus.h"
extern TWIBus i2c;
#endif
#if ENABLED(G38_PROBE_TARGET) #if ENABLED(G38_PROBE_TARGET)
extern bool G38_move, // flag to tell the interrupt handler that a G38 command is being run extern bool G38_move, // flag to tell the interrupt handler that a G38 command is being run
G38_endstop_hit; // flag from the interrupt handler to indicate if the endstop went active G38_endstop_hit; // flag from the interrupt handler to indicate if the endstop went active

View File

@ -20,6 +20,14 @@
* *
*/ */
#include "../../../inc/MarlinConfig.h"
#if ENABLED(EXPERIMENTAL_I2CBUS)
#include "../../gcode.h"
#include "../../../Marlin.h" // for i2c
/** /**
* M260: Send data to a I2C slave device * M260: Send data to a I2C slave device
* *
@ -36,7 +44,7 @@
* M260 R1 ; Reset the buffer without sending data * M260 R1 ; Reset the buffer without sending data
* *
*/ */
void gcode_M260() { void GcodeSuite::M260() {
// Set the target address // Set the target address
if (parser.seen('A')) i2c.address(parser.value_byte()); if (parser.seen('A')) i2c.address(parser.value_byte());
@ -55,7 +63,7 @@ void gcode_M260() {
* *
* Usage: M261 A<slave device address base 10> B<number of bytes> * Usage: M261 A<slave device address base 10> B<number of bytes>
*/ */
void gcode_M261() { void GcodeSuite::M261() {
if (parser.seen('A')) i2c.address(parser.value_byte()); if (parser.seen('A')) i2c.address(parser.value_byte());
uint8_t bytes = parser.byteval('B', 1); uint8_t bytes = parser.byteval('B', 1);
@ -68,3 +76,5 @@ void gcode_M261() {
SERIAL_ERRORLN("Bad i2c request"); SERIAL_ERRORLN("Bad i2c request");
} }
} }
#endif

View File

@ -121,8 +121,6 @@ extern void gcode_M164();
extern void gcode_M165(); extern void gcode_M165();
extern void gcode_M240(); extern void gcode_M240();
extern void gcode_M250(); extern void gcode_M250();
extern void gcode_M260();
extern void gcode_M261();
extern void gcode_M280(); extern void gcode_M280();
extern void gcode_M300(); extern void gcode_M300();
extern void gcode_M301(); extern void gcode_M301();
@ -602,16 +600,9 @@ void GcodeSuite::process_next_command() {
#endif // HAS_LCD_CONTRAST #endif // HAS_LCD_CONTRAST
#if ENABLED(EXPERIMENTAL_I2CBUS) #if ENABLED(EXPERIMENTAL_I2CBUS)
case 260: M260(); break; // M260: Send data to an i2c slave
case 260: // M260: Send data to an i2c slave case 261: M261(); break; // M261: Request data from an i2c slave
gcode_M260(); #endif
break;
case 261: // M261: Request data from an i2c slave
gcode_M261();
break;
#endif // EXPERIMENTAL_I2CBUS
#if ENABLED(PREVENT_COLD_EXTRUSION) #if ENABLED(PREVENT_COLD_EXTRUSION)
case 302: // M302: Allow cold extrudes (set the minimum extrude temperature) case 302: // M302: Allow cold extrudes (set the minimum extrude temperature)