Added ability to get current profile, fix stapm spelling mistake.
This commit is contained in:
parent
577231a9be
commit
3f6d0749e3
38
main.py
38
main.py
@ -28,6 +28,12 @@ lib.get_slow_limit.argtypes = [c_void_p]
|
|||||||
# Fast limit and value
|
# Fast limit and value
|
||||||
lib.get_fast_limit.restype = c_float
|
lib.get_fast_limit.restype = c_float
|
||||||
lib.get_fast_limit.argtypes = [c_void_p]
|
lib.get_fast_limit.argtypes = [c_void_p]
|
||||||
|
# Slow time and value
|
||||||
|
lib.get_slow_time.restype = c_float
|
||||||
|
lib.get_slow_time.argtypes = [c_void_p]
|
||||||
|
# stapm time and value
|
||||||
|
lib.get_stapm_time.restype = c_float
|
||||||
|
lib.get_stapm_time.argtypes = [c_void_p]
|
||||||
# Vrm Max Current and value
|
# Vrm Max Current and value
|
||||||
lib.get_vrmmax_current.restype = c_float
|
lib.get_vrmmax_current.restype = c_float
|
||||||
lib.get_vrmmax_current.argtypes = [c_void_p]
|
lib.get_vrmmax_current.argtypes = [c_void_p]
|
||||||
@ -95,11 +101,11 @@ def list_by_category(list, config):
|
|||||||
|
|
||||||
|
|
||||||
def set_from_config(config, profile):
|
def set_from_config(config, profile):
|
||||||
adjust("stapm_limit", config.getint(profile, 'stamp-limit'))
|
adjust("stapm_limit", config.getint(profile, 'stapm-limit'))
|
||||||
adjust("fast_limit", config.getint(profile, 'fast-limit'))
|
adjust("fast_limit", config.getint(profile, 'fast-limit'))
|
||||||
adjust("slow_limit", config.getint(profile, 'slow-limit'))
|
adjust("slow_limit", config.getint(profile, 'slow-limit'))
|
||||||
adjust("slow_time", config.getint(profile, 'slow-time'))
|
adjust("slow_time", config.getint(profile, 'slow-time'))
|
||||||
adjust("stapm_time", config.getint(profile, 'stamp-time'))
|
adjust("stapm_time", config.getint(profile, 'stapm-time'))
|
||||||
adjust("tctl_temp", config.getint(profile, 'tctl-temp'))
|
adjust("tctl_temp", config.getint(profile, 'tctl-temp'))
|
||||||
adjust("vrmmax_current", config.getint(profile, 'vrmmax-current'))
|
adjust("vrmmax_current", config.getint(profile, 'vrmmax-current'))
|
||||||
|
|
||||||
@ -109,6 +115,30 @@ def set_from_config(config, profile):
|
|||||||
enable("power_saving")
|
enable("power_saving")
|
||||||
|
|
||||||
|
|
||||||
|
def get_current_profile(config):
|
||||||
|
profiles = config.sections()
|
||||||
|
lib.refresh_table(ry)
|
||||||
|
current = {
|
||||||
|
'stapm-limit' : f'{round(lib.get_stapm_limit(ry) * 1000)}',
|
||||||
|
'fast-limit' : f'{round(lib.get_fast_limit(ry) * 1000)}',
|
||||||
|
'slow-limit' : f'{round(lib.get_slow_limit(ry) * 1000)}',
|
||||||
|
'slow-time' : f'{round(lib.get_slow_time(ry))}',
|
||||||
|
'stapm-time' : f'{round(lib.get_stapm_time(ry))}',
|
||||||
|
'tctl-temp' : f'{round(lib.get_tctl_temp(ry))}',
|
||||||
|
'vrmmax-current' : f'{round(lib.get_vrmmax_current(ry) * 1000)}',
|
||||||
|
}
|
||||||
|
|
||||||
|
for profile in profiles:
|
||||||
|
options = dict(config.items(profile))
|
||||||
|
options.pop('category')
|
||||||
|
options.pop('max-performance')
|
||||||
|
if current == options:
|
||||||
|
print(profile)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
print("system-default")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('-v', '--version', action='store_true',
|
parser.add_argument('-v', '--version', action='store_true',
|
||||||
@ -125,6 +155,8 @@ def main():
|
|||||||
set.add_argument('profile', type=str, metavar='PROFILE', action='store', nargs='?',
|
set.add_argument('profile', type=str, metavar='PROFILE', action='store', nargs='?',
|
||||||
help="Profile name from the config")
|
help="Profile name from the config")
|
||||||
|
|
||||||
|
subparser.add_parser('get', help="Get current profile")
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
|
|
||||||
if os.path.isfile((CONFIG_FILE)):
|
if os.path.isfile((CONFIG_FILE)):
|
||||||
@ -162,6 +194,8 @@ def main():
|
|||||||
print('Profile must be provided')
|
print('Profile must be provided')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
if args.command == 'get':
|
||||||
|
get_current_profile(config)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user