-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_mdm.py
42 lines (34 loc) · 1.08 KB
/
test_mdm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
from __future__ import print_function
from matplotlib.pyplot import *
from numpy import *
from numpy.random import *
from hardwarex import *
bExit = 0
# This function should be called when a key is pressed.
def on_key(event):
# Global variables to share with other functions.
global bExit
# Actions to do depending on the key pressed.
#print('You pressed', event.key, event.xdata, event.ydata)
if event.key == 'escape':
bExit = 1
pMDM = CreateMDM()
# Check and modify the configuration file if needed...
result = ConnectMDM(pMDM, 'MDM0.txt')
ion() # Turn the interactive mode on.
# Create a figure that will use the function on_key() when a key is
# pressed.
fig = figure('Test')
cid = fig.canvas.mpl_connect('key_press_event',on_key)
while (bExit == 0):
clf(); axis('square'); axis([-200,200,-200,200])
buf = zeros(4)
result = RecvDataMDM(pMDM, buf, 4)
buf = result[1]
nbbytes = result[2]
str='%d, %d, %d, %d'%(buf[0], buf[1], buf[2], buf[3])
text(-150,0,str)
pause(1)
result = DisconnectMDM(pMDM)
DestroyMDM(pMDM)