mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-22 13:23:54 +02:00
cngt/cngt.c: added small steps (default) and long steps (with shift)
This commit is contained in:
parent
eb8964da6f
commit
639d9a21df
38
cngt/cngt.c
38
cngt/cngt.c
@ -13,14 +13,17 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "serial.h"
|
||||
#include "getkey.h"
|
||||
|
||||
|
||||
#define MAX_POS 10
|
||||
#define STEP 5 /* xy movement step, 5 mm */
|
||||
#define STEP_Z 1 /* z movement step, 1 mm */
|
||||
#define STEP_XY 5 /* xy movement step, 5 mm */
|
||||
#define STEP_FINE_XY 0.5 /* xy movement fine step, 0.5 mm */
|
||||
#define STEP_Z 1 /* z movement step, 1 mm */
|
||||
#define STEP_FINE_Z 0.1 /* z movement step, 0.1 mm */
|
||||
|
||||
|
||||
static double pos_x[MAX_POS];
|
||||
@ -56,20 +59,30 @@ static void down(void)
|
||||
|
||||
static int do_key(char c)
|
||||
{
|
||||
double step_xy = STEP_FINE_XY;
|
||||
double step_z = STEP_FINE_Z;
|
||||
|
||||
if (isupper(c)) {
|
||||
step_xy = STEP_XY;
|
||||
step_z = STEP_Z;
|
||||
}
|
||||
|
||||
/* Anything but x/y positioning */
|
||||
|
||||
switch (c) {
|
||||
case 'U':
|
||||
case 'u':
|
||||
if (positioning) {
|
||||
cz += STEP_Z;
|
||||
cz += step_z;
|
||||
move();
|
||||
} else {
|
||||
up();
|
||||
}
|
||||
return 0;
|
||||
case 'D':
|
||||
case 'd':
|
||||
if (positioning) {
|
||||
cz -= STEP_Z;
|
||||
cz -= step_z;
|
||||
move();
|
||||
} else {
|
||||
down();
|
||||
@ -87,17 +100,21 @@ static int do_key(char c)
|
||||
up();
|
||||
|
||||
switch (c) {
|
||||
case 'H':
|
||||
case 'h':
|
||||
cx -= STEP;
|
||||
cx -= step_xy;
|
||||
break;
|
||||
case 'J':
|
||||
case 'j':
|
||||
cy -= STEP;
|
||||
cy -= step_xy;
|
||||
break;
|
||||
case 'K':
|
||||
case 'k':
|
||||
cy += STEP;
|
||||
cy += step_xy;
|
||||
break;
|
||||
case 'L':
|
||||
case 'l':
|
||||
cx += STEP;
|
||||
cx += step_xy;
|
||||
break;
|
||||
default:
|
||||
if (positioning)
|
||||
@ -212,7 +229,10 @@ int main(int argc, char **argv)
|
||||
if (positioning)
|
||||
printf("%f %f %f\r\n", cx, cy, cz);
|
||||
}
|
||||
up();
|
||||
|
||||
if (!positioning)
|
||||
up();
|
||||
|
||||
serial_close();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user