File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #include " Devlpr.h "
1+ #include < libdevlpr.h >
22
3- Devlpr devlpr;
4-
5- void printEMG (Devlpr *d) {
6- int result = d->windowPeakToPeakAmplitude ();
7- Serial.print (" 0 1024 " );
8- Serial.println (result);
9- }
3+ // create a DEVLPR object with the pin we have connected on the shield
4+ // can create multiple for different pins if stacking shields
5+ Devlpr devlpr (A0);
106
117void writeFlex (Devlpr *d) {
8+ // since this function is called when a flex is detected, just print
129 Serial.println (" FLEX" );
1310}
1411
1512void setup () {
13+ // prepare Serial for printing to the monitor
1614 Serial.begin (2000000 );
17- // add our print function to our DEVLPR schedule
18- // try to run once every 1ms
19- devlpr. scheduleFunction (printEMG, 1 );
20- // devlpr.setFlexCallback(writeFlex);
15+ // set the callback for flex detection
16+ // flex detection is based on a multiple of peak-to-peak amplitude
17+ // here we set the mutliple to be 1.7x baseline and a cooldown of 300ms
18+ devlpr.setFlexCallback (writeFlex, 1.7 , 300 );
2119}
2220
2321void loop () {
Original file line number Diff line number Diff line change 1+ #include < libdevlpr.h>
2+
3+ // create a DEVLPR object with the pin we have connected on the shield
4+ // can create multiple for different pins if stacking shields
5+ Devlpr devlpr (A0);
6+
7+ void printAvg (Devlpr *d) {
8+ // first grab the most recent window average of EMG values sampled
9+ // this is effectively a low-pass filter
10+ int result = d->windowAvg ();
11+ // we will print three values each time: 0, 1024, and the measurement
12+ // the 0 and 1024 simply give us a top and bottom line in the plotter
13+ Serial.print (" 0 1024 " );
14+ Serial.println (result);
15+ }
16+
17+ void setup () {
18+ // prepare Serial for printing to the plotter
19+ Serial.begin (2000000 );
20+ // add a printing function as a scheduled callback for our Devlpr
21+ // here we set the function to be called every 1ms
22+ devlpr.scheduleFunction (printAvg, 1 );
23+ }
24+
25+ void loop () {
26+ // let the DEVLPR library do its job
27+ devlpr.tick ();
28+ }
Original file line number Diff line number Diff line change 1+ #include < libdevlpr.h>
2+
3+ // create a DEVLPR object with the pin we have connected on the shield
4+ // can create multiple for different pins if stacking shields
5+ Devlpr devlpr (A0);
6+
7+ void printEMG (Devlpr *d) {
8+ // first grab the most recent raw EMG value sampled and then centered
9+ // this method subtracts a window average to roughly center around 0
10+ int result = d->lastValueCentered ();
11+ // we will print three values each time: -1024, 1024, and the measurement
12+ // the -1024 and 1024 simply give us a top and bottom line in the plotter
13+ Serial.print (" -1024 1024 " );
14+ Serial.println (result);
15+ }
16+
17+ void setup () {
18+ // prepare Serial for printing to the plotter
19+ Serial.begin (2000000 );
20+ // add a printing function as a scheduled callback for our Devlpr
21+ // here we set the function to be called every 1ms
22+ devlpr.scheduleFunction (printEMG, 1 );
23+ }
24+
25+ void loop () {
26+ // let the DEVLPR library do its job
27+ devlpr.tick ();
28+ }
Original file line number Diff line number Diff line change 1+ #include < libdevlpr.h>
2+
3+ // create a DEVLPR object with the pin we have connected on the shield
4+ // can create multiple for different pins if stacking shields
5+ Devlpr devlpr (A0);
6+
7+ void printPeak (Devlpr *d) {
8+ // first grab the peak amplitude (max) as measured in the current window
9+ int result = d->windowPeakAmplitude ();
10+ // we will print three values each time: 0, 1024, and the measurement
11+ // the 0 and 1024 simply give us a top and bottom line in the plotter
12+ Serial.print (" 0 1024 " );
13+ Serial.println (result);
14+ }
15+
16+ void setup () {
17+ // prepare Serial for printing to the plotter
18+ Serial.begin (2000000 );
19+ // add a printing function as a scheduled callback for our Devlpr
20+ // here we set the function to be called every 1ms
21+ devlpr.scheduleFunction (printPeak, 1 );
22+ }
23+
24+ void loop () {
25+ // let the DEVLPR library do its job
26+ devlpr.tick ();
27+ }
Original file line number Diff line number Diff line change 1- #include " Devlpr.h "
1+ #include < libdevlpr.h >
22
3- Devlpr devlpr;
3+ // create a DEVLPR object with the pin we have connected on the shield
4+ // can create multiple for different pins if stacking shields
5+ Devlpr devlpr (A0);
46
5- void printEMG (Devlpr *d) {
7+ void printP2P (Devlpr *d) {
8+ // first grab the peak-to-peak amplitude (max-min) as measured in the current window
69 int result = d->windowPeakToPeakAmplitude ();
10+ // we will print three values each time: 0, 1024, and the measurement
11+ // the 0 and 1024 simply give us a top and bottom line in the plotter
712 Serial.print (" 0 1024 " );
813 Serial.println (result);
914}
1015
11- void writeFlex (Devlpr *d) {
12- Serial.println (" FLEX" );
13- }
14-
1516void setup () {
17+ // prepare Serial for printing to the plotter
1618 Serial.begin (2000000 );
17- // add our print function to our DEVLPR schedule
18- // try to run once every 1ms
19- devlpr.scheduleFunction (printEMG, 1 );
20- // devlpr.setFlexCallback(writeFlex);
19+ // add a printing function as a scheduled callback for our Devlpr
20+ // here we set the function to be called every 1ms
21+ devlpr.scheduleFunction (printP2P, 1 );
2122}
2223
2324void loop () {
Original file line number Diff line number Diff line change 1+ #include < libdevlpr.h>
2+
3+ // create a DEVLPR object with the pin we have connected on the shield
4+ // can create multiple for different pins if stacking shields
5+ Devlpr devlpr (A0);
6+
7+ void printEMG (Devlpr *d) {
8+ // first grab the most recent raw EMG value sampled
9+ int result = d->lastValue ();
10+ // we will print three values each time: 0, 1024, and the measurement
11+ // the 0 and 1024 simply give us a top and bottom line in the plotter
12+ Serial.print (" 0 1024 " );
13+ Serial.println (result);
14+ }
15+
16+ void setup () {
17+ // prepare Serial for printing to the plotter
18+ Serial.begin (2000000 );
19+ // add a printing function as a scheduled callback for our Devlpr
20+ // here we set the function to be called every 1ms
21+ devlpr.scheduleFunction (printEMG, 1 );
22+ }
23+
24+ void loop () {
25+ // let the DEVLPR library do its job
26+ devlpr.tick ();
27+ }
Original file line number Diff line number Diff line change 11name =Libdevlpr
2- version =0.1.2
2+ version =0.1.3
33author =Finn Kuusisto <finn@getfantm.com>, Ezra Boley <ezra@getfantm.com>
44maintainer =Finn Kuusisto <finn@getfantm.com>
55sentence =A library that makes using the FANTM DEVLPR shield easier.
Original file line number Diff line number Diff line change 11#ifndef libdevlpr_h
22#define libdevlpr_h
33
4- #define LIBDEVLPR_VERSION "0.1.2 "
4+ #define LIBDEVLPR_VERSION "0.1.3 "
55
66#include "Devlpr.h"
77
You can’t perform that action at this time.
0 commit comments