Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@4:a7442c1faed1, 2015-04-24 (annotated)
- Committer:
- tyleralt
- Date:
- Fri Apr 24 07:51:33 2015 +0000
- Revision:
- 4:a7442c1faed1
- Parent:
- 3:9e8eb12f831f
- Child:
- 5:54ff826d1897
working more so;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| tyleralt | 0:c8b0c4f50d18 | 1 | #include "mbed.h" |
| tyleralt | 0:c8b0c4f50d18 | 2 | #include <vector> |
| tyleralt | 0:c8b0c4f50d18 | 3 | #define BUFFER_SIZE 16 |
| tyleralt | 0:c8b0c4f50d18 | 4 | #define NUMBER_OF_SLICES 120 |
| tyleralt | 2:e2502545f2f0 | 5 | #include "MRF24J40.h" |
| tyleralt | 0:c8b0c4f50d18 | 6 | |
| tyleralt | 0:c8b0c4f50d18 | 7 | |
| tyleralt | 3:9e8eb12f831f | 8 | int offAngles [8] = {0, 180, 45, 225, 90, 270, 135, 315}; |
| tyleralt | 0:c8b0c4f50d18 | 9 | |
| tyleralt | 2:e2502545f2f0 | 10 | //*********************point class************************// |
| tyleralt | 0:c8b0c4f50d18 | 11 | class Point { |
| tyleralt | 0:c8b0c4f50d18 | 12 | int positionRadian, positionHeight, positionDistance; |
| tyleralt | 0:c8b0c4f50d18 | 13 | public: |
| tyleralt | 0:c8b0c4f50d18 | 14 | Point (int , int , int ); |
| tyleralt | 0:c8b0c4f50d18 | 15 | int getArraySlice(void); |
| tyleralt | 0:c8b0c4f50d18 | 16 | char getIdentifyingChar(void); |
| tyleralt | 0:c8b0c4f50d18 | 17 | int getPositionDistance(void); |
| tyleralt | 0:c8b0c4f50d18 | 18 | void moveUp(); |
| tyleralt | 0:c8b0c4f50d18 | 19 | void moveDown(); |
| tyleralt | 0:c8b0c4f50d18 | 20 | void rotateRight(); |
| tyleralt | 0:c8b0c4f50d18 | 21 | void rotateLeft(); |
| tyleralt | 0:c8b0c4f50d18 | 22 | void moveIn(); |
| tyleralt | 0:c8b0c4f50d18 | 23 | void moveOut(); |
| tyleralt | 0:c8b0c4f50d18 | 24 | |
| tyleralt | 0:c8b0c4f50d18 | 25 | }; |
| tyleralt | 0:c8b0c4f50d18 | 26 | Point :: Point (int posRadian, int posHeight, int posDistance){ |
| tyleralt | 0:c8b0c4f50d18 | 27 | positionRadian = posRadian; |
| tyleralt | 0:c8b0c4f50d18 | 28 | positionHeight = posHeight; |
| tyleralt | 0:c8b0c4f50d18 | 29 | positionDistance = posDistance; |
| tyleralt | 0:c8b0c4f50d18 | 30 | } |
| tyleralt | 0:c8b0c4f50d18 | 31 | int Point :: getArraySlice (void){ |
| tyleralt | 4:a7442c1faed1 | 32 | return (int) (positionRadian + (offAngles[positionHeight]/3))%120; |
| tyleralt | 0:c8b0c4f50d18 | 33 | } |
| tyleralt | 0:c8b0c4f50d18 | 34 | char Point :: getIdentifyingChar(void){ |
| tyleralt | 1:533b878c22ab | 35 | return 0x01 << positionHeight; |
| tyleralt | 0:c8b0c4f50d18 | 36 | } |
| tyleralt | 0:c8b0c4f50d18 | 37 | int Point :: getPositionDistance(void){ |
| tyleralt | 0:c8b0c4f50d18 | 38 | return positionDistance; |
| tyleralt | 0:c8b0c4f50d18 | 39 | } |
| tyleralt | 1:533b878c22ab | 40 | void Point :: moveUp(){ |
| tyleralt | 0:c8b0c4f50d18 | 41 | if (positionHeight < 7){ |
| tyleralt | 0:c8b0c4f50d18 | 42 | positionHeight ++; |
| tyleralt | 0:c8b0c4f50d18 | 43 | } |
| tyleralt | 0:c8b0c4f50d18 | 44 | } |
| tyleralt | 1:533b878c22ab | 45 | void Point :: moveDown(){ |
| tyleralt | 1:533b878c22ab | 46 | if(positionHeight > 0){ |
| tyleralt | 0:c8b0c4f50d18 | 47 | positionHeight --; |
| tyleralt | 1:533b878c22ab | 48 | } |
| tyleralt | 1:533b878c22ab | 49 | } |
| tyleralt | 1:533b878c22ab | 50 | void Point :: rotateRight(){ |
| tyleralt | 1:533b878c22ab | 51 | positionRadian = (positionRadian + 1) % 120; |
| tyleralt | 1:533b878c22ab | 52 | } |
| tyleralt | 1:533b878c22ab | 53 | void Point :: rotateLeft(){ |
| tyleralt | 3:9e8eb12f831f | 54 | positionRadian = (positionRadian - 1) % 120; |
| tyleralt | 1:533b878c22ab | 55 | } |
| tyleralt | 1:533b878c22ab | 56 | void Point :: moveIn(){ |
| tyleralt | 3:9e8eb12f831f | 57 | if (positionDistance > 0){ |
| tyleralt | 1:533b878c22ab | 58 | positionDistance --; |
| tyleralt | 1:533b878c22ab | 59 | } |
| tyleralt | 1:533b878c22ab | 60 | } |
| tyleralt | 1:533b878c22ab | 61 | void Point :: moveOut(){ |
| tyleralt | 3:9e8eb12f831f | 62 | if (positionDistance < 15){ |
| tyleralt | 1:533b878c22ab | 63 | positionDistance ++; |
| tyleralt | 1:533b878c22ab | 64 | } |
| tyleralt | 1:533b878c22ab | 65 | } |
| tyleralt | 2:e2502545f2f0 | 66 | |
| tyleralt | 2:e2502545f2f0 | 67 | //******************end Point class*******************// |
| tyleralt | 0:c8b0c4f50d18 | 68 | |
| tyleralt | 1:533b878c22ab | 69 | enum DrawingMode { line, point, circle }; |
| tyleralt | 1:533b878c22ab | 70 | DrawingMode currentMode; |
| tyleralt | 1:533b878c22ab | 71 | |
| tyleralt | 1:533b878c22ab | 72 | Point pointer(60, 3, 8); |
| tyleralt | 0:c8b0c4f50d18 | 73 | |
| tyleralt | 3:9e8eb12f831f | 74 | DigitalIn digitalMode(p15); |
| tyleralt | 3:9e8eb12f831f | 75 | DigitalIn digitalUp(p16); |
| tyleralt | 3:9e8eb12f831f | 76 | DigitalIn digitalDown(p17); |
| tyleralt | 3:9e8eb12f831f | 77 | DigitalIn digitalRotateRight(p18); |
| tyleralt | 3:9e8eb12f831f | 78 | DigitalIn digitalRotateLeft(p21); |
| tyleralt | 3:9e8eb12f831f | 79 | DigitalIn digitalMoveOut(p22); |
| tyleralt | 3:9e8eb12f831f | 80 | DigitalIn digtialMoveIn(p23); |
| tyleralt | 3:9e8eb12f831f | 81 | DigitalIn digitalSelect(p24); |
| tyleralt | 3:9e8eb12f831f | 82 | |
| tyleralt | 0:c8b0c4f50d18 | 83 | InterruptIn buttonMode(p15); |
| tyleralt | 0:c8b0c4f50d18 | 84 | InterruptIn buttonUp(p16); |
| tyleralt | 0:c8b0c4f50d18 | 85 | InterruptIn buttonDown(p17); |
| tyleralt | 0:c8b0c4f50d18 | 86 | InterruptIn buttonRotateRight(p18); |
| tyleralt | 3:9e8eb12f831f | 87 | InterruptIn buttonRotateLeft(p21); |
| tyleralt | 3:9e8eb12f831f | 88 | InterruptIn buttonMoveOut(p22); |
| tyleralt | 3:9e8eb12f831f | 89 | InterruptIn buttonMoveIn(p23); |
| tyleralt | 3:9e8eb12f831f | 90 | InterruptIn buttonSelect(p24); |
| tyleralt | 3:9e8eb12f831f | 91 | |
| tyleralt | 3:9e8eb12f831f | 92 | bool registerButtons = true; |
| tyleralt | 3:9e8eb12f831f | 93 | Timeout buttonRegisterTimeout; |
| tyleralt | 3:9e8eb12f831f | 94 | Timeout unBlink; |
| tyleralt | 0:c8b0c4f50d18 | 95 | |
| tyleralt | 1:533b878c22ab | 96 | Ticker pointerBlinkTicker; |
| tyleralt | 1:533b878c22ab | 97 | |
| tyleralt | 2:e2502545f2f0 | 98 | MRF24J40 mrf(p11, p12, p13, p14, p26); |
| tyleralt | 2:e2502545f2f0 | 99 | char txBuffer[128]; |
| tyleralt | 2:e2502545f2f0 | 100 | int rxLen; |
| tyleralt | 2:e2502545f2f0 | 101 | |
| tyleralt | 3:9e8eb12f831f | 102 | |
| tyleralt | 2:e2502545f2f0 | 103 | void rf_send(char *data, uint8_t len) |
| tyleralt | 2:e2502545f2f0 | 104 | { |
| tyleralt | 2:e2502545f2f0 | 105 | //We need to prepend the message with a valid ZigBee header |
| tyleralt | 2:e2502545f2f0 | 106 | uint8_t header[8]= {1, 8, 0, 0xA1, 0xB2, 0xC3, 0xD4, 0x00}; |
| tyleralt | 2:e2502545f2f0 | 107 | uint8_t *send_buf = (uint8_t *) malloc( sizeof(uint8_t) * (len+8) ); |
| tyleralt | 3:9e8eb12f831f | 108 | |
| tyleralt | 2:e2502545f2f0 | 109 | for(uint8_t i = 0; i < len+8; i++) { |
| tyleralt | 2:e2502545f2f0 | 110 | //prepend the 8-byte header |
| tyleralt | 2:e2502545f2f0 | 111 | send_buf[i] = (i<8) ? header[i] : data[i-8]; |
| tyleralt | 2:e2502545f2f0 | 112 | } |
| tyleralt | 2:e2502545f2f0 | 113 | //pc.printf("Sent: %s\r\n", send_buf+8); |
| tyleralt | 3:9e8eb12f831f | 114 | |
| tyleralt | 2:e2502545f2f0 | 115 | mrf.Send(send_buf, len+8); |
| tyleralt | 2:e2502545f2f0 | 116 | free(send_buf); |
| tyleralt | 2:e2502545f2f0 | 117 | } |
| tyleralt | 2:e2502545f2f0 | 118 | |
| tyleralt | 3:9e8eb12f831f | 119 | void sendPointOver (int slice, int distance, char height, char operation){ |
| tyleralt | 1:533b878c22ab | 120 | ///TODO implement communications |
| tyleralt | 4:a7442c1faed1 | 121 | //printf(" slice %i distance %i height %X operation %c \r\n", (char) slice, (char) distance, height, operation); |
| tyleralt | 3:9e8eb12f831f | 122 | txBuffer [0] = (char) slice; |
| tyleralt | 3:9e8eb12f831f | 123 | txBuffer [1] = (char)distance; |
| tyleralt | 3:9e8eb12f831f | 124 | txBuffer [2] = height; |
| tyleralt | 3:9e8eb12f831f | 125 | txBuffer [3] = operation; |
| tyleralt | 3:9e8eb12f831f | 126 | |
| tyleralt | 3:9e8eb12f831f | 127 | rf_send(txBuffer, 5); |
| tyleralt | 1:533b878c22ab | 128 | } |
| tyleralt | 1:533b878c22ab | 129 | |
| tyleralt | 1:533b878c22ab | 130 | void drawPoint(){ |
| tyleralt | 3:9e8eb12f831f | 131 | |
| tyleralt | 1:533b878c22ab | 132 | int pointerSlice = pointer.getArraySlice(); |
| tyleralt | 1:533b878c22ab | 133 | int pointerDistance = pointer.getPositionDistance(); |
| tyleralt | 1:533b878c22ab | 134 | char height = pointer.getIdentifyingChar(); |
| tyleralt | 3:9e8eb12f831f | 135 | sendPointOver(pointerSlice, pointerDistance, height, 'o'); |
| tyleralt | 1:533b878c22ab | 136 | } |
| tyleralt | 1:533b878c22ab | 137 | |
| tyleralt | 3:9e8eb12f831f | 138 | void registerButtonsAgain (){ |
| tyleralt | 3:9e8eb12f831f | 139 | registerButtons = true; |
| tyleralt | 3:9e8eb12f831f | 140 | } |
| tyleralt | 2:e2502545f2f0 | 141 | |
| tyleralt | 2:e2502545f2f0 | 142 | //***************** all of the button reactions *********// |
| tyleralt | 0:c8b0c4f50d18 | 143 | void changeMode(){ |
| tyleralt | 3:9e8eb12f831f | 144 | if (!registerButtons){ |
| tyleralt | 3:9e8eb12f831f | 145 | return; |
| tyleralt | 3:9e8eb12f831f | 146 | } |
| tyleralt | 3:9e8eb12f831f | 147 | registerButtons = false; |
| tyleralt | 3:9e8eb12f831f | 148 | buttonRegisterTimeout.attach(®isterButtonsAgain, .1); |
| tyleralt | 3:9e8eb12f831f | 149 | printf("changeMode\r\n"); |
| tyleralt | 1:533b878c22ab | 150 | if (currentMode == point){ |
| tyleralt | 1:533b878c22ab | 151 | currentMode = line; |
| tyleralt | 3:9e8eb12f831f | 152 | printf("line mode\r\n"); |
| tyleralt | 3:9e8eb12f831f | 153 | return; |
| tyleralt | 1:533b878c22ab | 154 | } |
| tyleralt | 1:533b878c22ab | 155 | if (currentMode == line){ |
| tyleralt | 1:533b878c22ab | 156 | currentMode = circle; |
| tyleralt | 3:9e8eb12f831f | 157 | printf("circle mode\r\n"); |
| tyleralt | 3:9e8eb12f831f | 158 | return; |
| tyleralt | 1:533b878c22ab | 159 | } |
| tyleralt | 1:533b878c22ab | 160 | if (currentMode == circle){ |
| tyleralt | 1:533b878c22ab | 161 | currentMode = point; |
| tyleralt | 3:9e8eb12f831f | 162 | printf("point mode\r\n"); |
| tyleralt | 3:9e8eb12f831f | 163 | return; |
| tyleralt | 1:533b878c22ab | 164 | } |
| tyleralt | 0:c8b0c4f50d18 | 165 | } |
| tyleralt | 0:c8b0c4f50d18 | 166 | void moveUp(){ |
| tyleralt | 3:9e8eb12f831f | 167 | if (!registerButtons){ |
| tyleralt | 3:9e8eb12f831f | 168 | return; |
| tyleralt | 3:9e8eb12f831f | 169 | } |
| tyleralt | 3:9e8eb12f831f | 170 | registerButtons = false; |
| tyleralt | 3:9e8eb12f831f | 171 | buttonRegisterTimeout.attach(®isterButtonsAgain, .1); |
| tyleralt | 3:9e8eb12f831f | 172 | printf("moveUp\r\n"); |
| tyleralt | 1:533b878c22ab | 173 | if (currentMode == line){ |
| tyleralt | 1:533b878c22ab | 174 | drawPoint(); |
| tyleralt | 1:533b878c22ab | 175 | } |
| tyleralt | 1:533b878c22ab | 176 | pointer.moveUp(); |
| tyleralt | 0:c8b0c4f50d18 | 177 | } |
| tyleralt | 0:c8b0c4f50d18 | 178 | void moveDown(){ |
| tyleralt | 3:9e8eb12f831f | 179 | if (!registerButtons){ |
| tyleralt | 3:9e8eb12f831f | 180 | return; |
| tyleralt | 3:9e8eb12f831f | 181 | } |
| tyleralt | 3:9e8eb12f831f | 182 | registerButtons = false; |
| tyleralt | 3:9e8eb12f831f | 183 | buttonRegisterTimeout.attach(®isterButtonsAgain, .1); |
| tyleralt | 1:533b878c22ab | 184 | if (currentMode == line){ |
| tyleralt | 1:533b878c22ab | 185 | drawPoint(); |
| tyleralt | 1:533b878c22ab | 186 | } |
| tyleralt | 4:a7442c1faed1 | 187 | printf("moveDown\r\n"); |
| tyleralt | 1:533b878c22ab | 188 | pointer.moveDown(); |
| tyleralt | 0:c8b0c4f50d18 | 189 | } |
| tyleralt | 0:c8b0c4f50d18 | 190 | void rotateRight(){ |
| tyleralt | 3:9e8eb12f831f | 191 | if (!registerButtons){ |
| tyleralt | 3:9e8eb12f831f | 192 | return; |
| tyleralt | 3:9e8eb12f831f | 193 | } |
| tyleralt | 3:9e8eb12f831f | 194 | registerButtons = false; |
| tyleralt | 3:9e8eb12f831f | 195 | buttonRegisterTimeout.attach(®isterButtonsAgain, .1); |
| tyleralt | 3:9e8eb12f831f | 196 | printf("rotaeRight\r\n"); |
| tyleralt | 1:533b878c22ab | 197 | if (currentMode == line){ |
| tyleralt | 3:9e8eb12f831f | 198 | drawPoint(); |
| tyleralt | 1:533b878c22ab | 199 | pointer.rotateRight(); |
| tyleralt | 3:9e8eb12f831f | 200 | wait(.3); |
| tyleralt | 3:9e8eb12f831f | 201 | while (digitalRotateRight){ |
| tyleralt | 3:9e8eb12f831f | 202 | drawPoint(); |
| tyleralt | 3:9e8eb12f831f | 203 | pointer.rotateRight(); |
| tyleralt | 3:9e8eb12f831f | 204 | wait(.03); |
| tyleralt | 3:9e8eb12f831f | 205 | } |
| tyleralt | 3:9e8eb12f831f | 206 | return; |
| tyleralt | 1:533b878c22ab | 207 | } |
| tyleralt | 1:533b878c22ab | 208 | pointer.rotateRight(); |
| tyleralt | 3:9e8eb12f831f | 209 | wait(.3); |
| tyleralt | 3:9e8eb12f831f | 210 | while (digitalRotateRight){ |
| tyleralt | 3:9e8eb12f831f | 211 | pointer.rotateRight(); |
| tyleralt | 3:9e8eb12f831f | 212 | wait(.03); |
| tyleralt | 3:9e8eb12f831f | 213 | } |
| tyleralt | 0:c8b0c4f50d18 | 214 | } |
| tyleralt | 0:c8b0c4f50d18 | 215 | void rotateLeft(){ |
| tyleralt | 3:9e8eb12f831f | 216 | if (!registerButtons){ |
| tyleralt | 3:9e8eb12f831f | 217 | return; |
| tyleralt | 3:9e8eb12f831f | 218 | } |
| tyleralt | 3:9e8eb12f831f | 219 | registerButtons = false; |
| tyleralt | 3:9e8eb12f831f | 220 | buttonRegisterTimeout.attach(®isterButtonsAgain, .1); |
| tyleralt | 3:9e8eb12f831f | 221 | printf("rotateLeft\r\n"); |
| tyleralt | 1:533b878c22ab | 222 | if (currentMode == line){ |
| tyleralt | 1:533b878c22ab | 223 | drawPoint(); |
| tyleralt | 4:a7442c1faed1 | 224 | pointer.rotateLeft(); |
| tyleralt | 3:9e8eb12f831f | 225 | wait(.3); |
| tyleralt | 3:9e8eb12f831f | 226 | while (digitalRotateLeft){ |
| tyleralt | 3:9e8eb12f831f | 227 | drawPoint(); |
| tyleralt | 4:a7442c1faed1 | 228 | pointer.rotateLeft(); |
| tyleralt | 3:9e8eb12f831f | 229 | wait(.03); |
| tyleralt | 3:9e8eb12f831f | 230 | } |
| tyleralt | 3:9e8eb12f831f | 231 | return; |
| tyleralt | 1:533b878c22ab | 232 | } |
| tyleralt | 1:533b878c22ab | 233 | pointer.rotateLeft(); |
| tyleralt | 2:e2502545f2f0 | 234 | wait(.3); |
| tyleralt | 3:9e8eb12f831f | 235 | while(digitalRotateLeft){ |
| tyleralt | 3:9e8eb12f831f | 236 | pointer.rotateLeft(); |
| tyleralt | 3:9e8eb12f831f | 237 | wait(.03); |
| tyleralt | 3:9e8eb12f831f | 238 | |
| tyleralt | 3:9e8eb12f831f | 239 | } |
| tyleralt | 3:9e8eb12f831f | 240 | |
| tyleralt | 0:c8b0c4f50d18 | 241 | } |
| tyleralt | 0:c8b0c4f50d18 | 242 | void moveOut(){ |
| tyleralt | 3:9e8eb12f831f | 243 | if (!registerButtons){ |
| tyleralt | 3:9e8eb12f831f | 244 | return; |
| tyleralt | 3:9e8eb12f831f | 245 | } |
| tyleralt | 3:9e8eb12f831f | 246 | registerButtons = false; |
| tyleralt | 3:9e8eb12f831f | 247 | buttonRegisterTimeout.attach(®isterButtonsAgain, .1); |
| tyleralt | 3:9e8eb12f831f | 248 | printf("moveOut\r\n"); |
| tyleralt | 1:533b878c22ab | 249 | if (currentMode == line){ |
| tyleralt | 1:533b878c22ab | 250 | drawPoint(); |
| tyleralt | 1:533b878c22ab | 251 | } |
| tyleralt | 1:533b878c22ab | 252 | pointer.moveOut(); |
| tyleralt | 0:c8b0c4f50d18 | 253 | } |
| tyleralt | 0:c8b0c4f50d18 | 254 | void moveIn(){ |
| tyleralt | 3:9e8eb12f831f | 255 | if (!registerButtons){ |
| tyleralt | 3:9e8eb12f831f | 256 | return; |
| tyleralt | 3:9e8eb12f831f | 257 | } |
| tyleralt | 3:9e8eb12f831f | 258 | registerButtons = false; |
| tyleralt | 3:9e8eb12f831f | 259 | buttonRegisterTimeout.attach(®isterButtonsAgain, .1); |
| tyleralt | 1:533b878c22ab | 260 | if (currentMode == line){ |
| tyleralt | 1:533b878c22ab | 261 | drawPoint(); |
| tyleralt | 1:533b878c22ab | 262 | } |
| tyleralt | 4:a7442c1faed1 | 263 | printf("moveIn\r\n"); |
| tyleralt | 1:533b878c22ab | 264 | pointer.moveIn(); |
| tyleralt | 0:c8b0c4f50d18 | 265 | } |
| tyleralt | 3:9e8eb12f831f | 266 | |
| tyleralt | 0:c8b0c4f50d18 | 267 | void pointerBlink(){ |
| tyleralt | 1:533b878c22ab | 268 | Point currentBlink = pointer; |
| tyleralt | 1:533b878c22ab | 269 | int slice = currentBlink.getArraySlice(); |
| tyleralt | 1:533b878c22ab | 270 | int distance = currentBlink.getPositionDistance(); |
| tyleralt | 1:533b878c22ab | 271 | char height = pointer.getIdentifyingChar(); |
| tyleralt | 3:9e8eb12f831f | 272 | sendPointOver(slice, distance, height, 'x'); |
| tyleralt | 3:9e8eb12f831f | 273 | wait(1.5); |
| tyleralt | 3:9e8eb12f831f | 274 | sendPointOver(slice, distance, height, 'x'); |
| tyleralt | 0:c8b0c4f50d18 | 275 | } |
| tyleralt | 1:533b878c22ab | 276 | void drawWholeCircle(){ |
| tyleralt | 4:a7442c1faed1 | 277 | printf("drawing circle"); |
| tyleralt | 1:533b878c22ab | 278 | int distance = pointer.getPositionDistance(); |
| tyleralt | 1:533b878c22ab | 279 | char height = pointer.getIdentifyingChar(); |
| tyleralt | 1:533b878c22ab | 280 | for (int i = 0; i < 120; i ++){ |
| tyleralt | 3:9e8eb12f831f | 281 | sendPointOver(i, distance, height, 'o'); |
| tyleralt | 1:533b878c22ab | 282 | } |
| tyleralt | 1:533b878c22ab | 283 | |
| tyleralt | 1:533b878c22ab | 284 | } |
| tyleralt | 3:9e8eb12f831f | 285 | |
| tyleralt | 1:533b878c22ab | 286 | void select(){ |
| tyleralt | 3:9e8eb12f831f | 287 | if (!registerButtons){ |
| tyleralt | 3:9e8eb12f831f | 288 | return; |
| tyleralt | 3:9e8eb12f831f | 289 | } |
| tyleralt | 3:9e8eb12f831f | 290 | registerButtons = false; |
| tyleralt | 3:9e8eb12f831f | 291 | buttonRegisterTimeout.attach(®isterButtonsAgain, .1); |
| tyleralt | 3:9e8eb12f831f | 292 | printf(" select \r\n"); |
| tyleralt | 1:533b878c22ab | 293 | if (currentMode == point){ |
| tyleralt | 1:533b878c22ab | 294 | drawPoint(); |
| tyleralt | 1:533b878c22ab | 295 | } |
| tyleralt | 1:533b878c22ab | 296 | if (currentMode == circle){ |
| tyleralt | 1:533b878c22ab | 297 | drawWholeCircle(); |
| tyleralt | 1:533b878c22ab | 298 | } |
| tyleralt | 1:533b878c22ab | 299 | } |
| tyleralt | 3:9e8eb12f831f | 300 | //****************end buttons section ************// |
| tyleralt | 3:9e8eb12f831f | 301 | |
| tyleralt | 0:c8b0c4f50d18 | 302 | |
| tyleralt | 0:c8b0c4f50d18 | 303 | |
| tyleralt | 0:c8b0c4f50d18 | 304 | int main() { |
| tyleralt | 3:9e8eb12f831f | 305 | printf(" started the program\r\n "); |
| tyleralt | 3:9e8eb12f831f | 306 | |
| tyleralt | 3:9e8eb12f831f | 307 | uint8_t channel = 2; |
| tyleralt | 3:9e8eb12f831f | 308 | |
| tyleralt | 3:9e8eb12f831f | 309 | |
| tyleralt | 3:9e8eb12f831f | 310 | //Set the Channel. 0 is default, 15 is max |
| tyleralt | 3:9e8eb12f831f | 311 | mrf.SetChannel(channel); |
| tyleralt | 3:9e8eb12f831f | 312 | |
| tyleralt | 0:c8b0c4f50d18 | 313 | currentMode = point; |
| tyleralt | 0:c8b0c4f50d18 | 314 | buttonMode.rise(&changeMode); |
| tyleralt | 0:c8b0c4f50d18 | 315 | buttonUp.rise(&moveUp); |
| tyleralt | 0:c8b0c4f50d18 | 316 | buttonDown.rise(&moveDown); |
| tyleralt | 0:c8b0c4f50d18 | 317 | buttonRotateRight.rise(&rotateRight); |
| tyleralt | 0:c8b0c4f50d18 | 318 | buttonRotateLeft.rise(&rotateLeft); |
| tyleralt | 0:c8b0c4f50d18 | 319 | buttonMoveOut.rise(&moveOut); |
| tyleralt | 0:c8b0c4f50d18 | 320 | buttonMoveIn.rise(&moveIn); |
| tyleralt | 1:533b878c22ab | 321 | buttonSelect.rise(&select); |
| tyleralt | 4:a7442c1faed1 | 322 | pointerBlinkTicker.attach(&pointerBlink, 2.0); |
| tyleralt | 1:533b878c22ab | 323 | |
| tyleralt | 0:c8b0c4f50d18 | 324 | |
| tyleralt | 3:9e8eb12f831f | 325 | while(1); |
| tyleralt | 0:c8b0c4f50d18 | 326 | |
| tyleralt | 0:c8b0c4f50d18 | 327 | |
| tyleralt | 0:c8b0c4f50d18 | 328 | } |