Skip to content

Commit 2c7115b

Browse files
authored
Merge pull request #83 from openUC2/mergemaster
adding dac
2 parents c1a7f28 + 5771aaf commit 2c7115b

4 files changed

Lines changed: 30 additions & 6 deletions

File tree

uc2rest/TEST/TEST_ESP32_Serial.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
#ESP32.serial.sendMessage('{"task":"/home_act", "home": {"steppers": [{"stepperid":1, "timeout": 20000, "speed": 15000, "direction":1, "endposrelease":3000}]}}')
1212

1313

14+
# test servo
15+
for i in range(180):
16+
ESP32.laser.set_servo(channel=1, value=i, is_blocking=False)
17+
time.sleep(0.1)
18+
ESP32.laser.set_servo(channel=1, value=0, is_blocking=False)
19+
20+
1421
#%% TEMPERATURE
1522
if 0:
1623
ESP32.temperature.start_temperature_polling()

uc2rest/galvo.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import numpy as np
12
class Galvo(object):
23
def __init__(self, parent=None):
34
'''
@@ -15,16 +16,18 @@ def __init__(self, parent=None):
1516
self._parent = parent
1617

1718

18-
def set_dac(self, channel=1, frequency=1, offset=0, amplitude=1/2, clk_div=0, timeout=1):
19-
19+
def set_dac(self, channel=1, frequency=1, offset=0, amplitude=1, clk_div=0, phase=0, invert=1, timeout=1):
20+
# {"task":"/dac_act", "dac_channel":1, "frequency":10, "offset":1, "amplitude":1, "divider":0, "phase":0, "invert":1, "qid":2}
2021
path = "/dac_act"
2122
payload = {
2223
"task": path,
2324
"dac_channel": channel, # 1 or 2
2425
"frequency": frequency,
2526
"offset": offset,
26-
"amplitude":amplitude,
27-
"clk_div": clk_div
27+
"divider": clk_div,
28+
"amplitude":amplitude,
29+
"phase":phase,
30+
"invert":invert
2831
}
2932

3033
self._parent.post_json(path, payload, timeout=timeout, getReturn=False)

uc2rest/laser.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,18 @@ def set_laserpin(self, laserid=1, laserpin=0):
6060
r = self._parent.post_json(path, payload)
6161
return r
6262

63+
64+
65+
def set_servo(self, channel=1, value=0, is_blocking=False):
66+
#{"task":"/laser_act", "LASERid":1 ,"LASERval":99, "servo":1, "qid":1}
67+
path = '/laser_act'
68+
69+
payload = {
70+
"task": path,
71+
"LASERid": channel,
72+
"LASERval": value,
73+
"servo": 1
74+
}
75+
76+
r = self._parent.post_json(path, payload, getReturn=is_blocking)
77+
return r

uc2rest/ledmatrix.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import numpy as np
2-
import json
3-
import time
2+
43
gTimeout = 2
54
class LedMatrix(object):
65
def __init__(self, parent, NLeds=64):

0 commit comments

Comments
 (0)