Commit afaf6b39 authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Adds a change config function in utils

Showing with 7 additions and 2 deletions
+7 -2
...@@ -29,7 +29,7 @@ HARDWARE_CONFIG = { ...@@ -29,7 +29,7 @@ HARDWARE_CONFIG = {
'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V 'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V
'nb_samples': 20, # Max value 10 # was named integer before... 'nb_samples': 20, # Max value 10 # was named integer before...
}, },
'mux': {'model' : 'ohmpi_i2c_mux64_v1.01', 'mux': {'model' : 'dummy_mux', # 'ohmpi_i2c_mux64_v1.01',
'max_elec': 64, 'max_elec': 64,
'board_addresses': {'A': 0x73, 'B': 0x72, 'M': 0x71, 'N': 0x70}, # CHECK IF YOUR BOARDS HAVE THESE ADDRESSES 'board_addresses': {'A': 0x73, 'B': 0x72, 'M': 0x71, 'N': 0x70}, # CHECK IF YOUR BOARDS HAVE THESE ADDRESSES
'voltage_max': 100, 'voltage_max': 100,
......
...@@ -20,10 +20,15 @@ def get_platform(): ...@@ -20,10 +20,15 @@ def get_platform():
pass pass
return platform, on_pi return platform, on_pi
def change_config(config_file): def change_config(config_file, verbose=True):
cwd = os.getcwd() cwd = os.getcwd()
try: try:
shutil.copyfile(f'{cwd}/OhmPi/config.py', f'{cwd}/OhmPi/config_tmp.py') shutil.copyfile(f'{cwd}/OhmPi/config.py', f'{cwd}/OhmPi/config_tmp.py')
shutil.copyfile(f'{cwd}/OhmPi/{config_file}', f'{cwd}/OhmPi/config.py') shutil.copyfile(f'{cwd}/OhmPi/{config_file}', f'{cwd}/OhmPi/config.py')
if verbose:
print(f'Changed to {cwd}/OhmPi/{config_file}:\n')
with open(f'{cwd}/OhmPi/config.py', mode='r') as f:
print(f.read())
except Exception as error: except Exception as error:
print(f'Could not change config file to {cwd}/OhmPi/{config_file}:\n{error}') print(f'Could not change config file to {cwd}/OhmPi/{config_file}:\n{error}')
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment