Guest User

Untitled

a guest
Jan 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. async transmit() {
  2. // time = 1200 / words per minute
  3. // 20 words per minute
  4. // follows a 3 to 1 ratio
  5. // 60 milliseconds for one dot
  6. // 180 milliseconds for a dash
  7. // multiplied by factor of 4 to slow it down here
  8. const dot = 60 * 4;
  9. const dash = 180 * 4;
  10.  
  11. this.showMorse = '';
  12. const messageUpper = this.message.toUpperCase();
  13. for (const char of messageUpper) {
  14. this.showMorse = this.showMorse + '(' + char + ') ';
  15. const morseValue = this.morseTranslation[char];
  16. for (const morse of morseValue) {
  17. this.showMorse = this.showMorse + ' ' + morse;
  18. if (morse === '.') {
  19. // dot
  20. await this.flashlight('yellow', dot);
  21. // show white light to show when flash is finished
  22. await this.flashlight('white', 60);
  23. } else {
  24. // dash at 3 X 60 or 180
  25. await this.flashlight('yellow', dash);
  26. // show white light to show when flash is finished
  27. await this.flashlight('white', 60);
  28. }
  29. }
  30. }
  31. }
Add Comment
Please, Sign In to add comment