mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-10 02:10:02 +01:00
fixed a few small bugs and only read analog inputs if there is a change
This commit is contained in:
@@ -9,8 +9,8 @@ class AnalogInput(object):
|
||||
self.actions = actions
|
||||
self.data = data
|
||||
self.analog_mappings = data.analog_mappings
|
||||
self.midi_device = None
|
||||
self.analog_delay = 50
|
||||
self.last_readings = [0,0,0,0,0,0,0,0]
|
||||
|
||||
SPI_PORT = 1
|
||||
SPI_DEVICE = 2
|
||||
@@ -26,11 +26,12 @@ class AnalogInput(object):
|
||||
|
||||
def poll_analog_inputs(self):
|
||||
if self.data.settings['other']['ANALOG_INPUT']['value'] == 'enabled':
|
||||
for i in range(0,8):
|
||||
for i in range(0,8):
|
||||
if str(i) in self.analog_mappings:
|
||||
print('{} is in the mapping'.format(i))
|
||||
reading = self.analog_input.read_adc(i)
|
||||
self.run_action_for_mapped_channel(i, reading)
|
||||
this_reading = self.analog_input.read_adc(i)
|
||||
if this_reading - self.last_readings[i] > 3:
|
||||
self.run_action_for_mapped_channel(i, this_reading)
|
||||
self.last_readings[i] = this_reading
|
||||
self.root.after(self.analog_delay, self.poll_analog_inputs)
|
||||
else:
|
||||
self.check_if_listening_enabled()
|
||||
|
||||
@@ -36,8 +36,8 @@ class MidiInput(object):
|
||||
for message in self.midi_device.iter_pending():
|
||||
i = i + 1
|
||||
message_dict = message.dict()
|
||||
## only listening to midi channel 1 for now , will make it seletcable later
|
||||
if not message_dict['channel'] == 0:
|
||||
midi_channel = midi_setting = self.data.settings['midi']['CHANNEL']['value'] - 1
|
||||
if not message_dict['channel'] == midi_channel:
|
||||
pass
|
||||
## turning off noisey clock messages for now - may want to use them at some point
|
||||
elif message_dict['type'] == 'clock':
|
||||
|
||||
Reference in New Issue
Block a user