Attribute VB_Name = "Module1"
' Note: 06/06/2002 Do not pass integers as they do not work only longs
' Note: 06/06/2002 Pass numeric arrays ByRef and strings ByVal

Global ProgPath$            ' path program was executed from
Global ProgBase$            ' Root name of program
Global OpenStat As Long    ' Returned status of open application

Public TempNow As Long
Public TempHi As Long
Public TempLo As Long
Public TempCfg As Long
Public TempChannel As Long
Public anaType(8) As Long

'Humidity public variable
Public Hum_current As Double

Declare Function vbapp_Open Lib "prvapp_EnvFan.dll" (ByVal VBioChannel As Long) As Long
Declare Sub vbapp_Close Lib "prvapp_EnvFan.dll" ()
Declare Sub vbapp_LedOn Lib "prvapp_EnvFan.dll" ()
Declare Sub vbapp_LedOff Lib "prvapp_EnvFan.dll" ()
Declare Function vbapp_Read Lib "prvapp_EnvFan.dll" (ByVal Offset As Long) As Long
Declare Sub vbapp_Write Lib "prvapp_EnvFan.dll" (ByVal Offset As Long, ByVal value As Long)
Declare Function vbapp_Test Lib "prvapp_EnvFan.dll" (ByVal value As Long) As Long
Declare Function vbapp_Version Lib "prvapp_EnvFan.dll" () As Long

Declare Function envFan Lib "prvapp_EnvFan.dll" (ByVal State As Long) As Long
Declare Function envDiagLED Lib "prvapp_EnvFan.dll" (ByVal State As Long) As Long
Declare Function envReadCfg Lib "prvapp_EnvFan.dll" () As Long
Declare Function envReadDig Lib "prvapp_EnvFan.dll" () As Long
Declare Function envSetDig Lib "prvapp_EnvFan.dll" (ByVal val As Long) As Long
Declare Function envSetEnables Lib "prvapp_EnvFan.dll" (ByVal val As Long) As Long
Declare Function envReadAna Lib "prvapp_EnvFan.dll" (ByVal channel As Long) As Long

Declare Sub envInitTemp Lib "prvapp_EnvFan.dll" (ByVal ch As Long)
Declare Sub envReadTemp Lib "prvapp_EnvFan.dll" (ByRef TempNow As Long, ByRef TempHi As Long, ByRef TempLo As Long, ByRef TempCfg As Long, ByVal ch As Long)
Declare Sub envWriteTemp Lib "prvapp_EnvFan.dll" (ByVal TempHi As Long, ByVal TempLo As Long, ByVal ch As Long)

Const MAX_IO = 7            ' 8 - 1 for BASIC arrays upperbound
Const MAX_MEM = 7

Type PRVDRV_RANGES
    nRanges As Long
    nIo As Long
    nMem As Long
    ioBase(MAX_IO) As Long
    ioBytes(MAX_IO) As Long
    ioOffset(MAX_IO) As Long
    memBase(MAX_MEM) As Long
    memBytes(MAX_MEM) As Long
    memOffset(MAX_MEM) As Long
End Type

' -------------------------
' Declare the dll functions
' -------------------------
Public range As PRVDRV_RANGES
Declare Sub vbapp_CardRangesL Lib "prvapp_EnvFan.dll" ( _
        ByRef nRanges As Long, _
        ByRef nIo As Long, _
        ByRef nMem As Long, _
        ioBase As Long, _
        ioBytes As Long, _
        ioOffset As Long, _
        memBase As Long, _
        memBytes As Long, _
        memOffset As Long)

Public Sub vbdrv_GetCardInfo()
    If OpenStat = 2 Then
        Call vbapp_CardRangesL( _
            range.nRanges, _
            range.nIo, _
            range.nMem, _
            range.ioBase(0), _
            range.ioBytes(0), _
            range.ioOffset(0), _
            range.memBase(0), _
            range.memBytes(0), _
            range.memOffset(0))
        End If
End Sub


