MCPcopy Create free account
hub / github.com/MarlinFirmware/Marlin / M240

Method M240

Marlin/src/gcode/feature/camera/M240.cpp:125–195  ·  view source on GitHub ↗

* M240: Trigger a camera by... * * - CHDK : Emulate a Canon RC-1 with a configurable ON duration. * https://captain-slow.dk/2014/03/09/3d-printing-timelapses/ * - PHOTOGRAPH_PIN : Pulse a digital pin 16 times. * See https://www.doc-diy.net/photo/rc-1_hacked/ * - PHOTO_SWITCH_POSITION : Bump a physical switch wit

Source from the content-addressed store, hash-verified

123 * J - Switch trigger position override Y
124 */
125void GcodeSuite::M240() {
126
127 #ifdef PHOTO_POSITION
128
129 if (homing_needed_error()) return;
130
131 const xyz_pos_t old_pos = NUM_AXIS_ARRAY(
132 current_position.x + parser.linearval('A'),
133 current_position.y + parser.linearval('B'),
134 current_position.z,
135 current_position.i, current_position.j, current_position.k,
136 current_position.u, current_position.v, current_position.w
137 );
138
139 #ifdef PHOTO_RETRACT_MM
140 const float rval = parser.linearval('R', _PHOTO_RETRACT_MM);
141 const feedRate_t sval = parser.feedrateval('S', TERN(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_RETRACT_FEEDRATE, TERN(FWRETRACT, RETRACT_FEEDRATE, 45)));
142 e_move_m240(-rval, sval);
143 #endif
144
145 feedRate_t fr_mm_s = parser.feedrateval('F');
146 if (fr_mm_s) NOLESS(fr_mm_s, 10.0f);
147
148 constexpr xyz_pos_t photo_position = PHOTO_POSITION;
149 xyz_pos_t raw = {
150 parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : photo_position.x,
151 parser.seenval('Y') ? RAW_Y_POSITION(parser.value_linear_units()) : photo_position.y,
152 (parser.seenval('Z') ? parser.value_linear_units() : photo_position.z) + current_position.z
153 };
154 apply_motion_limits(raw);
155 do_blocking_move_to(raw, fr_mm_s);
156
157 #ifdef PHOTO_SWITCH_POSITION
158 constexpr xy_pos_t photo_switch_position = PHOTO_SWITCH_POSITION;
159 const xy_pos_t sraw = {
160 parser.seenval('I') ? RAW_X_POSITION(parser.value_linear_units()) : photo_switch_position.x,
161 parser.seenval('J') ? RAW_Y_POSITION(parser.value_linear_units()) : photo_switch_position.y
162 };
163 do_blocking_move_to_xy(sraw, get_homing_bump_feedrate(X_AXIS));
164 #if PHOTO_SWITCH_MS > 0
165 safe_delay(parser.intval('D', PHOTO_SWITCH_MS));
166 #endif
167 do_blocking_move_to(raw);
168 #endif
169
170 #endif
171
172 #if PIN_EXISTS(CHDK)
173
174 OUT_WRITE(CHDK_PIN, HIGH);
175 chdk_timeout = millis() + parser.intval('D', PHOTO_SWITCH_MS);
176
177 #elif HAS_PHOTOGRAPH
178
179 spin_photo_pin();
180 delay(7.33);
181 spin_photo_pin();
182

Callers

nothing calls this directly

Calls 15

e_move_m240Function · 0.85
NOLESSFunction · 0.85
apply_motion_limitsFunction · 0.85
do_blocking_move_toFunction · 0.85
get_homing_bump_feedrateFunction · 0.85
safe_delayFunction · 0.85
spin_photo_pinFunction · 0.85
delayFunction · 0.85
idleFunction · 0.85
linearvalMethod · 0.80
feedratevalMethod · 0.80
seenvalMethod · 0.80

Tested by

no test coverage detected