From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) From: Krystian Lewandowski In-Reply-To: <20140509232147.44E86B827@mail.bitblocks.com> Date: Sat, 10 May 2014 13:35:26 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <76C1D465-4DD8-478B-AFC6-B0AB8051F366@gmail.com> References: <275c3465707d98d4c1f88f81b40670fd@quintile.net> <20140508183622.E368BB827@mail.bitblocks.com> <20140509232147.44E86B827@mail.bitblocks.com> To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Subject: Re: [9fans] radio Topicbox-Message-UUID: e549488e-ead8-11e9-9d60-3106f5b1d025 Wiadomo=C5=9B=C4=87 napisana przez Bakul Shah w = dniu 10 maj 2014, o godz. 01:21: > On Fri, 09 May 2014 16:11:00 +0200 Krystian Lewandowski = wrote: >>=20 >> 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? >=20 > 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. >=20 > 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. >=20 Hi, i=E2=80=99ve added a simple edge events listener test.=20 The test reads 32 bits from #G/gpio/event where each bit position = corresponds to =E2=80=9Ebcm=E2=80=9D 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=3D0 2: pin 17, state changed GPIO0 state=3D1 3: pin 17, state changed GPIO0 state=3D0 4: pin 17, state changed GPIO0 state=3D1 Cheers, Krystian=