GPIO LED blinker using SYSFS on the Rock64
#13
Hi
First of all thank you for your work. Very helpful!
I'd like to share a modified version of the function to calculate the pin number, with a bit of validation to be sure that the string is ok (I hope it is ok). The function returns -1 if there was any problem with the string

Code:
def GPIO_name2gpio(value):
    value = value.upper()
    if (value[0:4] != 'GPIO') or (value[5] != '_'):
        return -1
    try:
        bank_num = int(value[4:5], 10)
        pad_nam = GPIO_pads[value[6:7]]
        pad_num = int(value[7:], 10)
        if (bank_num < 0) or (bank_num > 3) or (pad_num < 0) or (pad_num > 7):
            return -1;

        return (bank_num * 32) + (pad_nam * 8) + pad_num
    except (ValueError,KeyError):
        return -1


Messages In This Thread
RE: GPIO LED blinker using SYSFS on the Rock64 - by fra87 - 12-28-2017, 03:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rock64 No Audio @ Debian 12 dmitrymyadzelets 2 310 04-08-2024, 06:47 AM
Last Post: dmitrymyadzelets
  OpenWRT on the Rock64 CanadianBacon 14 8,407 04-03-2024, 08:48 AM
Last Post: helpmerock
  Rock64 bricked shawwwn 7 5,759 03-17-2024, 12:22 PM
Last Post: dmitrymyadzelets
  Rock64 won't boot luminosity7 10 4,233 03-16-2024, 08:33 AM
Last Post: dmitrymyadzelets
  Rock64 doesn't boot dstallmo 1 353 03-16-2024, 08:29 AM
Last Post: dmitrymyadzelets
  How well does Rock64 deal with HDR and Atmos on Kodi? drvlikhell 3 1,939 04-29-2023, 04:24 AM
Last Post: newestssd
  Rock64 board not working, no HDMI no Ethernet. EDited 3 3,557 01-17-2023, 02:31 PM
Last Post: Flagtrax
  ROCK64 v3 can it boot from USB? Tsagualsa 4 2,135 11-29-2022, 11:31 AM
Last Post: Macgyver
  rock64 v3 spiflash Macgyver 0 771 11-28-2022, 02:18 PM
Last Post: Macgyver
  my rock64 dosen't work rookie_267 0 966 10-07-2022, 07:50 PM
Last Post: rookie_267

Forum Jump:


Users browsing this thread: 1 Guest(s)