I have met problems using a timer to control the speed of repetitive shape drawing. It works fine until I use a different trigger to call A_Click (a bit more complex but the same principle.
Pseudo code showing the principle is below.
The purpose of the timer is to delay between each drawing.
After A_Click, a set of 6 drawings are drawn with a delay between them (6 automatic calls to Z_Tick).
When all are drawn the Timer is disabled and other code runs (after Else) doing something with drawings using the same timing as before by calling the A_Click from code instead of the button.
I seem to get later code running outside of the timer causing the sequence to corrupt. I don't understand how there could be a problem via time overlap.
I am trying to avoid using for next delays that will cause other problems.
Any insights or information that I may have misunderstood the use of timers would be welcome.
I cannot post actual code which would really confuse the issue.
[EDIT] It may be that I am recursing without realising it, heaven forbid, it would fry my brain.
Pseudo code showing the principle is below.
The purpose of the timer is to delay between each drawing.
After A_Click, a set of 6 drawings are drawn with a delay between them (6 automatic calls to Z_Tick).
When all are drawn the Timer is disabled and other code runs (after Else) doing something with drawings using the same timing as before by calling the A_Click from code instead of the button.
I seem to get later code running outside of the timer causing the sequence to corrupt. I don't understand how there could be a problem via time overlap.
I am trying to avoid using for next delays that will cause other problems.
Any insights or information that I may have misunderstood the use of timers would be welcome.
I cannot post actual code which would really confuse the issue.
[EDIT] It may be that I am recursing without realising it, heaven forbid, it would fry my brain.
B4X:
Set a suitable time in Z Timer 80mS
Press button A
Sub A_Click
prepare shapes
Count of shapes = 6 (say)
timer Z enable
end sub
Sub Z_Tick
If count > 0 then
count=count-1
draw a shape
set new position
else
Timer Z disable
do any number of things, timer is off
...
do something to trigger Click A
end if
end sub
Last edited: