Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async transmit() {
- // time = 1200 / words per minute
- // 20 words per minute
- // follows a 3 to 1 ratio
- // 60 milliseconds for one dot
- // 180 milliseconds for a dash
- // multiplied by factor of 4 to slow it down here
- const dot = 60 * 4;
- const dash = 180 * 4;
- this.showMorse = '';
- const messageUpper = this.message.toUpperCase();
- for (const char of messageUpper) {
- this.showMorse = this.showMorse + '(' + char + ') ';
- const morseValue = this.morseTranslation[char];
- for (const morse of morseValue) {
- this.showMorse = this.showMorse + ' ' + morse;
- if (morse === '.') {
- // dot
- await this.flashlight('yellow', dot);
- // show white light to show when flash is finished
- await this.flashlight('white', 60);
- } else {
- // dash at 3 X 60 or 180
- await this.flashlight('yellow', dash);
- // show white light to show when flash is finished
- await this.flashlight('white', 60);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment