Verbeterde template
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
main.cpp@2:cf2eb75fd845, 2019-10-11 (annotated)
- Committer:
- WiesjeRoskamp
- Date:
- Fri Oct 11 06:59:23 2019 +0000
- Revision:
- 2:cf2eb75fd845
- Parent:
- 1:b862262a9d14
Verbeterde template
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RobertoO | 0:67c50348f842 | 1 | #include "mbed.h" |
WiesjeRoskamp | 2:cf2eb75fd845 | 2 | #include "HIDScope.h" |
RobertoO | 0:67c50348f842 | 3 | //#include "QEI.h" |
RobertoO | 1:b862262a9d14 | 4 | #include "MODSERIAL.h" |
RobertoO | 0:67c50348f842 | 5 | //#include "BiQuad.h" |
RobertoO | 1:b862262a9d14 | 6 | //#include "FastPWM.h" |
RobertoO | 0:67c50348f842 | 7 | |
WiesjeRoskamp | 2:cf2eb75fd845 | 8 | //Define objects |
WiesjeRoskamp | 2:cf2eb75fd845 | 9 | AnalogIn emg0( A0 ); |
WiesjeRoskamp | 2:cf2eb75fd845 | 10 | AnalogIn emg1( A1 ); |
WiesjeRoskamp | 2:cf2eb75fd845 | 11 | |
RobertoO | 0:67c50348f842 | 12 | DigitalOut led(LED_RED); |
RobertoO | 0:67c50348f842 | 13 | |
RobertoO | 1:b862262a9d14 | 14 | MODSERIAL pc(USBTX, USBRX); |
WiesjeRoskamp | 2:cf2eb75fd845 | 15 | HIDScope scope( 2 ); |
WiesjeRoskamp | 2:cf2eb75fd845 | 16 | |
WiesjeRoskamp | 2:cf2eb75fd845 | 17 | void sample() |
WiesjeRoskamp | 2:cf2eb75fd845 | 18 | { |
WiesjeRoskamp | 2:cf2eb75fd845 | 19 | /* Set the sampled emg values in channel 0 (the first channel) and 1 (the second channel) in the 'HIDScope' instance named 'scope' */ |
WiesjeRoskamp | 2:cf2eb75fd845 | 20 | scope.set(0, emg0.read() ); |
WiesjeRoskamp | 2:cf2eb75fd845 | 21 | scope.set(1, emg1.read() ); |
WiesjeRoskamp | 2:cf2eb75fd845 | 22 | /* Repeat the step above if required for more channels of required (channel 0 up to 5 = 6 channels) |
WiesjeRoskamp | 2:cf2eb75fd845 | 23 | * Ensure that enough channels are available (HIDScope scope( 2 )) |
WiesjeRoskamp | 2:cf2eb75fd845 | 24 | * Finally, send all channels to the PC at once */ |
WiesjeRoskamp | 2:cf2eb75fd845 | 25 | scope.send(); |
WiesjeRoskamp | 2:cf2eb75fd845 | 26 | /* To indicate that the function is working, the LED is toggled */ |
WiesjeRoskamp | 2:cf2eb75fd845 | 27 | led = !led; |
WiesjeRoskamp | 2:cf2eb75fd845 | 28 | } |
RobertoO | 0:67c50348f842 | 29 | |
RobertoO | 0:67c50348f842 | 30 | int main() |
RobertoO | 0:67c50348f842 | 31 | { |
RobertoO | 0:67c50348f842 | 32 | pc.baud(115200); |
RobertoO | 1:b862262a9d14 | 33 | pc.printf("\r\nStarting...\r\n\r\n"); |
RobertoO | 0:67c50348f842 | 34 | |
RobertoO | 0:67c50348f842 | 35 | while (true) { |
RobertoO | 0:67c50348f842 | 36 | |
RobertoO | 1:b862262a9d14 | 37 | led = !led; |
WiesjeRoskamp | 2:cf2eb75fd845 | 38 | sample(); |
RobertoO | 0:67c50348f842 | 39 | wait_ms(500); |
RobertoO | 0:67c50348f842 | 40 | } |
RobertoO | 0:67c50348f842 | 41 | } |