Telling .wait() to "skip one sample" slightly obfuscates the intent of
getting the next samples while no condition applies. Explicitly pass no
condition arguments instead, to better reflect the purpose. Coincidently
these .wait() calls will execute in slightly less expensive code paths
in the common code.
bit = 0
while True:
# TODO: Come up with more appropriate self.wait() conditions.
bit = 0
while True:
# TODO: Come up with more appropriate self.wait() conditions.
- (dali,) = self.wait({'skip': 1})
if self.options['polarity'] == 'active-high':
dali ^= 1 # Invert.
if self.options['polarity'] == 'active-high':
dali ^= 1 # Invert.
# Mark and read a single transmitted byte
# (start bit, 8 data bits, 2 stop bits).
elif self.state == 'READ BYTE':
# Mark and read a single transmitted byte
# (start bit, 8 data bits, 2 stop bits).
elif self.state == 'READ BYTE':
- (dmx,) = self.wait({'skip': 1})
self.next_sample = self.run_start + (self.bit + 1) * self.skip_per_bit
self.aggreg += dmx
if self.samplenum != self.next_sample:
self.next_sample = self.run_start + (self.bit + 1) * self.skip_per_bit
self.aggreg += dmx
if self.samplenum != self.next_sample:
raise SamplerateError('Cannot decode without samplerate.')
bit = 0
while True:
raise SamplerateError('Cannot decode without samplerate.')
bit = 0
while True:
- (self.dsi,) = self.wait({'skip': 1})
+ (self.dsi,) = self.wait()
if self.options['polarity'] == 'active-high':
self.dsi ^= 1 # Invert.
if self.options['polarity'] == 'active-high':
self.dsi ^= 1 # Invert.
raise SamplerateError('Cannot decode without samplerate.')
# Initialize internal state from the very first sample.
raise SamplerateError('Cannot decode without samplerate.')
# Initialize internal state from the very first sample.
- (pin,) = self.wait({'skip': 1})
self.oldpin = pin
self.last_samplenum = self.samplenum
self.lastlast_samplenum = self.samplenum
self.oldpin = pin
self.last_samplenum = self.samplenum
self.lastlast_samplenum = self.samplenum
raise SamplerateError('Cannot decode without samplerate.')
while True:
raise SamplerateError('Cannot decode without samplerate.')
while True:
- (self.ir,) = self.wait({'skip': 1})
+ (self.ir,) = self.wait()
# Wait for any edge (rising or falling).
if self.old_ir == self.ir:
# Wait for any edge (rising or falling).
if self.old_ir == self.ir:
def decode(self):
while True:
# TODO: Come up with more appropriate self.wait() conditions.
def decode(self):
while True:
# TODO: Come up with more appropriate self.wait() conditions.
- pins = self.wait({'skip': 1})
# If none of the pins changed, there's nothing to do.
if self.oldpins == pins:
# If none of the pins changed, there's nothing to do.
if self.oldpins == pins:
if not self.samplerate:
raise SamplerateError('Cannot decode without samplerate.')
if not self.samplerate:
raise SamplerateError('Cannot decode without samplerate.')
- (qi,) = self.wait({'skip': 1})
self.handle_transition(self.samplenum, qi == 0)
while True:
prev = self.samplenum
self.handle_transition(self.samplenum, qi == 0)
while True:
prev = self.samplenum
while True:
# TODO: Come up with more appropriate self.wait() conditions.
while True:
# TODO: Come up with more appropriate self.wait() conditions.
- (pin,) = self.wait({'skip': 1})
if self.oldpin is None:
self.oldpin = pin
if self.oldpin is None:
self.oldpin = pin
raise SamplerateError('Cannot decode without samplerate.')
# Seed internal state from the very first sample.
raise SamplerateError('Cannot decode without samplerate.')
# Seed internal state from the very first sample.
- pins = self.wait({'skip': 1})
sym = symbols[self.options['signalling']][pins]
self.handle_idle(sym)
sym = symbols[self.options['signalling']][pins]
self.handle_idle(sym)
self.get_eop(sym)
elif self.state == 'WAIT IDLE':
# Skip "all-low" input. Wait for high level on either DP or DM.
self.get_eop(sym)
elif self.state == 'WAIT IDLE':
# Skip "all-low" input. Wait for high level on either DP or DM.
- pins = self.wait({'skip': 1})
while not pins[0] and not pins[1]:
pins = self.wait([{0: 'h'}, {1: 'h'}])
if self.samplenum - self.samplenum_lastedge > 1:
while not pins[0] and not pins[1]:
pins = self.wait([{0: 'h'}, {1: 'h'}])
if self.samplenum - self.samplenum_lastedge > 1:
def decode(self):
while True:
# TODO: Come up with more appropriate self.wait() conditions.
def decode(self):
while True:
# TODO: Come up with more appropriate self.wait() conditions.
- (d0, d1) = self.wait({'skip': 1})
if d0 == self._d0_prev and d1 == self._d1_prev:
if self.es_bit and self.samplenum >= self.es_bit:
if d0 == self._d0_prev and d1 == self._d1_prev:
if self.es_bit and self.samplenum >= self.es_bit:
def decode(self):
while True:
# TODO: Come up with more appropriate self.wait() conditions.
def decode(self):
while True:
# TODO: Come up with more appropriate self.wait() conditions.
- pins = self.wait({'skip': 1})
cycle = Cycle.NONE
if pins[Pin.MREQ] != 1: # default to asserted
if pins[Pin.RD] == 0:
cycle = Cycle.NONE
if pins[Pin.MREQ] != 1: # default to asserted
if pins[Pin.RD] == 0: