本文整理汇总了C++中Gcode::get_args方法的典型用法代码示例。如果您正苦于以下问题:C++ Gcode::get_args方法的具体用法?C++ Gcode::get_args怎么用?C++ Gcode::get_args使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gcode
的用法示例。
在下文中一共展示了Gcode::get_args方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_gcode_received
void TemperatureControl::on_gcode_received(void *argument)
{
Gcode *gcode = static_cast<Gcode *>(argument);
if (gcode->has_m) {
if( gcode->m == this->get_m_code ) {
char buf[32]; // should be big enough for any status
int n = snprintf(buf, sizeof(buf), "%s:%3.1f /%3.1f @%d ", this->designator.c_str(), this->get_temperature(), ((target_temperature <= 0) ? 0.0 : target_temperature), this->o);
gcode->txt_after_ok.append(buf, n);
return;
}
if (gcode->m == 305) { // set or get sensor settings
if (gcode->has_letter('S') && (gcode->get_value('S') == this->pool_index)) {
TempSensor::sensor_options_t args= gcode->get_args();
args.erase('S'); // don't include the S
if(args.size() > 0) {
// set the new options
if(sensor->set_optional(args)) {
this->sensor_settings= true;
}else{
gcode->stream->printf("Unable to properly set sensor settings, make sure you specify all required values\n");
}
}else{
// don't override
this->sensor_settings= false;
}
}else if(!gcode->has_letter('S')) {
gcode->stream->printf("%s(S%d): using %s\n", this->designator.c_str(), this->pool_index, this->readonly?"Readonly" : this->use_bangbang?"Bangbang":"PID");
sensor->get_raw();
TempSensor::sensor_options_t options;
if(sensor->get_optional(options)) {
for(auto &i : options) {
// foreach optional value
gcode->stream->printf("%s(S%d): %c %1.18f\n", this->designator.c_str(), this->pool_index, i.first, i.second);
}
}
}
return;
}
// readonly sensors don't handle the rest
if(this->readonly) return;
if (gcode->m == 143) {
if (gcode->has_letter('S') && (gcode->get_value('S') == this->pool_index)) {
if(gcode->has_letter('P')) {
max_temp= gcode->get_value('P');
} else {
gcode->stream->printf("Nothing set NOTE Usage is M143 S0 P300 where <S> is the hotend index and <P> is the maximum temp to set\n");
}
}else if(gcode->get_num_args() == 0) {
gcode->stream->printf("Maximum temperature for %s(%d) is %f°C\n", this->designator.c_str(), this->pool_index, max_temp);
}
} else if (gcode->m == 301) {
if (gcode->has_letter('S') && (gcode->get_value('S') == this->pool_index)) {
if (gcode->has_letter('P'))
setPIDp( gcode->get_value('P') );
if (gcode->has_letter('I'))
setPIDi( gcode->get_value('I') );
if (gcode->has_letter('D'))
setPIDd( gcode->get_value('D') );
if (gcode->has_letter('X'))
this->i_max = gcode->get_value('X');
if (gcode->has_letter('Y'))
this->heater_pin.max_pwm(gcode->get_value('Y'));
}else if(!gcode->has_letter('S')) {
gcode->stream->printf("%s(S%d): Pf:%g If:%g Df:%g X(I_max):%g max pwm: %d O:%d\n", this->designator.c_str(), this->pool_index, this->p_factor, this->i_factor / this->PIDdt, this->d_factor * this->PIDdt, this->i_max, this->heater_pin.max_pwm(), o);
}
} else if (gcode->m == 500 || gcode->m == 503) { // M500 saves some volatile settings to config override file, M503 just prints the settings
gcode->stream->printf(";PID settings:\nM301 S%d P%1.4f I%1.4f D%1.4f X%1.4f Y%d\n", this->pool_index, this->p_factor, this->i_factor / this->PIDdt, this->d_factor * this->PIDdt, this->i_max, this->heater_pin.max_pwm());
gcode->stream->printf(";Max temperature setting:\nM143 S%d P%1.4f\n", this->pool_index, this->max_temp);
if(this->sensor_settings) {
// get or save any sensor specific optional values
TempSensor::sensor_options_t options;
if(sensor->get_optional(options) && !options.empty()) {
gcode->stream->printf(";Optional temp sensor specific settings:\nM305 S%d", this->pool_index);
for(auto &i : options) {
gcode->stream->printf(" %c%1.18f", i.first, i.second);
}
gcode->stream->printf("\n");
}
}
} else if( ( gcode->m == this->set_m_code || gcode->m == this->set_and_wait_m_code ) && gcode->has_letter('S')) {
// this only gets handled if it is not controlled by the tool manager or is active in the toolmanager
this->active = true;
// this is safe as old configs as well as single extruder configs the toolmanager will not be running so will return false
// this will also ignore anything that the tool manager is not controlling and return false, otherwise it returns the active tool
void *returned_data;
//.........这里部分代码省略.........
示例2: on_gcode_received
//.........这里部分代码省略.........
}
break;
case 400: // wait until all moves are done up to this point
gcode->mark_as_taken();
THEKERNEL->conveyor->wait_for_empty_queue();
break;
case 500: // M500 saves some volatile settings to config override file
case 503: { // M503 just prints the settings
gcode->stream->printf(";Steps per unit:\nM92 X%1.5f Y%1.5f Z%1.5f\n", actuators[0]->steps_per_mm, actuators[1]->steps_per_mm, actuators[2]->steps_per_mm);
gcode->stream->printf(";Acceleration mm/sec^2:\nM204 S%1.5f Z%1.5f\n", THEKERNEL->planner->acceleration, THEKERNEL->planner->z_acceleration);
gcode->stream->printf(";X- Junction Deviation, Z- Z junction deviation, S - Minimum Planner speed mm/sec:\nM205 X%1.5f Z%1.5f S%1.5f\n", THEKERNEL->planner->junction_deviation, THEKERNEL->planner->z_junction_deviation, THEKERNEL->planner->minimum_planner_speed);
gcode->stream->printf(";Max feedrates in mm/sec, XYZ cartesian, ABC actuator:\nM203 X%1.5f Y%1.5f Z%1.5f A%1.5f B%1.5f C%1.5f\n",
this->max_speeds[X_AXIS], this->max_speeds[Y_AXIS], this->max_speeds[Z_AXIS],
alpha_stepper_motor->get_max_rate(), beta_stepper_motor->get_max_rate(), gamma_stepper_motor->get_max_rate());
// get or save any arm solution specific optional values
BaseSolution::arm_options_t options;
if(arm_solution->get_optional(options) && !options.empty()) {
gcode->stream->printf(";Optional arm solution specific settings:\nM665");
for(auto &i : options) {
gcode->stream->printf(" %c%1.4f", i.first, i.second);
}
gcode->stream->printf("\n");
}
gcode->mark_as_taken();
break;
}
case 665: { // M665 set optional arm solution variables based on arm solution.
gcode->mark_as_taken();
// the parameter args could be any letter each arm solution only accepts certain ones
BaseSolution::arm_options_t options= gcode->get_args();
options.erase('S'); // don't include the S
options.erase('U'); // don't include the U
if(options.size() > 0) {
// set the specified options
arm_solution->set_optional(options);
}
options.clear();
if(arm_solution->get_optional(options)) {
// foreach optional value
for(auto &i : options) {
// print all current values of supported options
gcode->stream->printf("%c: %8.4f ", i.first, i.second);
gcode->add_nl = true;
}
}
if(gcode->has_letter('S')) { // set delta segments per second, not saved by M500
this->delta_segments_per_second = gcode->get_value('S');
gcode->stream->printf("Delta segments set to %8.4f segs/sec\n", this->delta_segments_per_second);
}else if(gcode->has_letter('U')) { // or set mm_per_line_segment, not saved by M500
this->mm_per_line_segment = gcode->get_value('U');
this->delta_segments_per_second = 0;
gcode->stream->printf("mm per line segment set to %8.4f\n", this->mm_per_line_segment);
}
break;
}
}
}
if( this->motion_mode < 0)