Vibration Motor
Atom's Hardware
Atom has a vibration motor that can be used for creating custom vibration patterns. These vibration patterns are similar to Morse code but with many extensions.
In MagiScript, you can start vibration patterns with an atom.vibrate(pattern)
function call, where the parameter is a vibration pattern.
atom.vibrate('...'); // will play 3 short vibrations
PeekSmith Support
You can also send vibration patterns to a PeekSmith that Atom is connected to. Read more details about it on the PeekSmith page of the MagiScript documentation, however the format is similar:
ps.vibrate('...'); // will play 3 short vibrations on PeekSmith
Basic Vibration
There are 4 different lengths of vibrations Atom Knows:
' a very short notification (used for button press feedback)
. a short vibration (default length is 100ms)
- a long vibration (default length is 250ms)
= an extra long vibration (default length is 350ms)
You should send a combination of these characters, the pattern to vibrate:
atom.vibrate('...'); // plays three short vibrations
atom.vibrate('---'); // plays three long vibrations
atom.vibrate('==='); // plays three extra-long vibrations
atom.vibrate('-..'); // plays a long and two short vibrations
Numbers and English Letters
Numbers and English characters are also supported. English characters will be played as Morse code. Numbers can be configured to play as magicians used to encode numbers or as Morse code defines them. The default for the numbers is Morse encoding.
Morse Encoding
0: ----- 1: .---- 2: ..--- 3: ...-- 4: ....-
5: ..... 6: -.... 7: --... 8: ---.. 9: ----.
Only Shorts
0: .......... (ten shorts) 5: .....
1: . 6: ......
2: .. 7: .......
3: ... 8: ........
4: .... 9: .........
Long Means 3
0: ---. 5: -..
1: . 6: --
2: .. 7: --.
3: - 8: --..
4: -. 9: ---
Long Means 4
0: --.. 5: -.
1: . 6: -..
2: .. 7: -...
3: ... 8: --
4: - 9: --.
Long Means 5
0: -- 5: -
1: . 6: -.
2: .. 7: -..
3: ... 8: -...
4: .... 9: -....
Letters Encoding with Morse Code
A: .- H: .... O: --- V: ...-
B: -... I: .. P: .--. W: .--
C: -.-. J: .--- Q: --.- X: -..-
D: -.. K: -.- R: .-. Y: -.--
E: . L: .-.. S: ... Z: --..
F: ..-. M: -- T: -
G: --. N: -. U: ..-
Examples
atom.vibrate('SOS'); // plays ... --- ...
atom.vibrate('OK'); // plays --- -.-
atom.vibrate('12'); // plays .---- ..--- (by default)
Repeat
A pattern will be played once by default. However, you can add exclamation characters to the end of the pattern, and it will be played as many times as the number of exclamation characters.
atom.vibrate('.'); // plays a short vibration once
atom.vibrate('.!'); // plays a short vibration once
atom.vibrate('.!!'); // plays a short vibration twice
atom.vibrate('.!!!'); // plays a short vibration three times
Conclusion
This is how you can use the vibration motor from MagiScript! Hopefully, this information has helped you get started with configuring vibration patterns in your projects. Don’t hesitate to experiment with different patterns and lengths to create custom vibrations that suit your needs.
General
πΒ First Steps
MagiScript Editor
πΒ Basics
πΒ Running Your First Program
πΒ App Store
πΒ Atom Settings (Editor)
πΒ Debugging Techniques
Examples
πΒ Atom Time
ποΈ Time Practice
πΒ Atom Pi (Pi Revelations)
πΒ Atom Drum
ποΈ Atom Stack
πΒ Atom Square
πΒ Atom Level
πΒ Atom THMPR
πΒ Poker Hands
πΒ Keyboard Numeric
πΒ Keyboard NOKIA
πΒ Keyboard Cursor
πΒ Keyboard Media
πΒ Keyboard Custom
Input/Output
πΒ Buttons
πΒ Vibration Motor
πΒ RGB LED
πΒ Devices
πΒ PeekSmith
πΒ SB Watch
πΒ Bluetooth Keyboard
πΒ Bluetooth Mouse
πΒ Timers
πΒ Database
πΒ Events
πΒ System (exit, sleep, rand)
πΒ Objects (card, time)
Language
πΒ Summary
πΒ Comments
πΒ Variable Declarations
πΒ Operators
πΒ Control Flow
πΒ Functions
πΒ Numbers
πΒ Strings
πΒ Arrays
πΒ Objects
πΒ Uint8Array