Example #1
0
def main():
    print "Connecting to BLE Dongle . . ."
    bt = ble.BTDongle(port='/dev/ttyACM0')

    print "Discovering BLE devices in the vicinity . . ."
    devs = bt.discover()
    print "BLE Devices found: ", devs

    print "Changing conncection parameters . . ."
    bt.changeConnectionSettings()

    print "Establishing link to the first device found . . ."
    print bt.link(devs[0])

    print "Enabling notifications . . ."
    print bt.enableNotifications('0x002F')

    ecgPlot = streamplot.StreamPlot(saveFileNameStart="ecg_plot",
                                    lines=[('l', 'r', 'ecg')],
                                    exitforce=True)
    ecgPlot.addDataPoint(0, [0])
    Tsample = 1 / 400.0  # in seconds
    t = 0

    for evt in bt.pollNotifications():
        if len(evt) == 16:
            f2s = lambda x: x if x < 2**13 or x >= 65530 else (-2**14 + x)
            vals = [
                f2s(lsb + 256 * msb)
                for (lsb, msb) in zip(evt[::2], evt[1::2])
            ]
            vals = [val for val in vals if val < 65530]
            for val in vals:
                t += Tsample
                ecgPlot.addDataPoint(t, [val])
Example #2
0
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
'''

import streamplot

# create a stream plot containing two channels. First one shown by a solid red line and the second one by a solid blue line
myPlot = streamplot.StreamPlot(saveFileNameStart="my_plot",
                               lines=[('l', 'r', 'redPlot'),
                                      ('l', 'b', 'bluePlot')])

# add two data points
myPlot.addDataPoint(
    0,
    [99, 98
     ])  # at time t=0, channel 0 has y-value 99 and channel 1 has y-value 98
myPlot.addDataPoint(
    1,
    [50, 38
     ])  # at time t=1, channel 0 has y-value 50 and channel 1 has y-value 38

# wait for the user to hit the exit button on the GUI
myPlot.waitUntilExit()
Example #3
0
#              01 - MSB 6 bits
#              10 - debug out - 6 bits LSB
#              11 - debug out - 6 bits MSB
# waveform is reset when debug value of 4095 is sent

ser = serial.Serial('/dev/ttyUSB0', 115200, timeout=0)
ser.flushInput()
ser.flush()


def numKeyPressCallBack(num):
    ser.write(str(num))


ecgPlot = streamplot.StreamPlot(saveFileNameStart="ecg_plot",
                                lines=[('l', 'r', 'ecg')],
                                exitforce=True,
                                numKeyPressCallBack=numKeyPressCallBack)

Tsample = 1e-3  # in second
printdebug = True


def uartread():
    serbuf = ""
    data = 0
    debugdata = 0
    t = 0

    while True:
        serbuf += ser.read(100000)
        for c in serbuf:
Example #4
0
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
'''

import streamplot
import time

# create a stream plot containing two channels. First one shown by a solid red line and the second one by blue dots
myPlot = streamplot.StreamPlot(saveFileNameStart="my_plot",
                               lines=[('l', 'r', 'redPlot'),
                                      ('o', 'b', 'bluePlot')],
                               legend=True,
                               exitforce=True)


def run():
    t = 0
    while True:
        #a ramp-up
        if t == 400:
            t = 0
            myPlot.resetPlot()
        for i in range(100):
            time.sleep(0.05)
            myPlot.addDataPoint(t, [
                i, i + 2