当前位置: 首页>>代码示例>>C++>>正文


C++ Gcode类代码示例

本文整理汇总了C++中Gcode的典型用法代码示例。如果您正苦于以下问题:C++ Gcode类的具体用法?C++ Gcode怎么用?C++ Gcode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Gcode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: on_gcode_received

void ToolManager::on_gcode_received(void *argument)
{
    Gcode *gcode = static_cast<Gcode*>(argument);

    if( gcode->has_letter('T') ) {
        int new_tool = gcode->get_value('T');
        if(new_tool >= (int)this->tools.size() || new_tool < 0) {
            // invalid tool
            char buf[32]; // should be big enough for any status
            int n = snprintf(buf, sizeof(buf), "T%d invalid tool ", new_tool);
            gcode->txt_after_ok.append(buf, n);

        } else {
            if(new_tool != this->active_tool) {
                // We must wait for an empty queue before we can disable the current extruder
                THEKERNEL->conveyor->wait_for_empty_queue();
                this->tools[active_tool]->disable();
                this->active_tool = new_tool;
                this->current_tool_name = this->tools[active_tool]->get_name();
                this->tools[active_tool]->enable();

                //send new_tool_offsets to robot
                const float *new_tool_offset = tools[new_tool]->get_offset();
                THEKERNEL->robot->setToolOffset(new_tool_offset);
            }
        }
    }
}
开发者ID:ChristianRiesen,项目名称:Smoothie2,代码行数:28,代码来源:ToolManager.cpp

示例2: on_gcode_execute

// Turn pin on and off
void Switch::on_gcode_execute(void* argument){
    Gcode* gcode = static_cast<Gcode*>(argument);
    if( gcode->has_m){
        int code = gcode->m;
        if( code == this->on_m_code ){
            if (gcode->has_letter('S'))
            {
                int v = gcode->get_value('S') * output_pin.max_pwm() / 256.0;
                if (v)
                    this->output_pin.pwm(v);
                else
                    this->output_pin.set(0);
            }
            else
            {
                // Turn pin on
                this->output_pin.set(1);
            }
        }
        if( code == this->off_m_code ){
            // Turn pin off
            this->output_pin.set(0);
        }
    }
}
开发者ID:AndroZoid,项目名称:Smoothie,代码行数:26,代码来源:Switch.cpp

示例3: on_gcode_execute

// Turn laser on/off depending on received GCodes
void Laser::on_gcode_execute(void* argument){
    Gcode* gcode = static_cast<Gcode*>(argument);
    this->laser_on = false;
    if( gcode->has_g){
        int code = gcode->g;
        if( code == 0 ){                    // G0
            this->pwm_pin->write(this->pwm_inverting ? 1 - this->laser_minimum_power : this->laser_minimum_power);
            this->laser_on =  false;
        }else if( code >= 1 && code <= 3 ){ // G1, G2, G3
            this->laser_on =  true;
        }
    }

    if ( gcode->has_letter('S' )){
    	float requested_power = gcode->get_value('S') / this->laser_maximum_s_value;
    	// Ensure we can't exceed maximum power
    	if (requested_power > 1)
    		requested_power = 1;

        this->laser_power = requested_power;
    }

    if (this->ttl_used)
        this->ttl_pin->set(this->laser_on);

}
开发者ID:CubeSpawn-Research,项目名称:Smoothieware,代码行数:27,代码来源:Laser.cpp

示例4: on_gcode_received

void CurrentControl::on_gcode_received(void *argument)
{
    Gcode *gcode = static_cast<Gcode*>(argument);
    char alpha[8] = { 'X', 'Y', 'Z', 'E', 'A', 'B', 'C', 'D' };
    if (gcode->has_m)
    {
        if (gcode->m == 907)
        {
            int i;
            for (i = 0; i < 8; i++)
            {
                if (gcode->has_letter(alpha[i])){
                    float c= gcode->get_value(alpha[i]);
                    this->digipot->set_current(i, c);
                    switch(i) {
                        case 0: this->alpha_current= c; break;
                        case 1: this->beta_current= c; break;
                        case 2: this->gamma_current= c; break;
                        case 3: this->delta_current= c; break;
                        case 4: this->epsilon_current= c; break;
                        case 5: this->zeta_current= c; break;
                        case 6: this->eta_current= c; break;
                        case 7: this->theta_current= c; break;
                    }
                }
                gcode->stream->printf("%c:%3.1fA%c", alpha[i], this->digipot->get_current(i), (i == 7)?'\n':' ');
            }

        }else if(gcode->m == 500 || gcode->m == 503) {
            if(this->delta_current != this->original_delta_current) { // if not the same as loaded by config then save it
                gcode->stream->printf(";Extruder current:\nM907 E%1.5f\n", this->delta_current);
            }
        }
    }
}
开发者ID:0x23,项目名称:Smoothieware,代码行数:35,代码来源:CurrentControl.cpp

示例5: on_gcode_received

void SimpleShell::on_gcode_received(void *argument)
{
    Gcode *gcode = static_cast<Gcode *>(argument);
    string args = get_arguments(gcode->get_command());

    if (gcode->has_m) {
        if (gcode->m == 20) { // list sd card
            gcode->stream->printf("Begin file list\r\n");
            ls_command("/sd", gcode->stream);
            gcode->stream->printf("End file list\r\n");

        } else if (gcode->m == 30) { // remove file
            rm_command("/sd/" + args, gcode->stream);

        } else if(gcode->m == 501) { // load config override
            if(args.empty()) {
                load_command("/sd/config-override", gcode->stream);
            } else {
                load_command("/sd/config-override." + args, gcode->stream);
            }

        } else if(gcode->m == 504) { // save to specific config override file
            if(args.empty()) {
                save_command("/sd/config-override", gcode->stream);
            } else {
                save_command("/sd/config-override." + args, gcode->stream);
            }
        }
    }
}
开发者ID:arms22,项目名称:Smoothie,代码行数:30,代码来源:SimpleShell.cpp

示例6: on_gcode_execute

// Turn pin on and off
void Switch::on_gcode_execute(void *argument)
{
    Gcode *gcode = static_cast<Gcode *>(argument);

    if(match_input_on_gcode(gcode)) {
        int v;
        this->switch_state = true;
        if (this->output_type == PWM) {
            // PWM output pin turn on
            if(gcode->has_letter('S')) {
                v = round(gcode->get_value('S') * output_pin.max_pwm() / 255.0); // scale by max_pwm so input of 255 and max_pwm of 128 would set value to 128
                this->output_pin.pwm(v);
            } else {
                this->output_pin.pwm(this->switch_value);
            }
        } else {
            // logic pin turn on
            this->output_pin.set(true);
        }
    } else if(match_input_off_gcode(gcode)) {
        this->switch_state = false;
        if (this->output_type == PWM) {
            // PWM output pin
            this->output_pin.set(false);
        } else {
            // logic pin turn off
            this->output_pin.set(false);
        }
    }
}
开发者ID:0x23,项目名称:Smoothieware,代码行数:31,代码来源:Switch.cpp

示例7: on_gcode_execute

void TemperatureControl::on_gcode_execute(void* argument){
    Gcode* gcode = static_cast<Gcode*>(argument);
    if( gcode->has_m){
        if (((gcode->m == this->set_m_code) || (gcode->m == this->set_and_wait_m_code))
            && gcode->has_letter('S'))
        {
            float v = gcode->get_value('S');

            if (v == 0.0)
            {
                this->target_temperature = UNDEFINED;
                this->heater_pin.set((this->o=0));
            }
            else
            {
                this->set_desired_temperature(v);

                if( gcode->m == this->set_and_wait_m_code)
                {
                    THEKERNEL->pauser->take();
                    this->waiting = true;
                }
            }
        }
    }
}
开发者ID:0x23,项目名称:Smoothieware,代码行数:26,代码来源:TemperatureControl.cpp

示例8: on_gcode_received

void TemperatureSwitch::on_gcode_received(void *argument)
{
    Gcode *gcode = static_cast<Gcode *>(argument);
    if(gcode->has_m && gcode->m == this->arm_mcode) {
        this->armed= (gcode->has_letter('S') && gcode->get_value('S') != 0);
        gcode->stream->printf("temperature switch %s\n", this->armed ? "armed" : "disarmed");
    }
}
开发者ID:s0up,项目名称:SmootherWare,代码行数:8,代码来源:TemperatureSwitch.cpp

示例9: on_gcode_received

void Panel::on_gcode_received(void *argument)
{
    Gcode *gcode = static_cast<Gcode *>(argument);
    if ( gcode->has_m) {
        if ( gcode->m == 117 ) { // set LCD message
            this->message = get_arguments(gcode->get_command());
            if (this->message.size() > 20) this->message = this->message.substr(0, 20);
            gcode->mark_as_taken();
        }
    }
}
开发者ID:2thetop,项目名称:Smoothieware,代码行数:11,代码来源:Panel.cpp

示例10: on_gcode_received

void SimpleShell::on_gcode_received(void *argument) {
    Gcode *gcode = static_cast<Gcode*>(argument);

    if (gcode->has_m) {
        if (gcode->m == 20) { // list sd card
            gcode->mark_as_taken();
            gcode->stream->printf("Begin file list\r\n");
            ls_command("/sd", gcode->stream);
            gcode->stream->printf("End file list\r\n");
        }
    }
}
开发者ID:pjohns30,项目名称:Smoothie,代码行数:12,代码来源:SimpleShell.cpp

示例11: on_gcode_execute

// Process and respond to eeprom gcodes (M50x)
void Configurator::on_gcode_execute(void* argument){
    Gcode* gcode = static_cast<Gcode*>(argument);
    if( gcode->has_letter('G') ){
        int code = gcode->get_value('G');
        switch( code ){
        }
    }
    else if( gcode->has_letter('M') ){
        int code = gcode->get_value('M');
        switch( code ){
        }
    }
}
开发者ID:CNCBASHER,项目名称:Smoothie,代码行数:14,代码来源:Configurator.cpp

示例12: on_gcode_execute

// Turn laser on/off depending on received GCodes
void Laser::on_gcode_execute(void* argument){
    Gcode* gcode = static_cast<Gcode*>(argument);
    this->laser_on = false;
    if( gcode->has_letter('G' )){
        int code = gcode->get_value('G');
        if( code == 0 ){                    // G0
            this->laser_pin = 0;
            this->laser_on =  false;
        }else if( code >= 1 && code <= 3 ){ // G1, G2, G3
            this->laser_on =  true;
        }
    }
}
开发者ID:janczi,项目名称:Smoothie,代码行数:14,代码来源:Laser.cpp

示例13: on_gcode_execute

// React to enable/disable gcodes
void Stepper::on_gcode_execute(void *argument)
{
    Gcode *gcode = static_cast<Gcode *>(argument);

    if( gcode->has_m) {
        if( gcode->m == 17 ) {
            this->turn_enable_pins_on();
        }
        if( (gcode->m == 84 || gcode->m == 18) && !gcode->has_letter('E') ) {
            this->turn_enable_pins_off();
        }
    }
}
开发者ID:s0up,项目名称:SmootherWare,代码行数:14,代码来源:Stepper.cpp

示例14: main

int main(int argc, const char* argv[]){
  if(argc != 5)
    std::cout << "Please supply a bitmap shape location, increase ratio, wall width and no. layers \n"; 
  else
  {
    const char* filename = argv[1];
    double inc_ratio = atof(argv[2]);
    int wall_width = atoi(argv[3]);
    int no_layers = atoi(argv[4]);
    Gcode g = Gcode(filename, inc_ratio, wall_width, no_layers);
    g.generate();
  }
}
开发者ID:JWHennessey,项目名称:custom_slicer,代码行数:13,代码来源:custom_slicer.cpp

示例15: on_gcode_received

void Stepper::on_gcode_received(void *argument)
{
    Gcode *gcode = static_cast<Gcode *>(argument);

    if( gcode->has_m) {
        if( gcode->m == 17 ) {
            this->turn_enable_pins_on();

        }else if( (gcode->m == 84 || gcode->m == 18) && !gcode->has_letter('E') ) {
            THEKERNEL->conveyor->wait_for_empty_queue();
            this->turn_enable_pins_off();
        }
    }
}
开发者ID:ChristianRiesen,项目名称:Smoothie2,代码行数:14,代码来源:Stepper.cpp


注:本文中的Gcode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。