-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
693 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
platform = x86 | ||
|
||
CC = g++ | ||
|
||
ifeq ($(platform), mac32) | ||
CFLAGS += -m32 -framework IOKit -framework CoreFoundation | ||
|
||
endif | ||
|
||
ifeq ($(platform), mac64) | ||
|
||
CFLAGS += -framework IOKit -framework CoreFoundation | ||
endif | ||
|
||
ifeq ($(platform), mac) | ||
CFLAGS += -arch i386 -arch x86_64 -framework IOKit -framework CoreFoundation | ||
|
||
endif | ||
|
||
ifeq ($(platform), x86) | ||
CFLAGS += -ludev | ||
endif | ||
|
||
|
||
ifeq ($(platform), x64) | ||
CFLAGS += -m64 | ||
CFLAGS += -ludev | ||
endif | ||
|
||
ifeq ($(platform), armv5) | ||
CFLAGS += -ludev | ||
endif | ||
|
||
|
||
ifeq ($(platform), armv6) | ||
CFLAGS += -ludev | ||
|
||
endif | ||
|
||
ifeq ($(platform), armv8) | ||
CFLAGS += -ludev | ||
|
||
endif | ||
|
||
all:test_console | ||
test_console: main.cpp | ||
$(CC) main.cpp -o test_console $(CFLAGS) ../../lib/$(platform)/libEAFFocuser.a -I../../include $(CFLAGS) -lpthread | ||
-mkdir -p bin/$(platform)/ | ||
cp test_console bin/$(platform)/ | ||
clean: | ||
rm -f test_console | ||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
#include "stdio.h" | ||
#include "EAF_focuser.h" | ||
#ifdef _WINDOWS | ||
#include <windows.h> | ||
#else | ||
#include <sys/time.h> | ||
#include <unistd.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <signal.h> | ||
|
||
|
||
#define Sleep(a) usleep((a)*1000) | ||
#endif | ||
|
||
bool bRun = true; | ||
void IntHandle(int i) | ||
{ | ||
bRun = false; | ||
} | ||
|
||
int main() | ||
{ | ||
|
||
signal(SIGINT, IntHandle); | ||
int EAF_count = EAFGetNum(); | ||
if(EAF_count <= 0) | ||
{ | ||
printf("no focuser connected, press any key to exit\n"); | ||
getchar(); | ||
return -1; | ||
} | ||
else | ||
printf("attached focuser :\n"); | ||
|
||
EAF_INFO EAFInfo; | ||
|
||
|
||
for(int i = 0; i < EAF_count; i++) | ||
{ | ||
EAFGetID(i, &EAFInfo.ID); | ||
EAFGetProperty(EAFInfo.ID, &EAFInfo); | ||
printf("index %d: %s\n",i, EAFInfo.Name); | ||
} | ||
|
||
printf("\nselect one \n"); | ||
|
||
int EAFIndex, iSelectedID; | ||
scanf("%d", & EAFIndex); | ||
EAFGetID(EAFIndex, &iSelectedID); | ||
|
||
if(EAFOpen(iSelectedID) != EAF_SUCCESS) | ||
{ | ||
printf("open error,are you root?,press any key to exit\n"); | ||
getchar(); | ||
return -1; | ||
} | ||
|
||
float fTemp; | ||
EAFGetTemp(iSelectedID, &fTemp); | ||
printf("temperatur=%g\n", fTemp); | ||
|
||
EAF_ERROR_CODE err; | ||
while(1) | ||
{ | ||
err = EAFGetProperty(iSelectedID, & EAFInfo); | ||
if(err != EAF_ERROR_MOVING ) | ||
break; | ||
Sleep(500); | ||
} | ||
|
||
printf("Max step: %d", EAFInfo.MaxStep); | ||
|
||
bool bMoving = false; | ||
|
||
while(1) | ||
{ | ||
bool pbHandControl; | ||
err = EAFIsMoving(iSelectedID, &bMoving, &pbHandControl); | ||
if(err != EAF_SUCCESS || !bMoving) | ||
break; | ||
Sleep(500); | ||
} | ||
|
||
int currentPos; | ||
EAFGetPosition(iSelectedID, ¤tPos); | ||
printf("\ncurrent position: %d\n", currentPos); | ||
|
||
int targetPos; | ||
char szInput[16]; | ||
printf("\nPlease input target position, type \'q\' to quit:\n"); | ||
while(1) | ||
{ | ||
// safe_flush(stdin); | ||
scanf("%s", szInput); | ||
|
||
if(!strcmp(szInput, "q")) | ||
break; | ||
targetPos = atoi(szInput); | ||
printf("\nmove to: %d\n", targetPos); | ||
|
||
if(targetPos < 0) | ||
continue; | ||
|
||
bRun = true; | ||
err = EAFMove(iSelectedID, targetPos); | ||
if(err == EAF_SUCCESS) | ||
printf("\nMoving..., press CTRL+C to abort\n\n"); | ||
while(1) | ||
{ | ||
if(!bRun) | ||
{ | ||
printf("\nMove is aborted\n"); | ||
EAFStop(iSelectedID); | ||
} | ||
EAFGetPosition(iSelectedID, ¤tPos); | ||
printf("current position: %d\n", currentPos); | ||
|
||
bool pbHandControl; | ||
err = EAFIsMoving(iSelectedID, &bMoving, &pbHandControl); | ||
if(err != EAF_SUCCESS || !bMoving ) | ||
break; | ||
Sleep(500); | ||
} | ||
|
||
printf("\nPlease input target position, type \'q\' to quit:\n"); | ||
|
||
} | ||
EAFClose(iSelectedID); | ||
printf("main function over\n"); | ||
return 0; | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.