some convenience improvements
This commit is contained in:
+4
-4
@@ -43,22 +43,22 @@ class DOut(gex.Unit):
|
||||
pb.u16(self.pins2int(pins))
|
||||
self._send(CMD_TOGGLE, pb.close(), confirm=confirm)
|
||||
|
||||
def pulse_ms(self, pins, length, active=True, confirm=True):
|
||||
def pulse_ms(self, ms, pins=0b01, active=True, confirm=True):
|
||||
""" Send a pulse with length 1-65535 ms on selected pins """
|
||||
pb = gex.PayloadBuilder()
|
||||
pb.u16(self.pins2int(pins))
|
||||
pb.bool(active)
|
||||
pb.bool(False)
|
||||
pb.u16(length)
|
||||
pb.u16(ms)
|
||||
self._send(CMD_PULSE, pb.close(), confirm=confirm)
|
||||
|
||||
def pulse_us(self, pins, length, active=True, confirm=True):
|
||||
def pulse_us(self, us, pins=1, active=True, confirm=True):
|
||||
""" Send a pulse of 1-999 us on selected pins """
|
||||
pb = gex.PayloadBuilder()
|
||||
pb.u16(self.pins2int(pins))
|
||||
pb.bool(active)
|
||||
pb.bool(True)
|
||||
pb.u16(length)
|
||||
pb.u16(us)
|
||||
self._send(CMD_PULSE, pb.close(), confirm=confirm)
|
||||
|
||||
|
||||
|
||||
+3
-1
@@ -14,6 +14,8 @@ class SPI(gex.Unit):
|
||||
|
||||
If rskip is -1 (default), the tbytes length will be used.
|
||||
Set it to 0 to skip nothing.
|
||||
|
||||
slave is 0-based index
|
||||
"""
|
||||
if rskip == -1:
|
||||
rskip = len(tbytes)
|
||||
@@ -24,7 +26,7 @@ class SPI(gex.Unit):
|
||||
pb.u16(rlen)
|
||||
pb.blob(tbytes)
|
||||
|
||||
# SPI does not respond if rlen is 0, but can be envorced using 'confirm'
|
||||
# SPI does not respond if rlen is 0, but can be enforced using 'confirm'
|
||||
if rlen > 0:
|
||||
resp = self._query(0x00, pb.close())
|
||||
return resp.data
|
||||
|
||||
Reference in New Issue
Block a user