indeed an elegant/clever way to find true period.
will try to implement into my pendulum asap
omegas=omega;//save old value
T=t-ts;// period=time differences, not necessary starts from t=0
count=0;//you need to reset the counter, unless you only want to calculate the first period
will update my progress on your forum soon :)