diff --git a/Code/scripts/README.md b/Code/scripts/README.md new file mode 100644 index 0000000..dbec378 --- /dev/null +++ b/Code/scripts/README.md @@ -0,0 +1,12 @@ +# Scripts code used in uConsole os image + +## uconsole-4g-cm4 + +Bash script to PowerOn/PowerOff 4G ext module in uConsole. + +## audio_3.5_patch.py + +Python script to switch between 3.5 audio jack and speaker on uConsole when 3.5 audio jack plugged or not. + + + diff --git a/Code/scripts/audio_3.5_patch.py b/Code/scripts/audio_3.5_patch.py new file mode 100644 index 0000000..6b6cb82 --- /dev/null +++ b/Code/scripts/audio_3.5_patch.py @@ -0,0 +1,32 @@ +import os +import time + +def init_gpio(): + os.popen("pinctrl set 11 op") + os.popen("pinctrl set 10 ip pn") + +def check_3_5(): + tmp = os.popen("pinctrl 10").readline().strip("\n") + return tmp + + +def enable_speaker_gpio(): + os.popen("pinctrl set 11 op dh") + +def disable_speaker_gpio(): + os.popen("pinctrl set 11 op dl") + +init_gpio() + +while True: + tmp = check_3_5() + if tmp == "10: ip pn | lo // GPIO10 = input": + enable_speaker_gpio() + elif tmp == "10: ip pn | hi // GPIO10 = input": + disable_speaker_gpio() + + time.sleep(1) + + + +