Simplest HIDScope test
Dependencies: HIDScope mbed QEI
Fork of HID_scope_test by
main.cpp@1:3011d69df4a9, 2016-10-06 (annotated)
- Committer:
- sjoerdbarts
- Date:
- Thu Oct 06 12:58:35 2016 +0000
- Revision:
- 1:3011d69df4a9
- Parent:
- 0:1883abafaa19
- Child:
- 2:5fce9d33997f
HIDScope is not working, dont know why so left out of code as of now.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sjoerdbarts | 0:1883abafaa19 | 1 | #include "mbed.h" |
sjoerdbarts | 1:3011d69df4a9 | 2 | // #include "HIDScope.h" |
sjoerdbarts | 1:3011d69df4a9 | 3 | |
sjoerdbarts | 1:3011d69df4a9 | 4 | // Define the HIDScope and Ticker object |
sjoerdbarts | 1:3011d69df4a9 | 5 | // HIDScope scope(1); |
sjoerdbarts | 1:3011d69df4a9 | 6 | Ticker scopeTimer; |
sjoerdbarts | 1:3011d69df4a9 | 7 | |
sjoerdbarts | 1:3011d69df4a9 | 8 | // Read the analog input |
sjoerdbarts | 1:3011d69df4a9 | 9 | AnalogIn a0(A0); |
sjoerdbarts | 1:3011d69df4a9 | 10 | DigitalOut led(LED_RED); |
sjoerdbarts | 1:3011d69df4a9 | 11 | |
sjoerdbarts | 1:3011d69df4a9 | 12 | const float kTimeLedToggle = .5f; // period of blinking |
sjoerdbarts | 1:3011d69df4a9 | 13 | const int kLedOn=0; // Led on if 0 |
sjoerdbarts | 1:3011d69df4a9 | 14 | |
sjoerdbarts | 1:3011d69df4a9 | 15 | // The data read and send function |
sjoerdbarts | 1:3011d69df4a9 | 16 | void scopeSend() |
sjoerdbarts | 1:3011d69df4a9 | 17 | { |
sjoerdbarts | 1:3011d69df4a9 | 18 | // scope.set(0,a0.read()); |
sjoerdbarts | 1:3011d69df4a9 | 19 | // scope.send(); |
sjoerdbarts | 1:3011d69df4a9 | 20 | } |
sjoerdbarts | 0:1883abafaa19 | 21 | |
sjoerdbarts | 1:3011d69df4a9 | 22 | void SwitchLed(){ |
sjoerdbarts | 1:3011d69df4a9 | 23 | led = not led; |
sjoerdbarts | 1:3011d69df4a9 | 24 | } |
sjoerdbarts | 1:3011d69df4a9 | 25 | |
sjoerdbarts | 0:1883abafaa19 | 26 | int main() |
sjoerdbarts | 0:1883abafaa19 | 27 | { |
sjoerdbarts | 1:3011d69df4a9 | 28 | led = not kLedOn; |
sjoerdbarts | 0:1883abafaa19 | 29 | |
sjoerdbarts | 1:3011d69df4a9 | 30 | // Create ticker |
sjoerdbarts | 1:3011d69df4a9 | 31 | Ticker tick_toggle_led; |
sjoerdbarts | 1:3011d69df4a9 | 32 | tick_toggle_led.attach(SwitchLed,kTimeLedToggle); |
sjoerdbarts | 1:3011d69df4a9 | 33 | // Attach the data read and send function at 100 Hz |
sjoerdbarts | 1:3011d69df4a9 | 34 | // scopeTimer.attach(scopeSend, 1e4); |
sjoerdbarts | 1:3011d69df4a9 | 35 | |
sjoerdbarts | 1:3011d69df4a9 | 36 | |
sjoerdbarts | 1:3011d69df4a9 | 37 | |
sjoerdbarts | 1:3011d69df4a9 | 38 | |
sjoerdbarts | 1:3011d69df4a9 | 39 | while(true); |
sjoerdbarts | 0:1883abafaa19 | 40 | } |