Author Topic: USING DLL FOR C++ IN QB64  (Read 3596 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline RUSSELL

  • Newbie
  • Posts: 3
    • View Profile
USING DLL FOR C++ IN QB64
« on: August 06, 2020, 06:35:56 pm »
$RESIZE:SMOOTH
DECLARE DYNAMIC LIBRARY "ASICamera2"
    FUNCTION ASIGetNumOfConnectedCameras& () REM
    FUNCTION ASIOpenCamera& (BYVAL iCameraID AS INTEGER)
    FUNCTION ASIGetID& (BYVAL iCameraID AS INTEGER, BYVAL pID AS _OFFSET)
    FUNCTION ASICloseCamera& (BYVAL iCameraID AS INTEGER)
    FUNCTION ASIGetCameraProperty& (BYVAL info AS _OFFSET, BYVAL id AS INTEGER)
    FUNCTION ASIStartExposure& (BYVAL iCameraID AS INTEGER)
    FUNCTION ASIStopExposure& (BYVAL iCameraID AS INTEGER)
    FUNCTION ASIGetDataAfterExp& (BYVAL iCameraID AS INTEGER, BYVAL buffer AS _OFFSET, BYVAL buffersize AS LONG)
    FUNCTION ASIInitCamera& (BYVAL iCameraID AS INTEGER)
END DECLARE

DECLARE DYNAMIC LIBRARY "EFW_filter"
    FUNCTION EFWGetNum& () REM   int EFWGetNum()     return number of filter wheels
    FUNCTION EFWOpen& (BYVAL a AS INTEGER) REM    EFW_ERROR_CODE EFWOpen(int ID)
    FUNCTION EFWGetID& (BYVAL a AS INTEGER, BYVAL i AS _OFFSET) REM int index: the index of filter wheel, from 0 to N - 1, N is returned by EFWGetNum()
    FUNCTION EFWSetPosition& (BYVAL i AS INTEGER, BYVAL p AS INTEGER)
    FUNCTION EFWClose& (BYVAL i AS INTEGER) REM  EFW_ERROR_CODE EFWClose(int ID)
    FUNCTION EFWGetProperty& (BYVAL i AS INTEGER, BYVAL info AS _OFFSET) REM EFW_ERROR_CODE EFWGetProperty(int ID, EFW_INFO *pInfo)
    FUNCTION EFWGetPosition& (BYVAL i AS INTEGER, BYVAL p AS _OFFSET)
END DECLARE
DECLARE CUSTOMTYPE LIBRARY
    SUB memcpy (BYVAL dest AS _OFFSET, BYVAL source AS _OFFSET, BYVAL bytes AS LONG)

END DECLARE

DIM SHARED ap AS _OFFSET
CONST BUFFERSIZE = 16389120
CONST TRUE = 1
CONST FALSE = 0
DEFINT A-Z

TYPE efwinfo
    ID AS STRING * 4
    EFWname AS STRING * 64
    slotnumber AS STRING * 4
END TYPE
TYPE camerainfo
    NM AS STRING * 64
    ID AS STRING * 4
    MAXH AS STRING * 4
    MAXL AS STRING * 4
    ISCOLOR AS STRING * 1
    BAYER AS STRING * 4
    SUPPORTBIN AS STRING * 64
    IMAGETYPE AS STRING * 8
    PIXELSIZE AS STRING * 8
    ISSHUTTER AS _BIT * 1
    ST4PORT AS _BIT * 1
    ISCOOL AS _BIT * 1
    ISUSB3HOST AS _BIT * 1
    ISUSBCAMERA AS _BIT * 1

    ELEEPERADU AS STRING * 4
    BITDEPTH AS STRING * 4
    TRIGGER AS _BIT * 1
    UNUSED AS STRING * 16
END TYPE

TYPE ASIBUFF
    BUFF AS STRING * BUFFERSIZE
END TYPE


DIM SHARED cinfo AS camerainfo
DIM SHARED finfo AS efwinfo
DIM SHARED CID AS INTEGER
DIM SHARED MYBUFF AS ASIBUFF
DIM SHARED CX AS INTEGER
DIM SHARED CY AS INTEGER

IF ASIGetNumOfConnectedCameras > FALSE THEN cerror (ASIGetCameraProperty(_OFFSET(cinfo), 0)): memcpy _OFFSET(CID), _OFFSET(cinfo.ID), 4: cerror (ASIOpenCamera(CID)): ELSE cerror (ASICloseCamera(CID)): cerror (1)
cerror (ASIInitCamera(CID))
REM get sensor size
memcpy _OFFSET(CX), _OFFSET(cinfo.MAXL), 4
memcpy _OFFSET(CY), _OFFSET(cinfo.MAXH), 4


DIM SHARED C&
DIM SHARED S&

REM display  screen size
DIM SX AS _UNSIGNED INTEGER
DIM SY AS _UNSIGNED INTEGER
SX = 1024: SY = 768
C& = _NEWIMAGE(CX, CY, 32)
S& = _NEWIMAGE(SX, SY, 32)


SCREEN S&
_DEST C&
DIM pix AS _UNSIGNED _BYTE

DIM OC AS _UNSIGNED LONG



WHILE (1)

    takephoto
    REM PCOPY C&, S&

    _PUTIMAGE (0, 0)-(SX * .5, SY * .5), C&, 0, (0, 0)-(CX, CY)
WEND
END
startfw: REM start filter


filterdisplay
FOR X = 0 TO 10


    filterslot (RND * 8 + 1)
    filterdisplay


NEXT X
ferror (EFWClose(ASC(finfo.ID)))
END

SUB filterslot (slot)
    IF ASC(finfo.ID) > -1 THEN fwinfo.werror = EFWSetPosition(ASC(finfo.ID), slot - 1)
    WHILE (EFWSetPosition(ASC(finfo.ID), slot - 1) > 0)
        SLEEP 1
    WEND
END SUB

SUB startfw ()
    IF EFWGetNum - 1 < 0 THEN PRINT "no filter": efwinfo.ID = -1
    IF efwinfo.ID > -1 THEN ferror (EFWGetID(0, _OFFSET(efwinfo.ID))): ferror (EFWOpen(INT(ASC(finfo.ID)))): ferror (EFWGetProperty(ASC(finfo.ID), _OFFSET(finfo)))
END SUB

SUB filterdisplay
    ferror (EFWGetPosition(efwinfo.ID, _OFFSET(P)))
    LOCATE 7, 12
    PRINT "Filter Pseition"; P + 1
END SUB

SUB cerror (E)
    IF E = 1 THEN PRINT "no camera connected or index value out of boundary": SLEEP: END
    IF E = 2 THEN PRINT "INVALID ID": SLEEP: END
    IF E = 3 THEN PRINT "INVALID CONTROL TYPE": SLEEP: END
    IF E = 4 THEN PRINT "CAMERA DID NOT OPEN": SLEEP: END
    IF E = 5 THEN PRINT "UNABLE TO FIND CAMERA": SLEEP: END
    IF E = 6 THEN PRINT "COULD NOT FIND PATH OF FILE": SLEEP: END
    IF E = 7 THEN PRINT "INVALID FILE FORMAT": SLEEP: END
    IF E = 8 THEN PRINT "WRONG VIDEO FORMAT SIZE": SLEEP: END
    IF E = 9 THEN PRINT "UNSUPPORTED IMAGE FORMAT": SLEEP: END
    IF E = 10 THEN PRINT "THE START POSITION OUT SIDE BOUNDARY": SLEEP: END
    IF E = 11 THEN PRINT "TIME OUT": SLEEP: END
    IF E = 12 THEN PRINT "STOP CAPTURE FIRST": SLEEP: END
    IF E = 13 THEN PRINT "BUFFER NOT BIG ENOUGH": SLEEP: END
    IF E = 14 THEN PRINT "VIDEO_MODE_ACTIVE": SLEEP: END
    IF E = 15 THEN PRINT "EXPOSURE_IN_PROGRESS": SLEEP: END
    IF E = 16 THEN PRINT "GENERAL ERROR": SLEEP: END
    IF E = 17 THEN PRINT "ERROR END": SLEEP: END
END SUB
SUB ferror (E)
    IF E = 1 THEN PRINT "INVALID INDEX": SLEEP: END
    IF E = 2 THEN PRINT "INVALID ID": SLEEP: END
    IF E = 3 THEN PRINT "INVALID VALUE": SLEEP: END

    IF E = 4 THEN PRINT "CLOSED": SLEEP: END
    REM IF E = 5 THEN PRINT "UNABLE TO FIND FILTER WHEEL": SLEEP: END
    IF E = 5 THEN PRINT "FILTER WHEEL MOVING": SLEEP: END
    IF E = 7 THEN PRINT "OTHER ERROR": SLEEP: END
    IF E = 8 THEN PRINT "CLOSED": SLEEP: END
    IF E = -1 THEN PRINT "END": SLEEP: END
END SUB

SUB takephoto ()
    DIM PIX AS INTEGER
    amp = 1: m = 1: nh = 0
    DIM os AS LONG
    cerror (ASIStartExposure(CID))

    SLEEP 1

    REM PRINT _OFFSET(MYBUFF.BUFF), CX, CY
    REM GOTO over
    cerror (ASIStopExposure(CID))
    cerror (ASIGetDataAfterExp(CID, _OFFSET(MYBUFF.BUFF), BUFFERSIZE))

    os = 0
    FOR Y = 0 TO CY - 1
        FOR X = 0 TO CX - 1
            memcpy _OFFSET(PIX), _OFFSET(MYBUFF.BUFF) + os, 1: os = os + 1
            PIX = PIX * m
            PSET (X, Y), _RGB(PIX, PIX, PIX): REM 8 bit per pixel

        NEXT X
    NEXT Y


    over:
END SUB
« Last Edit: August 20, 2020, 02:37:51 pm by RUSSELL »

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: USING DLL FOR C++ IN QB64
« Reply #1 on: August 06, 2020, 09:51:58 pm »
Hi @RUSSELL, welcome to the forum! 

I don't know why the program is crashing, but one thing I see in the code you posted is that there is more than one i variable being used - i and i&.  Those will hold different values.  If that is not meant then perhaps an incorrect i (or i&) value is a problem for the function call.

Instead calling: er = EFWGetID(n, i&), try this: er = EFWGetID(n, i) and see if that works.

I'm sorry that is all I can suggest.  Maybe someone else will offer better help. 

Good luck!

- Dav
« Last Edit: August 06, 2020, 10:11:54 pm by Dav »

Offline RUSSELL

  • Newbie
  • Posts: 3
    • View Profile
Re: USING DLL FOR C++ IN QB64
« Reply #2 on: August 07, 2020, 01:44:53 pm »
DECLARE DYNAMIC LIBRARY "ASICamera2"
    FUNCTION ASIGetNumOfConnectedCameras& () REM
    FUNCTION ASIOpenCamera& (BYVAL iCameraID AS INTEGER)
    FUNCTION ASIGetID& (BYVAL iCameraID AS INTEGER, BYVAL pID AS _OFFSET)
    FUNCTION ASICloseCamera& (BYVAL iCameraID AS INTEGER)
    FUNCTION ASIGetCameraProperty& (BYVAL info AS _OFFSET, BYVAL id AS INTEGER)
END DECLARE

DECLARE DYNAMIC LIBRARY "EFW_filter"
    FUNCTION EFWGetNum& () REM   int EFWGetNum()     return number of filter wheels
    FUNCTION EFWOpen& (BYVAL a AS INTEGER) REM    EFW_ERROR_CODE EFWOpen(int ID)
    FUNCTION EFWGetID& (BYVAL a AS INTEGER, BYVAL i AS _OFFSET) REM int index: the index of filter wheel, from 0 to N - 1, N is returned by EFWGetNum()
    FUNCTION EFWSetPosition& (BYVAL i AS INTEGER, BYVAL p AS INTEGER)
    FUNCTION EFWClose& (BYVAL i AS INTEGER) REM  EFW_ERROR_CODE EFWClose(int ID)
    FUNCTION EFWGetProperty& (BYVAL i AS INTEGER, BYVAL info AS _OFFSET) REM EFW_ERROR_CODE EFWGetProperty(int ID, EFW_INFO *pInfo)
END DECLARE
DECLARE CUSTOMTYPE LIBRARY
    SUB memcpy (BYVAL dest AS _OFFSET, BYVAL source AS _OFFSET, BYVAL bytes AS LONG)
END DECLARE

DEFINT A-Z

TYPE efwinfo
    ID AS STRING * 4
    EFWname AS STRING * 64
    number AS STRING * 4
    ewrror AS INTEGER
    numbers AS INTEGER
END TYPE
TYPE camerainfo
    nm AS STRING * 64
    ID AS STRING * 4
    MAXH AS STRING * 4
    MAXL AS STRING * 4
    ISCOLOR AS STRING * 1
    BAYER AS STRING * 1
    SUPPORTBIN AS STRING * 16
    IMAGETYPE AS STRING * 8
    PIGELSIZE AS STRING * 8
    ISSHUTTER AS STRING * 1
    ST4PORT AS STRING * 1
    ISCOOL AS STRING * 1
    ELEEPERADU AS STRING * 4
    BITDEPTH AS STRING * 4
    TRIGGER AS STRING * 1
    UNUSED AS STRING * 16
END TYPE

TYPE ASI_ID

    id AS STRING * 8
END TYPE


DIM SHARED cinfo AS camerainfo
DIM SHARED finfo AS efwinfo
DIM SHARED asiid AS ASI_ID


DIM BIN(8) AS INTEGER
IF ASIGetNumOfConnectedCameras > 0 THEN CERROR (ASIGetCameraProperty(_OFFSET(cinfo), 0)) REM OPEN  FIRST CAMERA

memcpy _OFFSET(SX), _OFFSET(cinfo.MAXL), 4
memcpy _OFFSET(SY), _OFFSET(cinfo.MAXH), 4

REM memcpy _OFFSET(BIN(0)), _OFFSET(cinfo.SUPPORTBIN), 16
REM FOR Z = 0 TO 7
REM PRINT BIN(Z)
REM NEXT Z
PRINT SX, SY, cinfo.SUPPORTBIN: SLEEP: END
IF EFWGetNum THEN CERROR (ASIOpenCamera(0)): CERROR (ASICloseCamera(0)) ELSE CERROR (1)

startfw



FOR x = 0 TO ASC(finfo.number) - 1

    efwinfo.werror = EFWSetPosition(i, x)
    PRINT "FILTER", x + 1
    SLEEP 4
NEXT x
ferror (EFWClose(ASC(finfo.ID)))
END

SUB startfw ()

    IF EFWGetNum - 1 < 0 THEN PRINT "no filter": END
    ferror (EFWGetID(0, _OFFSET(efwinfo.ID)))
    ferror (EFWOpen(INT(ASC(finfo.ID))))
    ferror (EFWGetProperty(ASC(finfo.ID), _OFFSET(finfo)))

END SUB
SUB CERROR (E)
    IF E = 1 THEN PRINT "no camera connected or index value out of boundary": SLEEP: END
    IF E = 2 THEN PRINT "INVALID ID": SLEEP: END
    IF E = 3 THEN PRINT "INVALID CONTROL TYPE": SLEEP: END
    IF E = 4 THEN PRINT "CAMERA DID NOT OPEN": SLEEP: END
    IF E = 5 THEN PRINT "UNABLE TO FIND CAMERA": SLEEP: END
    IF E = 6 THEN PRINT "COULD NOT FIND PATH OF FILE": SLEEP: END
    IF E = 7 THEN PRINT "INVALID FILE FORMAT": SLEEP: END
    IF E = 8 THEN PRINT "WRONG VIDEO FORMAT SIZE": SLEEP: END
    IF E = 9 THEN PRINT "UNSUPPORTED IMAGE FORMAT": SLEEP: END
    IF E = 10 THEN PRINT "THE START POSITION OUT SIDE BOUNDARY": SLEEP: END
    IF E = 11 THEN PRINT "TIME OUT": SLEEP: END
    IF E = 12 THEN PRINT "STOP CAPTURE FIRST": SLEEP: END
    IF E = 13 THEN PRINT "BUFFER NOT BIG ENOUGH": SLEEP: END
    IF E = 14 THEN PRINT "VIDEO_MODE_ACTIVE": SLEEP: END
    IF E = 15 THEN PRINT "EXPOSURE_IN_PROGRESS": SLEEP: END
    IF E = 16 THEN PRINT "GENERAL ERROR": SLEEP: END
    IF E = 17 THEN PRINT "ERROR END": SLEEP: END
END SUB
SUB ferror (E)
    IF E = 1 THEN PRINT "INVALID INDEX": SLEEP: END
    IF E = 2 THEN PRINT "INVALID ID": SLEEP: END
    IF E = 3 THEN PRINT "INVALID VALUE": SLEEP: END
    IF E = 4 THEN PRINT "NOT OPEN": SLEEP: END
    IF E = 5 THEN PRINT "UNABLE TO FIND FILTER WHEEL": SLEEP: END
    IF E = 6 THEN PRINT "FILTER WHEEL MOVING": SLEEP: END
    IF E = 7 THEN PRINT "OTHER ERROR": SLEEP: END
    IF E = 8 THEN PRINT "CLOSED": SLEEP: END
    IF E = -1 THEN PRINT "END": SLEEP: END
END SUB
I am not a pro when it comes to programing but when this is done I hope to be able create a  sequence generator this will control a filter wheel and camera to create light frames and dark frames at different time exposers.
« Last Edit: August 16, 2020, 08:50:47 pm by RUSSELL »

Marked as best answer by RUSSELL on August 18, 2020, 05:24:01 pm

Offline RUSSELL

  • Newbie
  • Posts: 3
    • View Profile
Re: USING DLL FOR C++ IN QB64
« Reply #3 on: August 18, 2020, 09:11:40 pm »
$RESIZE:SMOOTH
DECLARE DYNAMIC LIBRARY "ASICamera2"
    FUNCTION ASIGetNumOfConnectedCameras& () REM
    FUNCTION ASIOpenCamera& (BYVAL iCameraID AS INTEGER)
    FUNCTION ASIGetID& (BYVAL iCameraID AS INTEGER, BYVAL pID AS _OFFSET)
    FUNCTION ASICloseCamera& (BYVAL iCameraID AS INTEGER)
    FUNCTION ASIGetCameraProperty& (BYVAL info AS _OFFSET, BYVAL id AS INTEGER)
    FUNCTION ASIStartExposure& (BYVAL iCameraID AS INTEGER)
    FUNCTION ASIStopExposure& (BYVAL iCameraID AS INTEGER)
    FUNCTION ASIGetDataAfterExp& (BYVAL iCameraID AS INTEGER, BYVAL buffer AS _OFFSET, BYVAL buffersize AS LONG)
    FUNCTION ASIInitCamera& (BYVAL iCameraID AS INTEGER)
END DECLARE

DECLARE DYNAMIC LIBRARY "EFW_filter"
    FUNCTION EFWGetNum& () REM   int EFWGetNum()     return number of filter wheels
    FUNCTION EFWOpen& (BYVAL a AS INTEGER) REM    EFW_ERROR_CODE EFWOpen(int ID)
    FUNCTION EFWGetID& (BYVAL a AS INTEGER, BYVAL i AS _OFFSET) REM int index: the index of filter wheel, from 0 to N - 1, N is returned by EFWGetNum()
    FUNCTION EFWSetPosition& (BYVAL i AS INTEGER, BYVAL p AS INTEGER)
    FUNCTION EFWClose& (BYVAL i AS INTEGER) REM  EFW_ERROR_CODE EFWClose(int ID)
    FUNCTION EFWGetProperty& (BYVAL i AS INTEGER, BYVAL info AS _OFFSET) REM EFW_ERROR_CODE EFWGetProperty(int ID, EFW_INFO *pInfo)
    FUNCTION EFWGetPosition& (BYVAL i AS INTEGER, BYVAL p AS _OFFSET)
END DECLARE
DECLARE CUSTOMTYPE LIBRARY
    SUB memcpy (BYVAL dest AS _OFFSET, BYVAL source AS _OFFSET, BYVAL bytes AS LONG)

END DECLARE

DIM SHARED ap AS _OFFSET
CONST BUFFERSIZE = 16389120
CONST TRUE = 1
CONST FALSE = 0
DEFINT A-Z

TYPE efwinfo
    ID AS STRING * 4
    EFWname AS STRING * 64
    slotnumber AS STRING * 4
END TYPE
TYPE camerainfo
    NM AS STRING * 64
    ID AS STRING * 4
    MAXH AS STRING * 4
    MAXL AS STRING * 4
    ISCOLOR AS STRING * 1
    BAYER AS STRING * 4
    SUPPORTBIN AS STRING * 64
    IMAGETYPE AS STRING * 8
    PIXELSIZE AS STRING * 8
    ISSHUTTER AS _BIT * 1
    ST4PORT AS _BIT * 1
    ISCOOL AS _BIT * 1
    ISUSB3HOST AS _BIT * 1
    ISUSBCAMERA AS _BIT * 1

    ELEEPERADU AS STRING * 4
    BITDEPTH AS STRING * 4
    TRIGGER AS _BIT * 1
    UNUSED AS STRING * 16
END TYPE

TYPE ASIBUFF
    BUFF AS STRING * BUFFERSIZE
END TYPE


DIM SHARED cinfo AS camerainfo
DIM SHARED finfo AS efwinfo
DIM SHARED CID AS INTEGER
DIM SHARED MYBUFF AS ASIBUFF
DIM SHARED CX AS INTEGER
DIM SHARED CY AS INTEGER

IF ASIGetNumOfConnectedCameras > FALSE THEN cerror (ASIGetCameraProperty(_OFFSET(cinfo), 0)): memcpy _OFFSET(CID), _OFFSET(cinfo.ID), 4: cerror (ASIOpenCamera(CID)): ELSE cerror (ASICloseCamera(CID)): cerror (1)
cerror (ASIInitCamera(CID))
REM get sensor size
memcpy _OFFSET(CX), _OFFSET(cinfo.MAXL), 4
memcpy _OFFSET(CY), _OFFSET(cinfo.MAXH), 4


DIM SHARED C&
DIM SHARED S&

REM display  screen size
DIM SX AS _UNSIGNED INTEGER
DIM SY AS _UNSIGNED INTEGER
SX = 1024: SY = 768
C& = _NEWIMAGE(CX, CY, 32)
S& = _NEWIMAGE(SX, SY, 32)


SCREEN S&
_DEST C&
DIM pix AS _UNSIGNED _BYTE

DIM OC AS _UNSIGNED LONG



WHILE (1)

    takephoto
    REM PCOPY C&, S&

    _PUTIMAGE (0, 0)-(SX * .5, SY * .5), C&, 0, (0, 0)-(CX, CY)
WEND
END
startfw: REM start filter


filterdisplay
FOR X = 0 TO 10


    filterslot (RND * 8 + 1)
    filterdisplay


NEXT X
ferror (EFWClose(ASC(finfo.ID)))
END

SUB filterslot (slot)
    IF ASC(finfo.ID) > -1 THEN fwinfo.werror = EFWSetPosition(ASC(finfo.ID), slot - 1)
    WHILE (EFWSetPosition(ASC(finfo.ID), slot - 1) > 0)
        SLEEP 1
    WEND
END SUB

SUB startfw ()
    IF EFWGetNum - 1 < 0 THEN PRINT "no filter": efwinfo.ID = -1
    IF efwinfo.ID > -1 THEN ferror (EFWGetID(0, _OFFSET(efwinfo.ID))): ferror (EFWOpen(INT(ASC(finfo.ID)))): ferror (EFWGetProperty(ASC(finfo.ID), _OFFSET(finfo)))
END SUB

SUB filterdisplay
    ferror (EFWGetPosition(efwinfo.ID, _OFFSET(P)))
    LOCATE 7, 12
    PRINT "Filter Pseition"; P + 1
END SUB

SUB cerror (E)
    IF E = 1 THEN PRINT "no camera connected or index value out of boundary": SLEEP: END
    IF E = 2 THEN PRINT "INVALID ID": SLEEP: END
    IF E = 3 THEN PRINT "INVALID CONTROL TYPE": SLEEP: END
    IF E = 4 THEN PRINT "CAMERA DID NOT OPEN": SLEEP: END
    IF E = 5 THEN PRINT "UNABLE TO FIND CAMERA": SLEEP: END
    IF E = 6 THEN PRINT "COULD NOT FIND PATH OF FILE": SLEEP: END
    IF E = 7 THEN PRINT "INVALID FILE FORMAT": SLEEP: END
    IF E = 8 THEN PRINT "WRONG VIDEO FORMAT SIZE": SLEEP: END
    IF E = 9 THEN PRINT "UNSUPPORTED IMAGE FORMAT": SLEEP: END
    IF E = 10 THEN PRINT "THE START POSITION OUT SIDE BOUNDARY": SLEEP: END
    IF E = 11 THEN PRINT "TIME OUT": SLEEP: END
    IF E = 12 THEN PRINT "STOP CAPTURE FIRST": SLEEP: END
    IF E = 13 THEN PRINT "BUFFER NOT BIG ENOUGH": SLEEP: END
    IF E = 14 THEN PRINT "VIDEO_MODE_ACTIVE": SLEEP: END
    IF E = 15 THEN PRINT "EXPOSURE_IN_PROGRESS": SLEEP: END
    IF E = 16 THEN PRINT "GENERAL ERROR": SLEEP: END
    IF E = 17 THEN PRINT "ERROR END": SLEEP: END
END SUB
SUB ferror (E)
    IF E = 1 THEN PRINT "INVALID INDEX": SLEEP: END
    IF E = 2 THEN PRINT "INVALID ID": SLEEP: END
    IF E = 3 THEN PRINT "INVALID VALUE": SLEEP: END

    IF E = 4 THEN PRINT "CLOSED": SLEEP: END
    REM IF E = 5 THEN PRINT "UNABLE TO FIND FILTER WHEEL": SLEEP: END
    IF E = 5 THEN PRINT "FILTER WHEEL MOVING": SLEEP: END
    IF E = 7 THEN PRINT "OTHER ERROR": SLEEP: END
    IF E = 8 THEN PRINT "CLOSED": SLEEP: END
    IF E = -1 THEN PRINT "END": SLEEP: END
END SUB

SUB takephoto ()
    DIM PIX AS INTEGER
    amp = 1: m = 1: nh = 0
    DIM os AS LONG
    cerror (ASIStartExposure(CID))

    SLEEP 1

    REM PRINT _OFFSET(MYBUFF.BUFF), CX, CY
    REM GOTO over
    cerror (ASIStopExposure(CID))
    cerror (ASIGetDataAfterExp(CID, _OFFSET(MYBUFF.BUFF), BUFFERSIZE))

    os = 0
    FOR Y = 0 TO CY - 1
        FOR X = 0 TO CX - 1
            memcpy _OFFSET(PIX), _OFFSET(MYBUFF.BUFF) + os, 1: os = os + 1
            PIX = PIX * m
            PSET (X, Y), _RGB(PIX, PIX, PIX): REM 8 bit per pixel

        NEXT X
    NEXT Y


    over:
END SUB
« Last Edit: August 20, 2020, 02:40:11 pm by RUSSELL »