RTTTL Repeat

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
Ath
Normal user
Posts: 3513
Joined: 10 Jun 2018, 12:06
Location: NL

Re: RTTTL Repeat

#1 Post by Ath » 30 Nov 2020, 12:23

Assuming you already send an event to play the rtttl sequence, you can set a timer (or a looptimer, only need to set it once), that timer is then to be reset to 0 once MQTT sends an event to stop the sound.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3513
Joined: 10 Jun 2018, 12:06
Location: NL

Re: RTTTL Repeat

#2 Post by Ath » 30 Nov 2020, 13:26

Possible solution (Rules and Old engine must be enabled on Tools/Advanced page)

Code: Select all

on StartAlarm do
  rtttl,... // whatever sequence you want
  if %v1%=0
    TimerSet,1,5 // Repeat after 5 seconds silence
  else
    Let,1,0 // re-arm for next MQTT StartAlarm
  endif
endon

on System#Timer=1 do
  AsyncEvent,StartAlarm // Add to event queue
endon

on StopAlarm do
  Let,1,1 // Stop repeat, current rtttl sequence will continue until completed
endon

/Ton (PayPal.me)

TD-er
Core team member
Posts: 8749
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: RTTTL Repeat

#3 Post by TD-er » 30 Nov 2020, 14:14

Playing RTTTL is blocking code.
So it is better to set various PWM values based on a loop timer.

See looptimer_ms: https://espeasy.readthedocs.io/en/lates ... =looptimer

The PWM pulsing will continue after you set it, until you change it.
So in the loop timer you can toggle between values like @Ath showed in his example and based on the toggling of a value you can set a new frequency.

Post Reply

Who is online

Users browsing this forum: No registered users and 68 guests