Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Tested Wait Method...

150 views
Skip to first unread message

Rostislav Persion

unread,
Mar 22, 2016, 7:10:46 PM3/22/16
to MIT App Inventor Forum
I finally tested my wait method... it works but it locks up the system... Does anyone know how to do a "DoEvents" in the delay loop? In VB6 and C# there was a DoEvents method that let the system do stuff while your app was in a loop....
WaitTest.aia

Scott Ferguson

unread,
Mar 22, 2016, 7:15:23 PM3/22/16
to MIT App Inventor Forum
Yes. Put the blocks to be executed inside a Clock Timer event block.
---

Rostislav Persion

unread,
Mar 22, 2016, 7:41:58 PM3/22/16
to MIT App Inventor Forum
I was trying to make an app that converts SMS messages to morse code... it would be very hard to do this with a timer...

Taifun

unread,
Mar 22, 2016, 8:21:14 PM3/22/16
to MIT App Inventor Forum
what about reading the answers in your other threads?

a wait method, which locks the system is probably not the best solution, is it?
how many other threads do you want to post about that "solution"?

I was trying to make an app that converts SMS messages to morse code... it would be very hard to do this with a timer...
why? message is coming in in the Message Received event, then convert then message and display it
you do not need a clock component at all

Taifun

Abraham Getzler

unread,
Mar 22, 2016, 10:08:21 PM3/22/16
to MIT App Inventor Forum
What do you want to do with the Morse code?  Sound it out?
Record a few mp3 files named dot.mp3, dash.mp3, space.mp3
and queue up the sound file names as you encode each letter.

Play the sounds one at a time using a Player, deleting it off pos 1 of the queue,
and starting the next sound only after when the current one ends.

ABG

Rostislav Persion

unread,
Mar 22, 2016, 10:33:13 PM3/22/16
to MIT App Inventor Forum
I wanted to scan an SMS one letter at a time and use the phone's vibration to sound it out...

Abraham Getzler

unread,
Mar 22, 2016, 11:17:38 PM3/22/16
to MIT App Inventor Forum
According to https://en.wikipedia.org/wiki/Morse_code
the dot length governs the speed, and the lengths of the dashes, gaps, letter gaps, and word gaps are all multiples of the dot length. which you can use as your Clock interval and the length of a vibration.

If you encode the vibrations and pauses as 1 and 0 respectively, you can queue them all up in a list.
So ABG would code as:
(In Morse:  . _   _...      _ _ .   )
(On the queue:)
1,0,1,1,1,0,0,0,1,1,1,0,1,0,1,0,1,0,0,0,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,0

Say a dot is a leisurely 500 ms.

Set the Clock to 500 ms, always fires, enabled, and the sound to vibrate for 500 ms per shot, initially quiet.

Clock fires:
If queue is not empty.
  set local n = 1st element of queue
  remove 1st element of queue
  if n > 0 then
    start vibration for 500 ms.
  else do nothing (silence)
end clock routine


That's the entire service routine to play.
It's all in the coding for how to build up the sound queue from the letters.

I haven't tried this myself yet.
I'm betting three  consecutive vibrations will melt into one long vibration.

ABG

Reply all
Reply to author
Forward
0 new messages