From 55133939647de1a4a6d7443deccbbacf227475e9 Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Thu, 19 Oct 2023 23:57:08 +0200
Subject: [PATCH] Adds constant strategy

---
 ohmpi/hardware_components/raspberry_pi.py | 2 ++
 ohmpi/hardware_system.py                  | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/ohmpi/hardware_components/raspberry_pi.py b/ohmpi/hardware_components/raspberry_pi.py
index 93acf8fc..641afe85 100644
--- a/ohmpi/hardware_components/raspberry_pi.py
+++ b/ohmpi/hardware_components/raspberry_pi.py
@@ -46,12 +46,14 @@ class Ctl(CtlAbstract):
         warnings.resetwarnings()
 
         # Extended I2C
+        warnings.filterwarnings("error")  # to filter out adafruit warning about setting I2C frequency
         try:
             self.interfaces['i2c_ext'] = ExtendedI2C(4)  # 4 is defined
         except RuntimeWarning:
             pass
         except Exception as e:
             self.exec_logger.warning(f'Could not initialize Extended I2C:\n{e}')
+        warnings.resetwarnings()
 
         # modbus
         try:
diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py
index b23e3120..ba893a8a 100644
--- a/ohmpi/hardware_system.py
+++ b/ohmpi/hardware_system.py
@@ -435,7 +435,7 @@ class OhmPiHardware:
             current, voltage = 0., 0.
             diff_vab = np.inf
             if strategy == 'constant':
-                tx_volt = vab_max*.9
+                vab_max = tx_volt * 1.001
                 strategy = 'vmax'
             if strategy == 'vmax':
                 while (k < n_steps) and (diff_vab > diff_vab_lim) and (vab_list[k] < vab_max):
-- 
GitLab