ardera / flutter-pi

A light-weight Flutter Engine Embedder for Raspberry Pi that runs without X.
MIT License
1.49k stars 154 forks source link

GPIO access #9

Closed jogiji closed 4 years ago

jogiji commented 4 years ago

Can we have GPIO access of some sort with this implementation ?? Just asking

ardera commented 4 years ago

Yeah, that's a good idea.

akilinomendez commented 4 years ago

Alternatively you can create a backend with flask or django and call with dio in flutter to execute gpio commands using python.

Is tested and working

ardera commented 4 years ago

Alternatively you can create a backend with flask or django and call with dio in flutter to execute gpio commands using python.

Is tested and working

That's kinda overkill but yeah, sounds like that should be working.

I found a package that does exactly what you want: https://pub.dev/packages/rpi_gpio

Only works for Raspberry Pi though, while flutter-pi (despite its name) works on much more embedded devices.

EDIT: Seems like it's also not that easy to use, since it requires you to compile a shared library on the Pi.

mortenboye commented 4 years ago

Here’s another vote for GPIO access (unless dart:ffi gets working soon)

ardera commented 4 years ago

Here’s another vote for GPIO access (unless dart:ffi gets working soon)

Yeah actually I started work on GPIO access using dart:ffi and libgpiod a while ago, because it's probably faster than platform channels. Had basic functionality going & was ready to test, then I found out dart:ffi isn't yet supported on ARM hardfp platforms.

mortenboye commented 4 years ago

Here’s another vote for GPIO access (unless dart:ffi gets working soon)

Yeah actually I started work on GPIO access using dart:ffi and libgpiod a while ago, because it's probably faster than platform channels. Had basic functionality going & was ready to test, then I found out dart:ffi isn't yet supported on ARM hardfp platforms.

So, how did you solve this challenge? Write a flutter plugin for GPIO?

ardera commented 4 years ago

So, how did you solve this challenge? Write a flutter plugin for GPIO?

I didn't (yet).

ardera commented 4 years ago

GPIO (more precisely, libgpiod) support is now integrated into flutter-pi. The dart interface still needs some work. Once it's done, I'll publish it on pub.dev.

ardera commented 4 years ago

Just published it.

mortenboye commented 4 years ago

dart:ffi seems to be working with hardfp by now, according to https://github.com/dart-lang/sdk/commit/a71d60c1cf9ff350d4f216b62aa44835182d98f5

@ardera Any chance you could share your FFI based plugin for reference?

ardera commented 4 years ago

dart:ffi seems to be working with hardfp by now, according to dart-lang/sdk@a71d60c

Nice! Keep in mind though that this feature is only available to flutter once the next stable version of the dart SDK (2.8) is released. I'll consider migrating the flutter_gpiod package to dart:ffi once that happens. That would mean a lot of the ugly async stuff, mutexes, etc in flutter_gpiod can go away.

@ardera Any chance you could share your FFI based plugin for reference?

Sure. The code is reaally ugly, very far from finished and doesn't look like the code of the flutter_gpiod package at all, though. I was just kinda experimenting.

flutter_gpiod_ffi.zip

hhk7734 commented 4 years ago

Test environment

Thank you :) flutter_gpiod works well.