VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   5355
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9900
   LinkTopic       =   "Form1"
   ScaleHeight     =   5355
   ScaleWidth      =   9900
   StartUpPosition =   3  'Windows Default
   Begin VB.ListBox List1 
      Height          =   3180
      Left            =   6840
      TabIndex        =   5
      Top             =   1680
      Width           =   2655
   End
   Begin VB.CommandButton Command1 
      Caption         =   "DESNO"
      Height          =   495
      Index           =   1
      Left            =   5040
      TabIndex        =   2
      Top             =   2520
      Width           =   1335
   End
   Begin VB.CommandButton Command1 
      Caption         =   "LEVO"
      Height          =   495
      Index           =   0
      Left            =   3240
      TabIndex        =   1
      Top             =   2520
      Width           =   1335
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   500
      Left            =   7800
      Top             =   600
   End
   Begin VB.Label Label3 
      Caption         =   "Label3"
      Height          =   495
      Left            =   1440
      TabIndex        =   4
      Top             =   3960
      Width           =   1215
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      Caption         =   "Pozicija motorja"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   238
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   300
      Left            =   3923
      TabIndex        =   3
      Top             =   840
      Width           =   2055
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   24
         Charset         =   238
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   555
      Left            =   4800
      TabIndex        =   0
      Top             =   1440
      Width           =   165
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim dolzina As Variant
Dim pozicija, Start, n As Variant
Dim output As Integer
Dim desno, pritisnjen As Boolean
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long


Private Sub Command1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
pritisnjen = True
Select Case Index
    Case 0:
Do Until pritisnjen = False
        'desno = False
        dolzina = dolzina - 0.05
        dolzina = FormatNumber(dolzina, -1, vbTrue, vbFalse, vbTrue)
        pozicija = dolzina * 180
        'Call polozaj
        Label1 = pozicija
        Call motor
        If dolzina = "0,00" Then pritisnjen = False
        Debug.Print pozicija, dolzina, output
        Call gumb
        'For n = 0 To 500000: Next n
Loop
    Case 1:
Do Until pritisnjen = False
        'desno = False
        dolzina = dolzina + 0.05
        dolzina = FormatNumber(dolzina, -1, vbTrue, vbFalse, vbTrue)
        pozicija = dolzina * 180
        'Call polozaj
        Label1 = pozicija
        Call motor
        If dolzina = "1,00" Then pritisnjen = False
        Debug.Print pozicija, dolzina, output
        Call gumb
Loop
        'desno = True
        'dolzina = dolzina + 0.1
        'dolzina = dolzina + 0.1
End Select
        'Debug.Print pritisnjen
'Loop

End Sub

Private Sub Command1_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case Index
    Case 0
    pritisnjen = False
    Case 1
    pritisnjen = False
End Select
End Sub

Private Sub Form_Activate()
pozicija = 90
dolzina = 0.5 'imam idejo!!!!kaksno? bom pokazal ok
desno = True
pritisnjen = False
List1.AddItem (dolzina + 1) & "ms" & vbTab & pozicija & "stopinj"
End Sub

Private Function motor()
n = 0
'Do
    Start = GetTickCount
        Do While GetTickCount < (Start + 30) 'setting bit to 0 (zero) for 30ms
        n = n + 1
            output = 0 'output bit D0 on LPT1
'Label3 = output 'poklicem kasneje OK
        Loop
        List1.AddItem n & "x" & output
    
    n = 0
    Start = GetTickCount
        Do While GetTickCount < (Start + dolzina + 1) 'setting bit to 1 (one) for 1.5ms
        n = n + 1
            output = 1
'Label3 = output
        Loop
        List1.AddItem n & "x" & output
        'DoEvents
'Loop

End Function
Private Function gumb()
If dolzina = "0,00" Then
    Command1(0).Enabled = False
Else
    Command1(0).Enabled = True
End If
If dolzina = "1,00" Then
    Command1(1).Enabled = False
Else
    Command1(1).Enabled = True
End If
List1.AddItem (dolzina + 1) & "ms" & vbTab & pozicija & "stopinj" ' & vbTab & output
End Function
