All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [libgpiod][PATCH 1/4] bindings: python: examples: replace tools examples with use case examples
Date: Mon, 26 Jun 2023 16:18:39 +0800	[thread overview]
Message-ID: <ZJlJ30c6psXjtXnz@sol> (raw)
In-Reply-To: <CAMRc=Mdi2cGYjV3GV-iqOazscnRe=swfToRyT2TfeJPv=_yDsg@mail.gmail.com>

On Mon, Jun 26, 2023 at 10:02:33AM +0200, Bartosz Golaszewski wrote:
> On Sat, Jun 24, 2023 at 7:21 AM Kent Gibson <warthog618@gmail.com> wrote:
> >
> > Replace tool examples with use case examples drawn from the tools.
> > +        while True:
> > +            # Blocks until at least one event is available
> > +            for event in request.read_edge_events():
> > +                print(
> > +                    "line: %d  type: Rising   event #%d"
> > +                    % (event.line_offset, event.line_seqno)
> > +                )
> 
> This still uses the old style formatting.
> 

Well spotted.
I only fixed the one you pointed out - didn't even consider that there
could be others.  Turns out there are a few - probably all
cut-and-paste.

> > +
> > +
> > +if __name__ == "__main__":
> > +    try:
> > +        watch_line_rising("/dev/gpiochip0", 5)
> > +    except OSError as ex:
> > +        print(ex, "\nCustomise the example configuration to suit your situation")
> > diff --git a/bindings/python/examples/watch_multiple_line_values.py b/bindings/python/examples/watch_multiple_line_values.py
> > new file mode 100755
> > index 0000000..658ecee
> > --- /dev/null
> > +++ b/bindings/python/examples/watch_multiple_line_values.py
> > @@ -0,0 +1,42 @@
> > +#!/usr/bin/env python3
> > +# SPDX-License-Identifier: GPL-2.0-or-later
> > +# SPDX-FileCopyrightText: 2023 Kent Gibson <warthog618@gmail.com>
> > +
> > +"""Minimal example of watching for edges on multiple lines."""
> > +
> > +import gpiod
> > +
> > +from gpiod.line import Edge
> > +
> > +
> > +def edge_type(event):
> > +    if event.event_type is event.Type.RISING_EDGE:
> > +        return "Rising"
> > +    if event.event_type is event.Type.FALLING_EDGE:
> > +        return "Falling"
> > +    return "Unknown"
> > +
> 
> As there'll be another iteration, maybe change this to get_edge_type()
> or get_edge_event_type_str()? I have a preference for function names
> to reflect the action in general.
> 

Yeah, I use _str elsewhere, not sure why I didn't here.

What an I supposed to resend the update as given the remainder of
the series was merged - v3??

Cheers,
Kent.

  reply	other threads:[~2023-06-26  8:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-24  5:20 [libgpiod][PATCH 0/4] python examples and comment corrections Kent Gibson
2023-06-24  5:20 ` [libgpiod][PATCH 1/4] bindings: python: examples: replace tools examples with use case examples Kent Gibson
2023-06-26  8:02   ` Bartosz Golaszewski
2023-06-26  8:18     ` Kent Gibson [this message]
2023-06-26  8:24       ` Bartosz Golaszewski
2023-06-24  5:20 ` [libgpiod][PATCH 2/4] core: examples: fix file comments Kent Gibson
2023-06-26  8:07   ` Bartosz Golaszewski
2023-06-24  5:20 ` [libgpiod][PATCH 3/4] cxx: examples: file comment consistency Kent Gibson
2023-06-24  5:20 ` [libgpiod][PATCH 4/4] rust: " Kent Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZJlJ30c6psXjtXnz@sol \
    --to=warthog618@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=linux-gpio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.