Saving GPIO Input/Output Settings



  • I have a touch screen that only works if I type the following commands into the terminal in the following order:

    fast-gpio set-input 15
    fast-gpio set-input 16
    fast-gpio set-input 17
    fast-gpio set-output 15
    fast-gpio set-output 16
    fast-gpio set-output 17

    I think I have to set it as an input first as the docs mention something about how you should prior to setting it as an output and driving voltage to it.

    The issue is everytime I unplug my omega or reset it, I have to go back to the terminal and type these commands to make it work, is there a way I can store these settings somewhere so when it boots I don't need to enter it via the terminal?

    Thanks



  • @Angus-Ryan Omega2 Documentation Running a Command on Boot

    Put a little script into your home (/root) directory.
    cd /root
    Run your favorite editor, copy or type this text and save it eg. as 'set_gpios.sh'.

    #!/bin/sh
    
    # setting GPIOs to Input
    fast-gpio set-input 15
    fast-gpio set-input 16
    fast-gpio set-input 17
     
    # setting GPIOs to Output
    fast-gpio set-output 15
    fast-gpio set-output 16
    fast-gpio set-output 17
    

    chmod +x set_gpios.sh

    Edit '/etc/rc.local' - add this command /root/set_gpios.sh before 'exit 0'.

    Your script will run automatically on boot and/or you can run it manually: /root/set_gpios.sh.

    root@Omega-5BE1:/# cd /root
    root@Omega-5BE1:~# nano set_gpios.sh
     ...
    root@Omega-5BE1:~# cat set_gpios.sh
    #!/bin/sh
    
    # setting GPIOs to Input
    fast-gpio set-input 15
    fast-gpio set-input 16
    fast-gpio set-input 17
     
    # setting GPIOs to Output
    fast-gpio set-output 15
    fast-gpio set-output 16
    fast-gpio set-output 17
    
    root@Omega-5BE1:~# chmod +x set_gpios.sh
    root@Omega-5BE1:~# ls -l
    -rwxr-xr-x    1 root     root           205 Mar 16 16:05 set_gpios.sh
    
    root@Omega-5BE1:~# nano /etc/rc.local
     ...
    root@Omega-5BE1:~# cat /etc/rc.local
    # Put your custom commands here that should be executed once
    # the system init finished. By default this file does nothing.
    
    /root/set_gpios.sh
    exit 0
    

    Good luck.

    Does your Adafruit shield work really well with these settings?



  • @György-Farkas THANKYOU! Yes it does, I have no idea why, but setting those 3 as inputs then outputs makes it function perfectly.


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.