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