Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"There are things that are so serious that you can only joke about them" -- Heisenberg


computers / comp.sys.raspberry-pi / Re: The button of the pico in python?

SubjectAuthor
* The button of the pico in python?F. W.
+* Re: The button of the pico in python?Martin Gregorie
|`* Re: The button of the pico in python?F. W.
| `* Re: The button of the pico in python?A. Dumas
|  `- Re: The button of the pico in python?A. Dumas
`* Re: The button of the pico in python?Dennis Lee Bieber
 `- Re: The button of the pico in python?Nikolaj Lazic

1
The button of the pico in python?

<sauk86$166e$3@gioia.aioe.org>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=2202&group=comp.sys.raspberry-pi#2202

  copy link   Newsgroups: comp.sys.raspberry-pi
Path: i2pn2.org!i2pn.org!aioe.org!9dmi2SLG0uq1e/d+UK3M0w.user.gioia.aioe.org.POSTED!not-for-mail
From: me...@home.com (F. W.)
Newsgroups: comp.sys.raspberry-pi
Subject: The button of the pico in python?
Date: Wed, 23 Jun 2021 08:27:18 +0200
Organization: Aioe.org NNTP Server
Lines: 13
Message-ID: <sauk86$166e$3@gioia.aioe.org>
NNTP-Posting-Host: 9dmi2SLG0uq1e/d+UK3M0w.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
X-Mozilla-News-Host: news://news.aioe.org:119
Content-Language: de-DE
X-Notice: Filtered by postfilter v. 0.9.2
 by: F. W. - Wed, 23 Jun 2021 06:27 UTC

Hi,

I am not very experienced with Raspberry Pi(co) nor Python. I was given
a R-Pico and enjoy learning about Python (as a former C-Programmer).

Does anybody know how to get a signal if the button on the pico is
pressed? How can a Python-Program detect that the button is pressed?

Or do I think the wrong way?

I have a mad and funny idea which I will publish here ... :-D

FW

Re: The button of the pico in python?

<saum85$6qv$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=2203&group=comp.sys.raspberry-pi#2203

  copy link   Newsgroups: comp.sys.raspberry-pi
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mar...@mydomain.invalid (Martin Gregorie)
Newsgroups: comp.sys.raspberry-pi
Subject: Re: The button of the pico in python?
Date: Wed, 23 Jun 2021 07:01:26 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <saum85$6qv$1@dont-email.me>
References: <sauk86$166e$3@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 23 Jun 2021 07:01:26 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="028fd944d0f845df8229d7494d72be48";
logging-data="7007"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CQ+LVfhBQaANyLjqGHgREnW8Hj5Z/EvQ="
User-Agent: Pan/0.146 (Hic habitat felicitas; 8107378
git@gitlab.gnome.org:GNOME/pan.git)
Cancel-Lock: sha1:gF7qdwKye4kRovIR79hquy0bPhQ=
 by: Martin Gregorie - Wed, 23 Jun 2021 07:01 UTC

On Wed, 23 Jun 2021 08:27:18 +0200, F. W. wrote:

> Hi,
>
> I am not very experienced with Raspberry Pi(co) nor Python. I was given
> a R-Pico and enjoy learning about Python (as a former C-Programmer).
>
Have yo been here:
https://www.raspberrypi.org/documentation/rp2040/getting-started/

and downloaded the PICO documentation?

> Does anybody know how to get a signal if the button on the pico is
> pressed? How can a Python-Program detect that the button is pressed?
>
I'd imagine that's covered in the docs, which are generally pretty good.
Same goes for the RPi range, though for that having a link to the Debian
documentation may also help:
http://www.debian.org/doc/manuals/debian-reference/

--
Martin | martin at
Gregorie | gregorie dot org

Re: The button of the pico in python?

<sauqj3$16r$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=2204&group=comp.sys.raspberry-pi#2204

  copy link   Newsgroups: comp.sys.raspberry-pi
Path: i2pn2.org!i2pn.org!aioe.org!9dmi2SLG0uq1e/d+UK3M0w.user.gioia.aioe.org.POSTED!not-for-mail
From: me...@home.com (F. W.)
Newsgroups: comp.sys.raspberry-pi
Subject: Re: The button of the pico in python?
Date: Wed, 23 Jun 2021 10:15:31 +0200
Organization: Aioe.org NNTP Server
Lines: 15
Message-ID: <sauqj3$16r$1@gioia.aioe.org>
References: <sauk86$166e$3@gioia.aioe.org> <saum85$6qv$1@dont-email.me>
NNTP-Posting-Host: 9dmi2SLG0uq1e/d+UK3M0w.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Content-Language: de-DE
X-Notice: Filtered by postfilter v. 0.9.2
 by: F. W. - Wed, 23 Jun 2021 08:15 UTC

Am 23.06.2021 um 09:01 schrieb Martin Gregorie:

> Have yo been here:
> https://www.raspberrypi.org/documentation/rp2040/getting-started/
>
> and downloaded the PICO documentation?
>

Yes, thank you again.

The button is not mentioned. So I think it is not "reachable".

:-(

FW

Re: The button of the pico in python?

<60d2f1f8$0$22692$e4fe514c@news.xs4all.nl>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=2205&group=comp.sys.raspberry-pi#2205

  copy link   Newsgroups: comp.sys.raspberry-pi
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!3.eu.feeder.erje.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
User-Agent: NewsTap/5.5 (iPad)
Cancel-Lock: sha1:9UxuZ4hLM6E2E7KFXgUBs9BVom4=
Newsgroups: comp.sys.raspberry-pi
Message-ID: <60d2f1f8$0$22692$e4fe514c@news.xs4all.nl>
Subject: Re: The button of the pico in python?
Content-Type: text/plain; charset=UTF-8
Mime-Version: 1.0
Content-Transfer-Encoding: 8bit
From: alexan...@dumas.fr.invalid (A. Dumas)
References: <sauk86$166e$3@gioia.aioe.org>
<saum85$6qv$1@dont-email.me>
<sauqj3$16r$1@gioia.aioe.org>
Date: 23 Jun 2021 08:34:00 GMT
Lines: 22
NNTP-Posting-Host: f425fb13.news.xs4all.nl
X-Trace: G=qShYy7XL,C=U2FsdGVkX19W3l7Bgf7C7xKvgJ1HZ8dadPA40BlC79tej8serviqJiPJI5FaKcDIRaGrcLoRAjnr/sPrEEyUXLDooel0qXaISUax1AvBVABWZWC5K6BHVG+zXBV5qajYYORWH+jt5AS+ZvcdphvdQQ==
X-Complaints-To: abuse@xs4all.nl
 by: A. Dumas - Wed, 23 Jun 2021 08:34 UTC

F. W. <me@home.com> wrote:
> Am 23.06.2021 um 09:01 schrieb Martin Gregorie:
>
>> Have yo been here:
>> https://www.raspberrypi.org/documentation/rp2040/getting-started/
>>
>> and downloaded the PICO documentation?
>>
>
> Yes, thank you again.
>
> The button is not mentioned. So I think it is not "reachable".
>
> :-(

It is mentioned though, depending on which document you read. In the Pico
datasheet for example, it is explained that the "bootsel" button is
connected to "TP6" (test point 6) which is *not* a GPIO pin. It can only be
used to select USB boot at power-up. Its status cannot be read. So yes: not
reachable.

Re: The button of the pico in python?

<60d2f47c$0$22695$e4fe514c@news.xs4all.nl>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=2206&group=comp.sys.raspberry-pi#2206

  copy link   Newsgroups: comp.sys.raspberry-pi
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
User-Agent: NewsTap/5.5 (iPad)
Cancel-Lock: sha1:cYq3FXiUtdAhG1bPficokG4zJto=
Newsgroups: comp.sys.raspberry-pi
Message-ID: <60d2f47c$0$22695$e4fe514c@news.xs4all.nl>
Subject: Re: The button of the pico in python?
Content-Type: text/plain; charset=UTF-8
Mime-Version: 1.0
Content-Transfer-Encoding: 8bit
From: alexan...@dumas.fr.invalid (A. Dumas)
References: <sauk86$166e$3@gioia.aioe.org>
<saum85$6qv$1@dont-email.me>
<sauqj3$16r$1@gioia.aioe.org>
<60d2f1f8$0$22692$e4fe514c@news.xs4all.nl>
Date: 23 Jun 2021 08:44:44 GMT
Lines: 6
NNTP-Posting-Host: f425fb13.news.xs4all.nl
X-Trace: G=qShYy7XL,C=U2FsdGVkX1+/GTXHRDzPbiXgz45mu88mJYph6wjRxUEj3C8gAgaDILdgfV7xYyNDfgV2MB7wHmW+LGfuuJ3yGslM1YKt5N6CUI4lTlC3pk/JP6c1R4KMG0grkFaiHofIo/yLP9Qpy+0TGRYJPs967w==
X-Complaints-To: abuse@xs4all.nl
 by: A. Dumas - Wed, 23 Jun 2021 08:44 UTC

A. Dumas <alexandre@dumas.fr.invalid> wrote:
> It is mentioned though, depending on which document you read. [...]

Download the book for an introduction to hardware things like buttons:
https://hackspace.raspberrypi.org/books/micropython-pico (free pdf link
from there, or buy a printed version)

Re: The button of the pico in python?

<fvk6dg10epma48htcdlbkl137b7276d6g7@4ax.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=2208&group=comp.sys.raspberry-pi#2208

  copy link   Newsgroups: comp.sys.raspberry-pi
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!buffer1.nntp.dca1.giganews.com!buffer2.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 23 Jun 2021 11:14:14 -0500
From: wlfr...@ix.netcom.com (Dennis Lee Bieber)
Newsgroups: comp.sys.raspberry-pi
Subject: Re: The button of the pico in python?
Date: Wed, 23 Jun 2021 12:14:14 -0400
Organization: IISS Elusive Unicorn
Message-ID: <fvk6dg10epma48htcdlbkl137b7276d6g7@4ax.com>
References: <sauk86$166e$3@gioia.aioe.org>
User-Agent: ForteAgent/8.00.32.1272
X-No-Archive: YES
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 164
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-vueRH/88LtPHHjcZ5XBBzOG4yrPtNOOgI1+0MDgjB+P0jk0lZisKOJMIVC1neKrM45BpIbtKHqrb+KP!YxAHq4NPahqgeY8Ni7/4G4zwi+S/SvJSgokIZMsF4EoW1xvoceXXT8iNcoFgMN2NN1Kpj9xn
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 9236
 by: Dennis Lee Bieber - Wed, 23 Jun 2021 16:14 UTC

On Wed, 23 Jun 2021 08:27:18 +0200, "F. W." <me@home.com> declaimed the
following:

>Does anybody know how to get a signal if the button on the pico is
>pressed? How can a Python-Program detect that the button is pressed?

As others have already commented as to the actual button, I'll attempt
a general review of the second question.

Their are a number of ways to read GPIO pins.

SYSFS:
Old (and being deprecated by Linux development)
https://www.ics.com/blog/gpio-programming-using-sysfs-interface

pi@rpi3bplus-1:~$ ls -l /sys/class/gpio
total 0
-rwxrwx--- 1 root gpio 4096 Jun 19 12:15 export
lrwxrwxrwx 1 root gpio 0 Jun 19 12:15 gpiochip0 ->
.../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0
lrwxrwxrwx 1 root gpio 0 Jun 19 12:15 gpiochip504 ->
.../../devices/platform/soc/soc:firmware/soc:firmware:expgpio/gpio/gpiochip504
-rwxrwx--- 1 root gpio 4096 Jun 19 12:15 unexport
pi@rpi3bplus-1:~$ echo "24" >/sys/class/gpio/export
pi@rpi3bplus-1:~$ ls -l /sys/class/gpio
total 0
-rwxrwx--- 1 root gpio 4096 Jun 23 11:41 export
lrwxrwxrwx 1 root gpio 0 Jun 23 11:41 gpio24 ->
.../../devices/platform/soc/3f200000.gpio/gpiochip0/gpio/gpio24
lrwxrwxrwx 1 root gpio 0 Jun 19 12:15 gpiochip0 ->
.../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0
lrwxrwxrwx 1 root gpio 0 Jun 19 12:15 gpiochip504 ->
.../../devices/platform/soc/soc:firmware/soc:firmware:expgpio/gpio/gpiochip504
-rwxrwx--- 1 root gpio 4096 Jun 19 12:15 unexport
pi@rpi3bplus-1:~$ ls -l /sys/class/gpio/gpio24
lrwxrwxrwx 1 root gpio 0 Jun 23 11:41 /sys/class/gpio/gpio24 ->
.../../devices/platform/soc/3f200000.gpio/gpiochip0/gpio/gpio24
pi@rpi3bplus-1:~$ ls -l /sys/class/gpio/gpio24/
total 0
-rwxrwx--- 1 root gpio 4096 Jun 23 11:41 active_low
lrwxrwxrwx 1 root gpio 0 Jun 23 11:41 device -> ../../../gpiochip0
-rwxrwx--- 1 root gpio 4096 Jun 23 11:41 direction
-rwxrwx--- 1 root gpio 4096 Jun 23 11:41 edge
drwxrwx--- 2 root gpio 0 Jun 23 11:41 power
lrwxrwxrwx 1 root gpio 0 Jun 23 11:41 subsystem ->
.../../../../../../../class/gpio
-rwxrwx--- 1 root gpio 4096 Jun 23 11:41 uevent
-rwxrwx--- 1 root gpio 4096 Jun 23 11:41 value
pi@rpi3bplus-1:~$ echo /sys/class/gpio/gpio24/direction
/sys/class/gpio/gpio24/direction
pi@rpi3bplus-1:~$ cat /sys/class/gpio/gpio24/direction
in
pi@rpi3bplus-1:~$ cat /sys/class/gpio/gpio24/value
0 pi@rpi3bplus-1:~$

Since those appear as "files" any application that can
open/read-write/close the paths can use it.

libgpiod:
The intended replacement for the sysfs access. Not installed by default
(based upon my R-Pi -- attempting apt install of gpiod; though I may have a
slightly corrupted apt system.
https://www.ics.com/blog/gpio-programming-exploring-libgpiod-library
pi@rpi3bplus-1:~$ gpioinfo
gpiochip0 - 54 lines:
line 0: unnamed unused input active-high
line 1: unnamed unused input active-high
line 2: unnamed unused input active-high
line 3: unnamed unused input active-high
line 4: unnamed unused input active-high
line 5: unnamed unused input active-high
line 6: unnamed unused input active-high
line 7: unnamed unused input active-high
line 8: unnamed unused input active-high
line 9: unnamed unused input active-high
line 10: unnamed unused input active-high
line 11: unnamed unused input active-high
line 12: unnamed unused input active-high
line 13: unnamed unused input active-high
line 14: unnamed unused input active-high
line 15: unnamed unused input active-high
line 16: unnamed unused input active-high
line 17: unnamed unused input active-high
line 18: unnamed unused input active-high
line 19: unnamed unused input active-high
line 20: unnamed unused input active-high
line 21: unnamed unused input active-high
line 22: unnamed unused input active-high
line 23: unnamed unused input active-high
line 24: unnamed "sysfs" input active-high [used]
line 25: unnamed unused input active-high
line 26: unnamed unused input active-high
line 27: unnamed unused input active-high
line 28: unnamed unused input active-high
line 29: unnamed "led0" output active-high [used]
line 30: unnamed unused input active-high
line 31: unnamed unused input active-high
line 32: unnamed unused input active-high
line 33: unnamed unused input active-high
line 34: unnamed unused input active-high
line 35: unnamed unused input active-high
line 36: unnamed unused input active-high
line 37: unnamed unused input active-high
line 38: unnamed unused input active-high
line 39: unnamed unused input active-high
line 40: unnamed unused input active-high
line 41: unnamed unused input active-high
line 42: unnamed unused input active-high
line 43: unnamed unused input active-high
line 44: unnamed unused input active-high
line 45: unnamed unused input active-high
line 46: unnamed unused input active-high
line 47: unnamed unused output active-high
line 48: unnamed unused input active-high
line 49: unnamed unused input active-high
line 50: unnamed unused input active-high
line 51: unnamed unused input active-high
line 52: unnamed unused input active-high
line 53: unnamed unused input active-high
gpiochip1 - 8 lines:
line 0: unnamed unused output active-high
line 1: unnamed unused output active-high
line 2: unnamed "led1" output active-low [used]
line 3: unnamed unused output active-high
line 4: unnamed unused input active-high
line 5: unnamed unused output active-high
line 6: unnamed unused output active-high
line 7: unnamed unused input active-high
pi@rpi3bplus-1:~$

Note that chip0 line 24 shows "sysfs" -- since I exported it using
sysfs commands.

From Python...

gpiozero library:
https://www.raspberrypi.org/documentation/usage/gpio/python/README.md
https://gpiozero.readthedocs.io/en/stable/
A newer Python binding (there is also a binding for gpiod -- I need to
install that next). It is capable of using a number of low-level libraries
for actual GPIO access

RPi.GPIO:
Original Python GPIO library

pigpio:
Relies upon a daemon process with which client programs communicate to
access GPIO http://abyz.me.uk/rpi/pigpio/python.html

Adafruit Blinka:
An interface layer translating CircuitPython calls into R-Pi GPIO (or
Beaglebone Black if one has one of those too). Adafruit is phasing out
usage of "native" libraries in example programs and device code in favor of
using the CircuitPython GPIO operations.
https://learn.adafruit.com/adafruit-io-basics-digital-input/python-setup (a
bit out-of-date; they still refer to Debian "Stretch")

--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

Re: The button of the pico in python?

<slrnsd6nk8.hva.nlazicBEZ_OVOGA@mudrac.ffzg.hr>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=2209&group=comp.sys.raspberry-pi#2209

  copy link   Newsgroups: comp.sys.raspberry-pi
Path: i2pn2.org!i2pn.org!aioe.org!newsfeed.CARNet.hr!.POSTED.193.198.212.8!not-for-mail
From: nlazicBE...@mudrac.ffzg.hr (Nikolaj Lazic)
Newsgroups: comp.sys.raspberry-pi
Subject: Re: The button of the pico in python?
Date: Wed, 23 Jun 2021 16:17:12 -0000 (UTC)
Organization: CARNet, Croatia
Message-ID: <slrnsd6nk8.hva.nlazicBEZ_OVOGA@mudrac.ffzg.hr>
References: <sauk86$166e$3@gioia.aioe.org>
<fvk6dg10epma48htcdlbkl137b7276d6g7@4ax.com>
Reply-To: nlazicBEZ_OVOGA@mudrac.ffzg.hr
Injection-Date: Wed, 23 Jun 2021 16:17:12 -0000 (UTC)
Injection-Info: news1.carnet.hr; posting-host="193.198.212.8";
logging-data="3778"; mail-complaints-to="abuse@CARNet.hr"
User-Agent: slrn/1.0.2 (Linux)
 by: Nikolaj Lazic - Wed, 23 Jun 2021 16:17 UTC

Dana Wed, 23 Jun 2021 12:14:14 -0400, Dennis Lee Bieber <wlfraed@ix.netcom.com> napis'o:
> On Wed, 23 Jun 2021 08:27:18 +0200, "F. W." <me@home.com> declaimed the
> following:
>
>
>>Does anybody know how to get a signal if the button on the pico is
>>pressed? How can a Python-Program detect that the button is pressed?
>
> As others have already commented as to the actual button, I'll attempt
> a general review of the second question.
[snip]

he asked about pico.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor