📄 gcode.c
字号:
case 141: X=X*25.4; Y=Y*25.4; Z=Z*25.4; A=change_aux_unit(software, A, MM); I=I*25.4; J=J*25.4;
cur_sp=cur_sp*25.4; (*ctrl).frate=(*ctrl).frate*25.4;
change_pt_units(software, world, MM, MM);
change_gcode_units(software, gcode, MM, MM);
change_units(hardware, software, MM, MM);
GMTtext(software, ctrl, gcode); break;
case 142: update_display(software, (*world).x_pos*(*ctrl).pty, (*world).y_pos*(*ctrl).pty,
(*world).z_pos*(*ctrl).pty, (*world).a_pos*(*ctrl).pty, 0, 0, (*ctrl).frate, ALL);
dwell=OFF;
if((temp=pause(hardware, software, ms/1000, &(*ctrl).frate))==BREAK)
{gettext(22,19,59,24,buffer);
box(22,19,59,24, RED,BLACK,WHITE,WHITE);
{gotoxy(4,3); cprintf(" Abort?");
gotoxy(4,4); cprintf(" <Y> Yes <N> No");
}
window(1,1,80,25);
while(1)
{ch=getch();
if(ch=='y' || ch=='Y' || ch=='N' || ch=='n') break;
}
puttext(22,19,59,24,buffer);
if(ch=='y' || ch=='y') {init_M00=ON; msg=M0;}
}
if(temp==PAUSE) {init_M00=ON; msg=M0;}
else if(temp==E_STOP) {init_M00=ON; msg=E_STOP;}
break;
case 150: dcycle81=ON; dcycle_init=ON; par=TRUE;
if((*ctrl).cvv==ON) fd_ch=TRUE;
break;
case 151: drilling=ON; ent_holder=ENT_TYPE; ENT_TYPE=LINE_G0_ENT;
if((*ctrl).pty==REL) Z=dcycleR-((*world).z_pos-(*gcode).z_coord[(*ctrl).cs]);
else Z=dcycleR;
new_Z=TRUE; num=152; goto MOVE;
case 152: ENT_TYPE=LINE_ENT;
if((*ctrl).pty==REL) Z=dcycleZ-((*world).z_pos-(*gcode).z_coord[(*ctrl).cs]);
else Z=dcycleZ;
new_Z=TRUE; num=153; goto MOVE;
case 153: ENT_TYPE=LINE_G0_ENT;
if((*ctrl).pty==REL) Z=dcycleR-((*world).z_pos-(*gcode).z_coord[(*ctrl).cs]);
else Z=dcycleR;
new_Z=TRUE; num=154; goto MOVE;
case 154: ENT_TYPE=ent_holder; drilling=OFF;
break;
case 155: dcycle83=ON; dcycle_init=ON; par=TRUE;
if((*ctrl).cvv==ON) fd_ch=TRUE;
break;
case 156: drilling=ON; ent_holder=ENT_TYPE; ENT_TYPE=LINE_G0_ENT;
if((*ctrl).pty==REL) Z=dcycleR-((*world).z_pos-(*gcode).z_coord[(*ctrl).cs]);
else Z=dcycleR;
dtemp=dcycleR; new_Z=TRUE; num=157; goto MOVE;
case 157: ENT_TYPE=LINE_ENT;
if(fabs(dcycleZ-dtemp)>dcycleQ)
{if(dcycleZ-dtemp<0) dtemp=dtemp-dcycleQ;
else dtemp=dtemp+dcycleQ;
num=158;}
else {dtemp=dcycleZ; num=153;}
if((*ctrl).pty==REL) Z=dtemp-((*world).z_pos-(*gcode).z_coord[(*ctrl).cs]);
else Z=dtemp;
new_Z=TRUE; goto MOVE;
case 158: ENT_TYPE=LINE_G0_ENT;
if((*ctrl).pty==REL) Z=dcycleR-((*world).z_pos-(*gcode).z_coord[(*ctrl).cs]);
else Z=dcycleR;
new_Z=TRUE; num=159; goto MOVE;
case 159: ENT_TYPE=LINE_G0_ENT;
if((*ctrl).pty==REL) Z=dtemp-((*world).z_pos-(*gcode).z_coord[(*ctrl).cs]);
else Z=dtemp;
new_Z=TRUE; num=157; goto MOVE;
default: break;
}
return msg;
}
double get_move_val(double *input, double *world, float *cs, double *scale, double *factor, int *pty)
{
if(*pty==ABS) return ((*input-*scale)**factor+*scale)-(*world-*cs);
else return *input**factor;
}
double get_ang(int rot, double x1, double y1, double x2, double y2)
{
double ang1, ang2, ang;
int s;
if((x1==0 && y1==0) || (x2==0 && y2==0)) return 0;
ang1=atan2(y1,x1); ang2=atan2(y2,x2);
ang=(ang2-ang1)*rot; if(ang<0) s=-1; else s=1;
if(fabs(s*ang-2*PI)<.00000001 || s*ang<.00000001) ang=0;
if(ang<=0) return rot*(ang+2*PI);
else return rot*ang;
}
double ang_of(double y, double x)
{
if(y==0 && x==0) return 0;
return atan2(y,x);
}
int break_msg(struct hard_setup *hardware, struct soft_setup *software, float rp, float a_rp,
struct pos *begin, struct pos *pt,
double *x, double *y, double *z, double *a, double *angle, int ent_type)
{
double break_ang=0, break_x, break_y, break_z, break_a;
float sp_limit=0, cur_speed=0, inc=0;
int msg=COMPLETE, msg2=0, ch, type=SLOW, s, temp1;
static BYTE buffer[1000], buffer2[1000];
struct pos stop=*pt;
if(*angle<0) s=-1; else s=1;
if(ent_type==XY_ARC_ENT)
break_ang=*angle-get_ang(s, -*x, -*y, -(*begin).x_pos-*x+(*pt).x_pos, -(*begin).y_pos-*y+(*pt).y_pos);
if(ent_type==YZ_ARC_ENT)
break_ang=*angle-get_ang(s, -*y, -*z, -(*begin).y_pos-*y+(*pt).y_pos, -(*begin).z_pos-*z+(*pt).z_pos);
if(ent_type==ZX_ARC_ENT)
break_ang=*angle-get_ang(s, -*z, -*x, -(*begin).z_pos-*z+(*pt).z_pos, -(*begin).x_pos-*x+(*pt).x_pos);
break_x=*x-((*pt).x_pos-(*begin).x_pos); break_y=*y-((*pt).y_pos-(*begin).y_pos);
break_z=*z-((*pt).z_pos-(*begin).z_pos); break_a=*a-((*pt).a_pos-(*begin).a_pos);
gettext(22,19,59,24,buffer);
box(22,19,59,24, RED,BLACK,WHITE,WHITE);
gotoxy(4,1); cprintf("<<Machine Break>> <Esc>To Abort");
gotoxy(4,3); cprintf("'B'->Continue From Break Point");
gotoxy(4,4); cprintf("'S'->Continue From Entity Start");
gotoxy(10,6); cprintf("Jog(Slow) Inc(%s)",prn_val(0));
for(temp1=0;temp1<6;temp1++) update_display(software, (*pt).x_pos, (*pt).y_pos, (*pt).z_pos, (*pt).a_pos, 0, 0, 0, temp1);
while((ch=getch())!=27)
{if(ch==0) ch=getch()+1000;
switch(ch)
{case 'b':
case 'B':
if(stop.x_pos-(*pt).x_pos!=0 || stop.y_pos-(*pt).y_pos!=0)
{sp_limit=(*hardware).min_vel_z;
msg=move(hardware,software, pt, &cur_speed, &sp_limit,
0, 0, rp-(*pt).z_pos, a_rp-(*pt).a_pos, NULL, LINE_ENT,
0, 0, 0, 0, NULL, LINE_ENT);
if(msg!=COMPLETE) break;
}
sp_limit=HIGH_SPEED;
msg=move(hardware, software, pt, &cur_speed, &sp_limit,
stop.x_pos-(*pt).x_pos, stop.y_pos-(*pt).y_pos, 0, 0, NULL, LINE_ENT,
0, 0, 0, 0, NULL, LINE_ENT);
if(msg!=COMPLETE) break;
sp_limit=(*hardware).min_vel_z;
msg=move(hardware, software, pt, &cur_speed, &sp_limit,
0, 0, stop.z_pos-(*pt).z_pos, stop.a_pos-(*pt).a_pos, NULL, LINE_ENT,
0, 0, 0, 0, NULL, LINE_ENT);
if(msg!=COMPLETE) break;
*x=break_x; *y=break_y; *z=break_z; *a=break_a; *angle=break_ang;
msg2=CONTINUE;
break;
case 's':
case 'S':
if((*begin).x_pos-(*pt).x_pos!=0 || (*begin).y_pos-(*pt).y_pos!=0)
{sp_limit=(*hardware).min_vel_z;
msg=move(hardware,software, pt, &cur_speed, &sp_limit,
0, 0, rp-(*pt).z_pos, a_rp-(*pt).a_pos, NULL, LINE_ENT,
0, 0, 0, 0, NULL, LINE_ENT);
if(msg!=COMPLETE) break;
}
sp_limit=HIGH_SPEED;
msg=move(hardware, software, pt, &cur_speed, &sp_limit,
(*begin).x_pos-(*pt).x_pos, (*begin).y_pos-(*pt).y_pos, 0, 0, NULL, LINE_ENT,
0, 0, 0, 0, NULL, LINE_ENT);
if(msg!=COMPLETE) break;
sp_limit=(*hardware).min_vel_z;
msg=move(hardware, software, pt, &cur_speed, &sp_limit,
0, 0, (*begin).z_pos-(*pt).z_pos, (*begin).a_pos-(*pt).a_pos, NULL, LINE_ENT,
0, 0, 0, 0, NULL, LINE_ENT);
if(msg!=COMPLETE) break;
msg2=CONTINUE;
break;
case 'j':
case 'J':
gotoxy(10,6);
if(type==FAST) {type=SLOW; cprintf("(Slow)");}
else if(type==SLOW) {type=INC; cprintf("(Inc) ");}
else if(type==INC) {type=FAST; cprintf("(Fast)");}
textcolor(WHITE);
break;
case 'i':
case 'I':
gettext(22,19,59,24,buffer2);
box(22,19,59,24, RED,BLACK,WHITE,WHITE);
gotoxy(13,1); cprintf("<Esc> To Exit");
gotoxy(7,3); cprintf("Enter New Jog Increment:");
_setcursortype(_NORMALCURSOR);
gotoxy(16,4); get_value(&inc);
_setcursortype(_NOCURSOR);
puttext(22,19,59,24,buffer2);
gotoxy(25,6); cprintf("(%s)",prn_val(inc));
break;
case 72+1000: //up
case 77+1000: //right
if((ch==72+1000 && (*software).invert_arrows==OFF) || (ch==77+1000 && (*software).invert_arrows==ON))
msg=jog(hardware, software, pt, type, inc, Y_AXIS, POS);
else msg=jog(hardware, software, pt, type, inc, X_AXIS, POS);
break;
case 80+1000: //down
case 75+1000: //left
if((ch==80+1000 && (*software).invert_arrows==OFF) || (ch==75+1000 && (*software).invert_arrows==ON))
msg=jog(hardware, software, pt, type, inc, Y_AXIS, NEG);
else msg=jog(hardware, software, pt, type, inc, X_AXIS, NEG);
break;
case 73+1000: //page up
msg=jog(hardware, software, pt, type, inc, Z_AXIS, POS);
break;
case 81+1000: //page down
msg=jog(hardware, software, pt, type, inc, Z_AXIS, NEG);
break;
case '+':
case '=':
msg=jog(hardware, software, pt, type, inc, A_AXIS, POS);
break;
case '-':
msg=jog(hardware, software, pt, type, inc, A_AXIS, NEG);
break;
}
for(temp1=0;temp1<6;temp1++) update_display(software, (*pt).x_pos, (*pt).y_pos, (*pt).z_pos, (*pt).a_pos, 0, 0, 0, temp1);
if((msg>=X_PLIMIT && msg<=A_NLIMIT) || msg==E_STOP || msg==QUIT) break;
if(msg2==CONTINUE) {msg=COMPLETE; break;}
}
if(ch==27) msg=BREAK;
puttext(22,19,59,24,buffer);
window(1,1,80,25);
return msg;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -