Skip to content

Instantly share code, notes, and snippets.

@ungeskriptet
Created October 2, 2022 11:53
Show Gist options
  • Save ungeskriptet/881abd24c26382893909c94e0efbafb7 to your computer and use it in GitHub Desktop.
Save ungeskriptet/881abd24c26382893909c94e0efbafb7 to your computer and use it in GitHub Desktop.
Generate the name of a regulator
#!/usr/bin/env python
print('Input the first letter of your regulator type. E.g. "smpf1" has type "s"')
REG_TYPE = input('Regulator type: ')
print('\nInput your PMIC ID. The PMIC ID is the letter after "ldo". E.g. "ldoc5" has ID "c".')
PMIC_ID = input('PMIC ID: ')
print('\nNow input your regulator number and microvolt value. The script will run in a loop here.')
while True:
REG_NUMBER = input('Regulator number: ')
VOLT = int(input('Microvolt: ')) / 1000000
if (VOLT < 1 and str(VOLT).endswith("8")) or str(VOLT).endswith("5"):
VOLT = round(VOLT, 2)
else:
VOLT = round(VOLT, 1)
REGULATOR = REG_TYPE + REG_NUMBER + PMIC_ID
VOLT_NAME = str(VOLT).replace(".", "p")
print(f"\n\033[1mvreg_{REGULATOR}_{VOLT_NAME}\033[0m\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment