From 74e068f18e2f5726483374afb3e48488104c18d4 Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Fri, 22 Sep 2023 22:10:31 +0200
Subject: [PATCH] Modifies the way a controller is used by defining several
 connections and adding an io to components

---
 ohmpi/hardware_components/mux_2024_rev_0_0.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ohmpi/hardware_components/mux_2024_rev_0_0.py b/ohmpi/hardware_components/mux_2024_rev_0_0.py
index 68f08c94..dfa7f422 100644
--- a/ohmpi/hardware_components/mux_2024_rev_0_0.py
+++ b/ohmpi/hardware_components/mux_2024_rev_0_0.py
@@ -11,7 +11,7 @@ MUX_CONFIG = HARDWARE_CONFIG['mux'].pop('default', {})
 MUX_CONFIG.update({'voltage_max': 50., 'current_max': 3.})  # board default values that overwrite system default values
 MUX_CONFIG.update({'activation_delay': 0.01, 'release_delay': 0.005})  # s
 default_mux_cabling = {(elec, role) : ('mux_1', elec) for role in ['A', 'B', 'M', 'N'] for elec in range(1,9)} # defaults to 4 roles cabling electrodes from 1 to 8
-
+ctl_connection = HARDWARE_CONFIG['ctl'].pop('connection', 'i2c')
 
 inner_cabling = {'4_roles' : {(1, 'X'): {'MCP': 0, 'MCP_GPIO': 0}, (1, 'Y'): {'MCP': 0, 'MCP_GPIO': 8},
                              (2, 'X'): {'MCP': 0, 'MCP_GPIO': 1}, (2, 'Y'): {'MCP': 0, 'MCP_GPIO': 9},
@@ -75,7 +75,7 @@ class Mux(MuxAbstract):
             self.exec_logger.error(f'Invalid role assignment for {self.board_name}: {self._roles} !')
             self._mode = ''
         if tca_address is None:
-            self._tca = self.ctl.bus
+            self._tca = self.ctl.connections[kwargs.pop('connection', ctl_connection)]
         else:
             self._tca = adafruit_tca9548a.TCA9548A(self.ctl.bus, tca_address)[tca_channel]
         self._mcp_addresses = (kwargs.pop('mcp_0', '0x22'), kwargs.pop('mcp_1', '0x23'))  # TODO: add assert on valid addresses..
-- 
GitLab