+ msg, chan = self.status_byte & 0xf0, (self.status_byte & 0x0f) + 1
+ fn, param = c[0], c[1]
+ default_name = 'undefined'
+ ctrl_fn = control_functions.get(fn, default_name)
+ if ctrl_fn == default_name:
+ ctrl_fn = ('undefined 0x%02x' % fn, 'undef 0x%02x' % fn, '0x%02x' % fn)
+ self.putx([0, ['Channel %d: %s \'%s\' (param = 0x%02x)' % \
+ (chan, status_bytes[msg][0], ctrl_fn[0], param),
+ 'ch %d: %s \'%s\' (param = 0x%02x)' % \
+ (chan, status_bytes[msg][1], ctrl_fn[1], param),
+ '%d: %s \'%s\' is 0x%02x' % \
+ (chan, status_bytes[msg][2], ctrl_fn[2], param)]])
+
+ def handle_channel_mode(self):
+ # Channel Mode: Bn mm vv
+ # n = channel, mm = mode number (120 - 127), vv = value
+ c = self.cmd
+ msg, chan = self.status_byte & 0xf0, (self.status_byte & 0x0f) + 1
+ mm, vv = c[0], c[1]
+ mode_fn = control_functions.get(mm, ('undefined', 'undef', 'undef'))
+ # Decode the value based on the mode number.
+ vv_string = ('', '')
+ if mm == 122: # mode = local control?
+ if vv == 0:
+ vv_string = ('off', 'off')
+ elif vv == 127: # mode = poly mode on?
+ vv_string = ('on', 'on')
+ else:
+ vv_string = ('(non-standard param value of 0x%02x)' % vv,
+ '0x%02x' % vv)
+ elif mm == 126: # mode = mono mode on?
+ if vv != 0:
+ vv_string = ('(%d channels)' % vv, '(%d ch)' % vv)
+ else:
+ vv_string = ('(channels \'basic\' through 16)',
+ '(ch \'basic\' thru 16)')
+ elif vv != 0: # All other channel mode messages expect vv == 0.
+ vv_string = ('(non-standard param value of 0x%02x)' % vv,
+ '0x%02x' % vv)
+ self.putx([0, ['Channel %d: %s \'%s\' %s' % \
+ (chan, status_bytes[msg][0], mode_fn[0], vv_string[0]),
+ 'ch %d: %s \'%s\' %s' % \
+ (chan, status_bytes[msg][1], mode_fn[1], vv_string[1]),
+ '%d: %s \'%s\' %s' % \
+ (chan, status_bytes[msg][2], mode_fn[2], vv_string[1])]])
+ self.cmd, self.state = [], 'IDLE'
+ self.soft_clear_status_byte()