DrawCircle_X = 100
DrawCircle_Y = 100
DrawCircle_Radius = 10
DrawCircle_Speed = 10

For v1 = 1 To Infinity
	Gosub DrawCircle
Next

Button 1 Text "ppp"


Stop



' =====================================================================
'  STEPPER-MOTORS DRAW CIRCLE
' =====================================================================
Variable Numeric DrawCircle_X 	    ' Center X in mm
Variable Numeric DrawCircle_Y 	    ' Center Y in mm
Variable Numeric DrawCircle_Radius  ' Radius in mm
Variable Numeric DrawCircle_Speed 	' Speed in mm/sec

Variable Numeric DCV1
Variable Numeric DCV2
Variable Numeric DCV3
Variable Numeric DCV4

Label DrawCircle
	' ----------------------------------- test for very low speed
	If DrawCircle_Speed < 0.1
		DrawCircle_Speed = 1
	EndIf
	' ----------------------------------- calc the movement in mm
	DCV3 = DrawCircle_Radius * Math_PI * 2
	' ----------------------------------- calc the loops count
	DCV4 = DCV3 / 0.01 '<<< loop time
	DCV4 = Int(DCV4 / DrawCircle_Speed)
	' ----------------------------------- too much speed ?
	If DCV4 < 16
		DCV4 = 16
	EndIf
	' ----------------------------------- prepare the increments
	DCV1 = 2 * Math_PI / DCV4
	' ----------------------------------- loop for v4 times
	For DCV3 = 0 To DCV4
		' ------------------------------- calc circle
		DCV2 = DCV3 * DCV1
		DestX = DrawCircle_X + DrawCircle_Radius * Sin(DCV2)
		DestY = DrawCircle_Y + DrawCircle_Radius * Cos(DCV2)
		Print DestX + " " + DestY + CRLF
		' ------------------------------- move and wait
		Wait Seconds 0.01 '<<< loop time
	Next
Return

Variable Numeric DestX
Variable Numeric DestY


'WATCH v1
'EXEC DestX = 12
