#include #include #include #include #include "enc3.h" #define SYS_ON_BACK MAGENTA #define SYS_ON_TEXT WHITE #define SYS_OFF_BACK CYAN #define SYS_OFF_TEXT WHITE //----------------------------------------------------------------------- void main() { unsigned int x_value; unsigned int y_value; unsigned int z_value; unsigned char index; unsigned char x_index; unsigned char y_index; unsigned char z_index; textbackground(SYS_OFF_BACK); clrscr(); _setcursortype(_NOCURSOR); ENC3_SELECT(0x240); ENC3_INIT_CARD( ENC_X1|ENC_QUADRANT, ENC_X1|ENC_QUADRANT, ENC_X1|ENC_QUADRANT); ENC3_RESET_ENCODER(X_axis); ENC3_RESET_ENCODER(Y_axis); ENC3_RESET_ENCODER(Z_axis); textbackground(SYS_ON_BACK); textcolor(SYS_ON_TEXT); do { x_value = ENC3_GET_ENCODER(X_axis); y_value = ENC3_GET_ENCODER(Y_axis); z_value = ENC3_GET_ENCODER(Z_axis); index = ENC3_GET_INDEX(); x_index = index & 0x01; y_index = (index & 0x02) >> 1; z_index = (index & 0x04) >> 2; gotoxy(15,8); cprintf(" -X- -Y- -Z-"); gotoxy(15,10); cprintf("%6d",x_value); gotoxy(35,10); cprintf("%6d",y_value); gotoxy(55,10); cprintf("%6d",z_value); gotoxy(15,12); cprintf("%6d",x_index); gotoxy(35,12); cprintf("%6d",y_index); gotoxy(55,12); cprintf("%6d",z_index); if ((x_index==1) || (y_index==1) || (z_index==1)) { sound(20); delay(100); nosound(); }; } while (!kbhit()); textbackground(BLACK); clrscr(); gotoxy(1,25); _setcursortype(_NORMALCURSOR); }