Text_to_morse function written
Dependencies: mbed 4DGL-uLCD-SE
Fork of morseCode_1 by
main.cpp@6:421ece74143e, 2018-04-29 (annotated)
- Committer:
- colson
- Date:
- Sun Apr 29 16:57:29 2018 +0000
- Revision:
- 6:421ece74143e
- Parent:
- 5:5b86521e418c
- Child:
- 8:78b057dd6da4
-Added comments; -Created wordlist
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
colson | 0:4e10b6c94be9 | 1 | #include "mbed.h" |
colson | 4:62c590826ddb | 2 | #include "Header_file.h" |
colson | 4:62c590826ddb | 3 | #include <iostream> |
colson | 4:62c590826ddb | 4 | #include <string> |
colson | 4:62c590826ddb | 5 | |
colson | 6:421ece74143e | 6 | //To-do list: |
colson | 6:421ece74143e | 7 | //Bluetooth input for strings |
colson | 6:421ece74143e | 8 | //Modify dot/dash for speaker/LED output |
colson | 6:421ece74143e | 9 | //Give user output/UI for game |
colson | 6:421ece74143e | 10 | //Traverse the tree using telegraph key |
colson | 6:421ece74143e | 11 | //Make menus/UI look pretty |
colson | 5:5b86521e418c | 12 | |
colson | 5:5b86521e418c | 13 | |
colson | 5:5b86521e418c | 14 | |
Jeco13 | 3:6e52b66c5a0c | 15 | //Part 1 |
Jeco13 | 3:6e52b66c5a0c | 16 | //Main takes in string text input from bluetooth module. Store in string variable |
Jeco13 | 3:6e52b66c5a0c | 17 | //call text_to_morse function on each character from input string variable |
Jeco13 | 3:6e52b66c5a0c | 18 | |
colson | 0:4e10b6c94be9 | 19 | int main() { |
colson | 4:62c590826ddb | 20 | |
colson | 6:421ece74143e | 21 | //Variable word list for the game portion |
colson | 6:421ece74143e | 22 | //Feel free to add words, just update the array size |
colson | 6:421ece74143e | 23 | string wordlist[20] = {"Dog","Cat","Car","Tree","Star","Radio","Tea","Book","Hello","Bank","Bird","Bus","Red","Green","Blue","Coat","Dress","Shirt","Egg","Pear"}; |
colson | 6:421ece74143e | 24 | |
colson | 6:421ece74143e | 25 | //Can I put these ^v in the header? I really can't remember |
colson | 6:421ece74143e | 26 | |
colson | 5:5b86521e418c | 27 | //Creation of the binary search tree// |
colson | 6:421ece74143e | 28 | //I need to insert 2,8,9,0,+// |
colson | 5:5b86521e418c | 29 | Tree * newRoot; |
colson | 5:5b86521e418c | 30 | newRoot->insertdot('e', newRoot); |
colson | 5:5b86521e418c | 31 | Tree * eNode = newRoot->dot; |
colson | 5:5b86521e418c | 32 | eNode->insertdash('a', eNode); |
colson | 5:5b86521e418c | 33 | eNode->insertdot('i', eNode); |
colson | 5:5b86521e418c | 34 | Tree * iNode = eNode->dot; |
colson | 5:5b86521e418c | 35 | iNode->insertdash('u',iNode); |
colson | 5:5b86521e418c | 36 | iNode->insertdot('s',iNode); |
colson | 5:5b86521e418c | 37 | Tree * sNode = iNode->dot; |
colson | 5:5b86521e418c | 38 | sNode->insertdash('v',sNode); |
colson | 5:5b86521e418c | 39 | sNode->insertdot('h',sNode); |
colson | 5:5b86521e418c | 40 | Tree * hNode = sNode->dot; |
colson | 5:5b86521e418c | 41 | hNode->insertdash('4',hNode); |
colson | 5:5b86521e418c | 42 | hNode->insertdot('5',hNode); |
colson | 5:5b86521e418c | 43 | Tree * vNode = sNode->dash; |
colson | 5:5b86521e418c | 44 | vNode->insertdash('3',vNode); |
colson | 5:5b86521e418c | 45 | Tree * uNode = iNode->dash; |
colson | 5:5b86521e418c | 46 | uNode->insertdot('f',uNode); |
colson | 5:5b86521e418c | 47 | Tree * aNode = eNode->dash; |
colson | 5:5b86521e418c | 48 | aNode->insertdot('r',aNode); |
colson | 5:5b86521e418c | 49 | aNode->insertdash('w',aNode); |
colson | 5:5b86521e418c | 50 | Tree * rNode = aNode->dot; |
colson | 5:5b86521e418c | 51 | rNode->insertdot('l',rNode); |
colson | 5:5b86521e418c | 52 | Tree * wNode = aNode->dash; |
colson | 5:5b86521e418c | 53 | wNode->insertdot('p',wNode); |
colson | 5:5b86521e418c | 54 | wNode->insertdash('j',wNode); |
colson | 5:5b86521e418c | 55 | Tree * jNode = wNode->dash; |
colson | 5:5b86521e418c | 56 | jNode->insertdash('1',jNode); |
colson | 5:5b86521e418c | 57 | newRoot->insertdash('t',newRoot); |
colson | 5:5b86521e418c | 58 | Tree * tNode = newRoot->dash; |
colson | 5:5b86521e418c | 59 | tNode->insertdot('n',tNode); |
colson | 5:5b86521e418c | 60 | tNode->insertdash('m',tNode); |
colson | 5:5b86521e418c | 61 | Tree * nNode = tNode->dash; |
colson | 5:5b86521e418c | 62 | nNode->insertdot('d',nNode); |
colson | 5:5b86521e418c | 63 | nNode->insertdash('k',nNode); |
colson | 5:5b86521e418c | 64 | Tree * dNode = nNode->dot; |
colson | 5:5b86521e418c | 65 | dNode->insertdot('b',dNode); |
colson | 5:5b86521e418c | 66 | dNode->insertdash('x',dNode); |
colson | 5:5b86521e418c | 67 | Tree * bNode = dNode->dot; |
colson | 5:5b86521e418c | 68 | bNode->insertdot('6',bNode); |
colson | 5:5b86521e418c | 69 | bNode->insertdash('=',bNode); |
colson | 5:5b86521e418c | 70 | Tree * xNode = dNode->dash; |
colson | 5:5b86521e418c | 71 | xNode->insertdot('/',xNode); |
colson | 5:5b86521e418c | 72 | Tree * kNode = nNode->dash; |
colson | 5:5b86521e418c | 73 | kNode->insertdot('c',kNode); |
colson | 5:5b86521e418c | 74 | kNode->insertdash('y',kNode); |
colson | 5:5b86521e418c | 75 | Tree * mNode = tNode->dash; |
colson | 5:5b86521e418c | 76 | mNode->insertdot('g',mNode); |
colson | 5:5b86521e418c | 77 | mNode->insertdash('o',mNode); |
colson | 5:5b86521e418c | 78 | Tree * gNode = mNode->dot; |
colson | 5:5b86521e418c | 79 | gNode->insertdot('z',gNode); |
colson | 5:5b86521e418c | 80 | gNode->insertdash('q',gNode); |
colson | 5:5b86521e418c | 81 | Tree * zNode = gNode->dot; |
colson | 5:5b86521e418c | 82 | zNode->insertdot('7',zNode); |
colson | 5:5b86521e418c | 83 | |
colson | 4:62c590826ddb | 84 | string newString = "YYZ"; |
colson | 4:62c590826ddb | 85 | |
colson | 4:62c590826ddb | 86 | for (int i = 0; i < newString.length(); i++){ |
colson | 4:62c590826ddb | 87 | Text_to_morse(newString[i]); |
colson | 4:62c590826ddb | 88 | } |
colson | 4:62c590826ddb | 89 | |
colson | 4:62c590826ddb | 90 | char schar = 's'; |
colson | 4:62c590826ddb | 91 | char ochar = 'o'; |
colson | 0:4e10b6c94be9 | 92 | while(1) { |
colson | 4:62c590826ddb | 93 | uLCD.printf("do this\n"); |
colson | 4:62c590826ddb | 94 | Text_to_morse(schar); |
colson | 4:62c590826ddb | 95 | Text_to_morse(ochar); |
colson | 4:62c590826ddb | 96 | Text_to_morse(schar); |
colson | 4:62c590826ddb | 97 | wait(0.5); |
colson | 0:4e10b6c94be9 | 98 | } |
colson | 0:4e10b6c94be9 | 99 | } |