Device to measure angle and get IMU measurements.
Dependencies: mbed commands BLE_API nRF51822
main.cpp@4:2a5a08b14539, 2015-06-03 (annotated)
- Committer:
- dkester
- Date:
- Wed Jun 03 15:10:45 2015 +0000
- Revision:
- 4:2a5a08b14539
- Parent:
- 3:a3e1a06c486d
- Child:
- 5:46947b447701
Remove GonioTrainer class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dkester | 0:1c5088dae6e1 | 1 | #include "mbed.h" |
dkester | 4:2a5a08b14539 | 2 | #include "Controller.h" |
dkester | 0:1c5088dae6e1 | 3 | |
dkester | 0:1c5088dae6e1 | 4 | Serial pc(USBTX, USBRX); |
dkester | 0:1c5088dae6e1 | 5 | |
dkester | 4:2a5a08b14539 | 6 | //Ticker ticker; |
dkester | 3:a3e1a06c486d | 7 | |
dkester | 4:2a5a08b14539 | 8 | //InterruptIn button(p23); |
dkester | 4:2a5a08b14539 | 9 | volatile int ledBlink = 0; |
dkester | 4:2a5a08b14539 | 10 | |
dkester | 3:a3e1a06c486d | 11 | |
dkester | 3:a3e1a06c486d | 12 | /* |
dkester | 4:2a5a08b14539 | 13 | |
dkester | 3:a3e1a06c486d | 14 | void ledInt(){ |
dkester | 4:2a5a08b14539 | 15 | led = !led; |
dkester | 3:a3e1a06c486d | 16 | } |
dkester | 4:2a5a08b14539 | 17 | |
dkester | 4:2a5a08b14539 | 18 | |
dkester | 3:a3e1a06c486d | 19 | |
dkester | 3:a3e1a06c486d | 20 | void buttonInt(){ |
dkester | 3:a3e1a06c486d | 21 | if(ledBlink) { |
dkester | 4:2a5a08b14539 | 22 | //ticker.detach(); |
dkester | 4:2a5a08b14539 | 23 | //ledBlink = 0; |
dkester | 4:2a5a08b14539 | 24 | //led = 0; |
dkester | 4:2a5a08b14539 | 25 | *(uint32_t *)0x40000500 = 0x1; |
dkester | 3:a3e1a06c486d | 26 | } else { |
dkester | 3:a3e1a06c486d | 27 | ticker.attach(&ledInt,0.1); |
dkester | 3:a3e1a06c486d | 28 | ledBlink = 1; |
dkester | 3:a3e1a06c486d | 29 | } |
dkester | 3:a3e1a06c486d | 30 | wait(0.25); |
dkester | 3:a3e1a06c486d | 31 | |
dkester | 3:a3e1a06c486d | 32 | //printf("POWER: 0x%x\n", *((unsigned int *)0x40000500)); |
dkester | 4:2a5a08b14539 | 33 | //printf("POWER: 0x%x\n", NRF_POWER->SYSTEMOFF); |
dkester | 3:a3e1a06c486d | 34 | |
dkester | 3:a3e1a06c486d | 35 | } |
dkester | 4:2a5a08b14539 | 36 | */ |
dkester | 3:a3e1a06c486d | 37 | |
dkester | 0:1c5088dae6e1 | 38 | int main(void) |
dkester | 0:1c5088dae6e1 | 39 | { |
dkester | 0:1c5088dae6e1 | 40 | pc.baud(19200); |
dkester | 4:2a5a08b14539 | 41 | Controller* goniometer = new Controller(); |
dkester | 4:2a5a08b14539 | 42 | |
dkester | 4:2a5a08b14539 | 43 | /* |
dkester | 4:2a5a08b14539 | 44 | button.fall(&buttonInt); |
dkester | 4:2a5a08b14539 | 45 | |
dkester | 4:2a5a08b14539 | 46 | led = 0; |
dkester | 4:2a5a08b14539 | 47 | */ |
dkester | 3:a3e1a06c486d | 48 | wait(0.01); |
dkester | 2:871b5efb2043 | 49 | |
dkester | 0:1c5088dae6e1 | 50 | while(true) { |
dkester | 4:2a5a08b14539 | 51 | |
dkester | 2:871b5efb2043 | 52 | if(pc.readable()){ |
dkester | 2:871b5efb2043 | 53 | |
dkester | 2:871b5efb2043 | 54 | char command = pc.getc(); |
dkester | 2:871b5efb2043 | 55 | |
dkester | 2:871b5efb2043 | 56 | switch(command){ |
dkester | 3:a3e1a06c486d | 57 | case '1': |
dkester | 2:871b5efb2043 | 58 | pc.printf("een\n"); |
dkester | 4:2a5a08b14539 | 59 | goniometer->setCommand(0); |
dkester | 2:871b5efb2043 | 60 | break; |
dkester | 3:a3e1a06c486d | 61 | case '2': |
dkester | 2:871b5efb2043 | 62 | pc.printf("twee\n"); |
dkester | 4:2a5a08b14539 | 63 | goniometer->setCommand(1); |
dkester | 2:871b5efb2043 | 64 | break; |
dkester | 3:a3e1a06c486d | 65 | case '3': |
dkester | 2:871b5efb2043 | 66 | pc.printf("drie\n"); |
dkester | 4:2a5a08b14539 | 67 | goniometer->setCommand(2); |
dkester | 2:871b5efb2043 | 68 | break; |
dkester | 3:a3e1a06c486d | 69 | case '4': |
dkester | 3:a3e1a06c486d | 70 | pc.printf("vier\n"); |
dkester | 4:2a5a08b14539 | 71 | goniometer->setCommand(3); |
dkester | 3:a3e1a06c486d | 72 | break; |
dkester | 3:a3e1a06c486d | 73 | case '5': |
dkester | 3:a3e1a06c486d | 74 | pc.printf("vijf\n"); |
dkester | 4:2a5a08b14539 | 75 | goniometer->setCommand(4); |
dkester | 3:a3e1a06c486d | 76 | break; |
dkester | 2:871b5efb2043 | 77 | } |
dkester | 2:871b5efb2043 | 78 | } |
dkester | 0:1c5088dae6e1 | 79 | } |
dkester | 0:1c5088dae6e1 | 80 | } |
dkester | 0:1c5088dae6e1 | 81 | |
dkester | 0:1c5088dae6e1 | 82 |