diff --git a/cngt/cngt.c b/cngt/cngt.c index f67a341..275f5a0 100644 --- a/cngt/cngt.c +++ b/cngt/cngt.c @@ -13,14 +13,17 @@ #include #include +#include #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; }