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 v2.0 u-boot SPI issues ju0n 1 1,627 09-25-2026, 11:19 PM
Last Post: mysy
  Disable MicroSD reader for extra GPIO mxruben 0 12,737 07-27-2024, 10:08 PM
Last Post: mxruben
  Rock64 No Audio @ Debian 12 dmitrymyadzelets 2 6,455 04-08-2024, 06:47 AM
Last Post: dmitrymyadzelets
  OpenWRT on the Rock64 CanadianBacon 14 29,671 04-03-2024, 08:48 AM
Last Post: helpmerock
  Rock64 bricked shawwwn 7 17,370 03-17-2024, 12:22 PM
Last Post: dmitrymyadzelets
  Rock64 won't boot luminosity7 10 19,605 03-16-2024, 08:33 AM
Last Post: dmitrymyadzelets
  Rock64 doesn't boot dstallmo 1 5,089 03-16-2024, 08:29 AM
Last Post: dmitrymyadzelets
  How well does Rock64 deal with HDR and Atmos on Kodi? drvlikhell 3 10,344 04-29-2023, 04:24 AM
Last Post: newestssd
  Rock64 board not working, no HDMI no Ethernet. EDited 3 11,358 01-17-2023, 02:31 PM
Last Post: Flagtrax
  ROCK64 v3 can it boot from USB? Tsagualsa 4 10,755 11-29-2022, 11:31 AM
Last Post: Macgyver

Forum Jump:


Users browsing this thread: 2 Guest(s)