RPi.GPIO python module for Pine A64/A64+
#51
PL10 S_PWM output is also connected to the feedback loop of the LCD backlight controller in the schematic, to control brightness from software I guess...
Come have a chat in the Pine IRC channel >>
  Reply
#52
(08-11-2016, 06:55 AM)martinayotte Wrote:
Quote:On the PineA64 pin(7) PL10 is GPIO04,  AND  S_PWM,  GPCLK0   hence, the reason a test LED is lit all the time


Yes, I've figured that out too... That's mean the the "green" color on pins mapping should be changed ...

Yes, martinayotte, and thank you for reminding me... 

... tllim was going to take the design from the pins mapping here and make one specifically similar to it for the PineA64; we just need to scrutinize it (measure twice cut once) to make sure that it makes sense for folks.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#53
With this setup and  Python code I can confirm that all pins I added functions for work as input.

[Image: VGGMJTq.jpg]

Code:
# -*- coding: utf-8 -*- import time import RPi.GPIO as GPIO class PIN:    def __init__(self):        # Setup GPIO to input        #GPIO.cleanup()        GPIO.setmode(GPIO.BCM)                # "Left" side        GPIO.setup(2,  GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(3,  GPIO.IN, pull_up_down=GPIO.PUD_UP)        #GPIO.setup(4, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Broken!!!        GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(9,  GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(5,  GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(6,  GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(19, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP)                # "Right" side        GPIO.setup(14, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(25, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(8,  GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(7,  GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(20, GPIO.IN, pull_up_down=GPIO.PUD_UP)        GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)        self.p2  = False        self.p3  = False        self.p17 = False        self.p27 = False        self.p22 = False        self.p10 = False        self.p9  = False        self.p11 = False        self.p5  = False        self.p6  = False        self.p13 = False        self.p19 = False        self.p26 = False        self.p14 = False        self.p15 = False        self.p18 = False        self.p23 = False        self.p24 = False        self.p25 = False        self.p8  = False        self.p7  = False        self.p12 = False        self.p16 = False        self.p20 = False        self.p21 = False        self.read()            def read(self):        self.old2  = self.p2        self.old3  = self.p3        self.old17 = self.p17        self.old27 = self.p27        self.old22 = self.p22        self.old10 = self.p10        self.old9  = self.p9        self.old11 = self.p11        self.old5  = self.p5        self.old6  = self.p6        self.old13 = self.p13        self.old19 = self.p19        self.old26 = self.p26            self.old14 = self.p14        self.old15 = self.p15        self.old18 = self.p18        self.old23 = self.p23        self.old24 = self.p24        self.old25 = self.p25        self.old8  = self.p8        self.old7  = self.p7        self.old12 = self.p12        self.old16 = self.p16        self.old20 = self.p20        self.old21 = self.p21        self.p2  = False if GPIO.input(2)  else True        self.p3  = False if GPIO.input(3)  else True        self.p17 = False if GPIO.input(17) else True        self.p27 = False if GPIO.input(27) else True        self.p22 = False if GPIO.input(22) else True        self.p10 = False if GPIO.input(10) else True        self.p9  = False if GPIO.input(9)  else True        self.p11 = False if GPIO.input(11) else True        self.p5  = False if GPIO.input(5)  else True        self.p6  = False if GPIO.input(6)  else True        self.p13 = False if GPIO.input(13) else True        self.p19 = False if GPIO.input(19) else True        self.p26 = False if GPIO.input(26) else True                self.p14 = False if GPIO.input(14) else True        self.p15 = False if GPIO.input(15) else True        self.p18 = False if GPIO.input(18) else True        self.p23 = False if GPIO.input(23) else True        self.p24 = False if GPIO.input(24) else True        self.p25 = False if GPIO.input(25) else True        self.p8  = False if GPIO.input(8)  else True        self.p7  = False if GPIO.input(7)  else True        self.p12 = False if GPIO.input(12) else True        self.p16 = False if GPIO.input(16)  else True        self.p20 = False if GPIO.input(20)  else True        self.p21 = False if GPIO.input(21) else True delay=1.0/60.0 if __name__=="__main__":    counter2 = 0    counter3 = 0    counter17 = 0    counter27 = 0    counter22 = 0    counter10 = 0    counter9  = 0    counter11 = 0    counter5  = 0    counter6  = 0    counter13 = 0    counter19 = 0    counter26 = 0        counter14 = 0    counter15 = 0    counter18 = 0    counter23 = 0    counter24 = 0    counter25 = 0    counter8  = 0    counter7  = 0    counter12 = 0    counter16 = 0    counter20 = 0    counter21 = 0        pin = PIN()    while True:        loopstart=time.time()        pin.read()                if pin.p2 and pin.p2 != pin.old2:            counter2 += 1            print "Button 2", counter2        if pin.p3 and pin.p3 != pin.old3:            counter3 += 1            print "Button 3", counter3        if pin.p17 and pin.p17 != pin.old17:            counter17 += 1            print "Button 17", counter17        if pin.p27 and pin.p27 != pin.old27:            counter27 += 1            print "Button 27", counter27        if pin.p22 and pin.p22 != pin.old22:            counter22 += 1            print "Button 22", counter22        if pin.p10 and pin.p10 != pin.old10:            counter10 += 1            print "Button 10", counter10        if pin.p9 and pin.p9 != pin.old9:            counter9 += 1            print "Button 9", counter9        if pin.p11 and pin.p11 != pin.old11:            counter11 += 1            print "Button 11", counter11        if pin.p5 and pin.p5 != pin.old5:            counter5 += 1            print "Button 5", counter5        if pin.p6 and pin.p6 != pin.old6:            counter6 += 1            print "Button 6", counter6        if pin.p13 and pin.p13 != pin.old13:            counter13 += 1            print "Button 13", counter13        if pin.p19 and pin.p19 != pin.old19:            counter19 += 1            print "Button 19", counter19        if pin.p26 and pin.p26 != pin.old26:            counter26 += 1            print "Button 26", counter26                    if pin.p14 and pin.p14 != pin.old14:            counter14 += 1            print "Button 14", counter14        if pin.p15 and pin.p15 != pin.old15:            counter15 += 1            print "Button 15", counter15        if pin.p18 and pin.p18 != pin.old18:            counter18 += 1            print "Button 18", counter18        if pin.p23 and pin.p23 != pin.old23:            counter23 += 1            print "Button 23", counter23        if pin.p24 and pin.p24 != pin.old24:            counter24 += 1            print "Button 24", counter24        if pin.p25 and pin.p25 != pin.old25:            counter25 += 1            print "Button 25", counter25        if pin.p8 and pin.p8 != pin.old8:            counter8 += 1            print "Button 8", counter8        if pin.p7 and pin.p7 != pin.old7:            counter7 += 1            print "Button 7", counter7        if pin.p12 and pin.p12 != pin.old12:            counter12 += 1            print "Button 12", counter12        if pin.p16 and pin.p16 != pin.old16:            counter16 += 1            print "Button 16", counter16        if pin.p20 and pin.p20 != pin.old20:            counter20 += 1            print "Button 20", counter20        if pin.p21 and pin.p21 != pin.old21:            counter21 += 1            print "Button 21", counter21                while loopstart+delay>time.time():            time.sleep(0.001) # Must be sleep or get 94.7% CPU drain
  Reply
#54
@Wolfenstein, thank you for the effort; very nice!

... its good to see other folks interested in the GPIO ; the more the community gets involved with connecting this PineA64 to the world via GPIO , the better. It might be nice if a couple of us can dive into the RPi.GPIO-PineA64 code a bit, maybe even fork it, and not only get some of the kinks ironed out, but also get i2c, i2s, SPI, and pwm working...
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#55
@all has anybody run into this bug, and if so knows a solution:
https://github.com/swkim01/RPi.GPIO-PineA64/issues/5

(08-15-2016, 02:51 PM)louwie17 Wrote: @all has anybody run into this bug, and if so knows a solution:
https://github.com/swkim01/RPi.GPIO-PineA64/issues/5

I managed to get it working using python3 instead, and not individually installing RPi.GPIO, left a comment in the issue.
  Reply
#56
(08-10-2016, 04:53 PM)MarkHaysHarris777 Wrote: @DonFL, confirmed:  

GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.OUT)

... will get an error channel not valid on a Raspberry PI.  Either the RPi.GPIO-PineA64 codes were ported from the 26 pin GPIO stuff... or else, this is an over-sight (a bug, for sure).

The work-around (as DonFL has noted) is to code  GPIO.setmode(GPIO.BCM).  then all of the channels may be setup, with the exception that some of the channels (GPIO04) apparently do not work.  Need to dive into the code to find out, because that doesn't make any sense.

This issue has been fixed. Updated code is at the github location: https://github.com/swkim01/RPi.GPIO-PineA64
  Reply
#57
(08-16-2016, 06:15 AM)DonFL Wrote:
(08-10-2016, 04:53 PM)MarkHaysHarris777 Wrote: @DonFL, confirmed:  

GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.OUT)

... will get an error channel not valid on a Raspberry PI.  Either the RPi.GPIO-PineA64 codes were ported from the 26 pin GPIO stuff... or else, this is an over-sight (a bug, for sure).

The work-around (as DonFL has noted) is to code  GPIO.setmode(GPIO.BCM).  then all of the channels may be setup, with the exception that some of the channels (GPIO04) apparently do not work.  Need to dive into the code to find out, because that doesn't make any sense.

This issue has been fixed. Updated code is at the github location:  https://github.com/swkim01/RPi.GPIO-PineA64

Thanks much, Don, for reporting it and for the update...   i really appreciate it !
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#58
(06-17-2016, 12:49 AM)jacobscarter Wrote: Is anyone running into the issue where "import RPi.GPIO as GPIO" return "No module named RPi_GPIO"?

I recently had to reflash my microSD card and reinstalled this script last night and it worked as per normal. When done for the evening I turned off the monitor but left the Pine powered on. This morning I went back to it and got the same error. I tried what I could to troubleshoot it, but ended up rebooting. Lo and behold, it worked again. 

The image I flashed was Ubuntu 20160530 from the Pine64 wiki, with the DRM update installed as per Longsleep's instructions found elsewhere on the forum, resulting in uname -r returning 3.10.102-2-pine64drm-longleep. Seemed odd to me so I thought I would document it. No idea what to make of the possible issue, though.
  Reply
#59
(06-17-2016, 12:49 AM)jacobscarter Wrote: Is anyone running into the issue where "import RPi.GPIO as GPIO" return "No module named RPi_GPIO"?

This happened to me and it was because I was executing my python script from the same folder where I downloaded the RPi.GPIO library. Just place your script in another location (or open a python session in another dir) and it should work.

On another subject, has someone been able to use the GPIO 4 (pin 7) as an input yet? I'm working on a shield for the Raspberry Pi and I would like to make it compatible with the Pine64. I need to use all the "green" pins, don't have any other free pin. Another issues I'm having is the lack of GPIO interrupts and SPI not working.
I really want to make my shield work on the Pine but I feel that there are a lot of community efforts and too little effort from the Pine team on the Linux side, so I'm considering to stop investing more time on the Pine, even after investing a lot of time in designing the board layout to fit both the RPi and the Pine.
  Reply
#60
(12-30-2016, 02:38 PM)ciclopez Wrote: On another subject, has someone been able to use the GPIO 4 (pin 7) as an input yet?
I didn't, but maybe this will guide you :
According to schematic, the Pin7 is LCD-PWM, which is GPIO PL10.
It is probably already in use by spwm0@0 or spwm0@1 in the DT, but it could be probably comment out and replace by plain gpio input.
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  fm transmitter with gpio weasel18 2 8,236 09-10-2019, 04:28 AM
Last Post: desai_amogh
  How to use dts or other setup to declare gpio pin Interrupt (e.g. a button)? dkebler 1 6,054 06-12-2019, 10:37 AM
Last Post: dkebler
Lightbulb Sample GPIO codes highlighting RPi.GPIO-PineA64 and the PI bus MarkHaysHarris777 6 17,974 06-07-2019, 12:37 AM
Last Post: tllim
Star GPIO, SPI and I2C C++ Lib databit 7 17,565 02-04-2019, 05:45 AM
Last Post: Jeff R
Information Howto: Controlling Pine64 GPIO via the filesystem (sysfs) on linux pfeerick 4 18,267 01-24-2019, 03:36 AM
Last Post: Fifth
  GPIO and SPI SamR1 20 49,030 03-15-2018, 10:32 AM
Last Post: jomoengineer
Question GPIO shockr 7 22,672 03-11-2018, 01:52 AM
Last Post: jomoengineer
  Read GPIO problem shworker 14 34,329 08-17-2017, 01:21 PM
Last Post: martinayotte
  Cross-wired Uart Ports between two Pine Boards via Cat5 Cable MarkHaysHarris777 10 25,696 11-20-2016, 04:17 AM
Last Post: pfeerick
  GPIO fiq capability joseph 3 9,921 11-10-2016, 06:07 PM
Last Post: joseph

Forum Jump:


Users browsing this thread: 1 Guest(s)