Measure EMG, publish on HID Scope
Dependencies: HIDScope mbed mbed-dsp
Fork of EMG by
Diff: main.cpp
- Revision:
- 14:94a4a5863689
- Parent:
- 12:768048d7f742
- Parent:
- 13:18d4cef1fdb4
- Child:
- 16:24e992616cf6
--- a/main.cpp Thu Sep 11 07:19:37 2014 +0000 +++ b/main.cpp Tue Sep 23 19:40:35 2014 +0000 @@ -1,11 +1,13 @@ #include "mbed.h" #include "MODSERIAL.h" +#include "HIDScope.h" //Define objects AnalogIn emg0(PTB1); //Analog input PwmOut red(LED_RED); //PWM output Ticker log_timer; MODSERIAL pc(USBTX,USBRX); +HIDScope scope(2); /** Looper function * functions used for Ticker and Timeout should be of type void <name>(void) @@ -28,8 +30,11 @@ red.write(emg0.read()); // read float value (0..1 = 0..3.3V) emg_value = emg0.read_u16(); // read direct ADC result, converted to 16 bit integer (0..2^16 = 0..65536 = 0..3.3V) /*send value to PC. Line below is used to prevent buffer overrun */ - if(pc.rxBufferGetSize(0)-pc.rxBufferGetCount() > 30) - pc.printf("%u\n",emg_value); + //if(pc.rxBufferGetSize(0)-pc.rxBufferGetCount() > 30) + // pc.printf("%u\n",emg_value); + scope.set(0,emg_value); + scope.set(1,red.read()); + scope.send(); /**When not using the LED, the above could also have been done this way: * pc.printf("%u\n", emg0.read_u16()); */ @@ -38,14 +43,14 @@ int main() { /*setup baudrate. Choose the same in your program on PC side*/ - pc.baud(115200); + //pc.baud(115200); /*set the period for the PWM to the red LED*/ red.period_ms(2); /**Here you attach the 'void looper(void)' function to the Ticker object * The looper() function will be called every 0.01 seconds. * Please mind that the parentheses after looper are omitted when using attach. */ - log_timer.attach(looper, 0.01); + log_timer.attach(looper, 0.005); while(1) //Loop { /*Empty!*/