9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Krystian Lewandowski <krystian.lew@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] radio
Date: Sat, 10 May 2014 13:35:26 +0200	[thread overview]
Message-ID: <76C1D465-4DD8-478B-AFC6-B0AB8051F366@gmail.com> (raw)
In-Reply-To: <20140509232147.44E86B827@mail.bitblocks.com>


Wiadomość napisana przez Bakul Shah <bakul@bitblocks.com> w dniu 10 maj 2014, o godz. 01:21:

> On Fri, 09 May 2014 16:11:00 +0200 Krystian Lewandowski <krystian.lew@gmail.com> wrote:
>> 
>> I was working on GPIO under Plan9 - very simple thing but also supports
>> edge-raising/falling events. I had simple C code to print what pin
>> triggered an event. I'll try to push this simple test to github during
>> weekend. Though i'm not sure how it can be integrated - is events counting
>> enough?
> 
> I think for a rotary encoder you'd want to know about every
> transition. One idea is to return 1/0 on a up/down transition
> to a blocking read. Let the user re-enable the corresponding
> interrupt by writing 1 to the same fd.
> 
> The user code reads from two pins and figures out which way
> the knob is turning. Similarly you can have user code count
> events if that is what you want.
> 


Hi,
i’ve added a simple edge events listener test. 

The test reads 32 bits from #G/gpio/event where each bit position corresponds to „bcm” naming scheme, so bit 17 means GPIO0 (was easier this way).
#G/gpio/event blocks on read, while #G/gpio/GPIO0 does not - just returns current value (and there is no need to seek to beginning).

Works with a single button. ;)

https://github.com/elewarr/gpio_test/blob/master/events.c

cpu% ./events
1: pin 17, state changed
	GPIO0 state=0
2: pin 17, state changed
	GPIO0 state=1
3: pin 17, state changed
	GPIO0 state=0
4: pin 17, state changed
	GPIO0 state=1

Cheers,
Krystian


  reply	other threads:[~2014-05-10 11:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-08 11:06 Steve Simon
2014-05-08 17:19 ` Bakul Shah
2014-05-08 17:58   ` Steve Simon
2014-05-08 18:36     ` Bakul Shah
2014-05-09 14:11       ` Krystian Lewandowski
2014-05-09 15:43         ` Skip Tavakkolian
2014-05-09 23:21         ` Bakul Shah
2014-05-10 11:35           ` Krystian Lewandowski [this message]
2014-05-08 18:51   ` Skip Tavakkolian
2014-05-08 19:04     ` Steve Simon
2014-05-08 20:07       ` Steven Stallion
2014-05-08 20:26         ` Skip Tavakkolian
2014-05-09 12:34   ` Steve Simon
2014-05-09 12:46     ` erik quanstrom
2014-05-09 12:54       ` lucio
2014-05-09 12:59         ` erik quanstrom

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=76C1D465-4DD8-478B-AFC6-B0AB8051F366@gmail.com \
    --to=krystian.lew@gmail.com \
    --cc=9fans@9fans.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).