@echo off
echo setting the ELO Touch driver that connect on Winbond W627UHG serial port
if "%1" == "5" goto begin
if "%1" == "6" goto begin
if "%1" == "4" goto begin
if "%1" == "3" goto begin
if "%1" == "2" goto begin
if "%1" == "1" goto begin

:Show_help
echo.
echo. Command example: W627UHG.BAT x
echo.     x=1-6 (Setting the driver that use Winbond W627UHG serial port No.x.)
goto Error_Break

:begin
W627UHGI
if errorlevel 1 goto DONE
@echo Find W627UHG device.
call SIOSET.BAT
del  SIOSET.BAT
elodev 2210,0
nomouse
echo.

:CheckCom5
if not "%1" == "5" goto CheckCom6
echo ucomtsr %SIO_COM3IO_HEX% %SIO_COM3IRQ_DEC%
     ucomtsr %SIO_COM3IO_HEX% %SIO_COM3IRQ_DEC%
goto InstallCheck

:CheckCom6
if not "%1" == "6" goto CheckCom4
echo ucomtsr %SIO_COM3IO_HEX% %SIO_COM3IRQ_DEC%
     ucomtsr %SIO_COM3IO_HEX% %SIO_COM3IRQ_DEC%
goto InstallCheck

:CheckCom4
if not "%1" == "4" goto CheckCom3
echo ucomtsr %SIO_COM4IO_HEX% %SIO_COM4IRQ_DEC%
     ucomtsr %SIO_COM4IO_HEX% %SIO_COM4IRQ_DEC%
goto InstallCheck

:CheckCom3
if not "%1" == "3" goto CheckCom2
echo ucomtsr %SIO_COM3IO_HEX% %SIO_COM3IRQ_DEC%
     ucomtsr %SIO_COM3IO_HEX% %SIO_COM3IRQ_DEC%
goto InstallCheck

:CheckCom2
if not "%1" == "1" goto CheckCom1
echo ucomtsr %SIO_COM2IO_HEX% %SIO_COM2IRQ_DEC%
     ucomtsr %SIO_COM2IO_HEX% %SIO_COM2IRQ_DEC%
goto InstallCheck

:CheckCom1
echo ucomtsr %SIO_COM1IO_HEX% %SIO_COM1IRQ_DEC%
     ucomtsr %SIO_COM1IO_HEX% %SIO_COM1IRQ_DEC%
goto InstallCheck


:InstallCheck
if errorlevel 1 goto W627UHGNotFound
if exist ELOGRAPH.CAL goto LoadEloCalib

:NoEloCalib
echo.
echo    Please save ELOCALIB but don't update AUTOEXEC.BAT after next step
echo.
pause
elocalib
monmouse
goto DONE

:LoadEloCalib
echo load elocalib data for mode 105
elocalib -c105,elograph.cal
monmouse
goto DONE

:W627UHGNotFound
echo ###  Error! No find the ELO Touch controller in W627UHG No.%1 serial port  ###
goto DONE

:Error_Break
set errorlevel=1

:DONE
@echo on
