martinohanlon / bluedot Goto Github PK
View Code? Open in Web Editor NEWA zero boiler plate bluetooth remote
License: MIT License
A zero boiler plate bluetooth remote
License: MIT License
The BlueDot is a blue circle (with a radius of lenght 1) inside a bounding white square (with a side of lenght 2 from -1 to 1).
The behavioud when touching outside the circle but inside the square should be better defined and controlable from the API.
In that area, the distance to the center will be higher than 1 (easy to filter at client side too).
For some usage you want only the circle to be sensitive and to report information, for other usage, you want to benefit from the full square.
I'd very much like an interface that works with squares. A blue dot is cute, but not very functional on a phone or tablet.
Imagine you could define a table with cells that would call a function on touch.
Quite a big request, but it would be awesome if you could read the device's orientation as well as the dot position.
Open up the following properties to BlueDot:
and remember to update the recipes.
really?
I know...
but really?
On small screen phones the 'devices' page gets a bit squashed. the list box goes over the 'connect' label at the top of the screen
What about a click wheel implementation?
Like the one you got on the Ipod classic. https://en.wikipedia.org/wiki/IPod_click_wheel
I was worry about the value of pos.distance when the finger is outside of the circle.
Mostly because I use it for saturation in my colour picker.
So I added some print debug:
print(pos.x,pos.y,pos.distance)
And I get "1 1 1" as one of the possible value.
Obviously distance is not equal to sqrt(x^2+y^2)
I believe the documentation should be updated on this topic.
Anything above 1.0 seems to be rounded to 1.0.
Hi, this is a feature request... or a recepie request if it is already possible.
We (dad and son) would like to be able to connect more than one BlueDot app to a python program.
I don't know if it is technically possible.
I don't know how the API can be modified to support that scenario without breaking compatibility.
But I can see some use for it:
As for implementation, here is some idea:
If possible, the app will display if you are player 1 or player 2.
The reason I say player is that of course BlueDot could be use to control a video game.
This link seems to be broken:
https://github.com/martinohanlon/BlueDot/blob/android-dev/clients/android/app/app-release.apk?raw=true
I had to use the following link to get a successful install:
https://github.com/martinohanlon/BlueDot/blob/master/clients/android/app/app-release.apk?raw=true
from BlueDot constructor.
its not used
self._moved_threshold = 0.01
Hi,
I'm using the BlueDot app for controlling my RC car. I have BlueDot python server and the BlueDot android app. I have changed a little the android app, i have just added a new activity with two input fields. Now, i'm trying to send the information from the input fields to the python server.Could you help me to do this?
The android app should handle server disconnects (i.e. being stopped) better.
Currently the app would only know the server had stopped when it sent a message (i.e. When the dot is pressed).
Should it:
Add into documents
functions to swipe left, right, up, down.
I am trying to set up BlueDot on my Pi3 for the first time (running Jessie) and I'm encountering an error I haven't yet been able to decipher. I'm also running BerryConda, which is creating all sorts of fun errors.
I was able to run this on my PiZeroW just fine yesterday. (No BerryConda).
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.4/dist-packages/bluedot/dot.py", line 410, in init
self.start()
File "/usr/local/lib/python3.4/dist-packages/bluedot/dot.py", line 638, in start
self._server.start()
File "/usr/local/lib/python3.4/dist-packages/bluedot/btcomm.py", line 338, in start
self._server_sock = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
File "/usr/lib/python3.4/socket.py", line 123, in init
_socket.socket.init(self, family, type, proto, fileno)
OSError: [Errno 93] Protocol not supported
If you read the position's x
and y
coordinates, they can go outside the range of -1 to 1.
If this is intentional, what's the use case for that?
If it's not intentional, I suggest clamping the values in the property definition.
Trying to pass x
and y
into a gpiozero object's value is fine, until it hits a value outside of that range, and it falls over, so you have to clamp it yourself. I did this:
def clamped(v):
return max(-1, min(1, v))
If set to true, the device wont be powered up as the power_up_device parameter is not passed in the BluetoothServer() constructor.
The android app sends all 'move' events, a threshold should be applied to preserve bandwidth and increase performance and the majority of 'moves' are tiny fluctuations in press position.
Currently BlueDot will start:
Server started B8:27:EB:CA:C7:71
Waiting for connection
But the client will be unable to connect
When I define a callback/event function as:
bd_pressed() -> None:
...
then bluedot/dot.py fails in _process_callback
(or more precisely, in getargspec
) with the error message "ValueError: Function has keyword-only arguments or annotations, use getfullargspec() API which can support them".
Could we have a feature that makes it possible to put a headless Pi into pairing mode (e.g. by pressing a GPIOzero button to make the device discoverable)
add a .when_double_pressed
Measures the time between a release and a press if its less than say 0.5 decs trigger a when_double_pressed
The icons have a white background they should be transparent.
What happens when:
wait_for_double_press
doesn't wait for a double press it only waits for a single press.
For example if I look at examples/dot_debug.py using vi I see the following
def released():^M
print("Released: x-{} y-{}".format(dot.position.x, dot.position.y))^M
print()^M
^M
pypi package - https://badge.fury.io/for/py/bluedot
.. image:: https://badge.fury.io/py/bluedot.svg
:target: https://badge.fury.io/py/bluedot
:alt: Latest Version
Travis
.. image:: https://travis-ci.org/martinohanlon/bluedot.svg?branch=master
:target: https://travis-ci.org/martinohanlon/bluedot
:alt: Tests
Readthedocs
https://readthedocs.org/projects/bluedot/badge/
.. image:: http://bluedot.readthedocs.io/en/latest/?badge=latest
:target: https://readthedocs.org/projects/bluedot/
:alt: Docs
A couple of improvements could be made to MockBlueDot.
mock_client_sending_data
should raise an error if the mock client is not connected
MockBluetoothAdapter
- should inherit from BluetoothAdapter then allow_pairing could also be inherited
The mock app - could either inherit from the Blue Dot Python app, allowing reuse, or it could be refactored to use tkinter meaning pygame isnt a requirement.
rfkill util info - https://wireless.wiki.kernel.org/en/users/documentation/rfkill
This will make power_up_device work better.
I'm not sure if my app has been updated with the version from the Play Store. It would be useful if the app displayed a version number somewhere
I've been having a play and was wondering if you could add something to make BlueDot behave like a rotary encoder.
The use model that I have in mind is something like:
Interested to hear your feedback.
Thanks
When I run the dot_debug.py
script I get output like:
Moved: x-0.06085610017180443 y-0.02328505739569664
Moved: x-0.0385429784655571 y--0.007508336566388607
Moved: x-0.02274600975215435 y--0.030493568629026413
Moved: x-0.011958551593124866 y--0.053042154759168625
Moved: x-0.0030368606094270945 y--0.07534630596637726
Moved: x--0.0070365434512495995 y--0.09938114136457443
All the minus signs are confusing. Consider using equals signs. e.g.
def moved(pos):
print("Moved: x={} y={}".format(pos.x, pos.y))
to match the python and android apps
When the client and server can no longer communicate, the server raises an unhandled exception.
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
self.run()
File "/usr/lib/python3.4/threading.py", line 868, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.4/dist-packages/bluedot-0.0.7-py3.4.egg/bluedot/server.py", line 139, in _wait_for_connection
self._read()
File "/usr/local/lib/python3.4/dist-packages/bluedot-0.0.7-py3.4.egg/bluedot/server.py", line 152, in _read
data = self._client_sock.recv(1024, socket.MSG_DONTWAIT)
TimeoutError: [Errno 110] Connection timed out
The app works fine and recognises the connection is lost.
Create a simple client using python (and maybe pygame) for the blue dot as an alternative to the app.
Tried it on a headless Pi Zero W and on a Pi 3B 1.2, with both Python 2.7.9 and Python 3.4.2 but every time I get the following when I try to run the first bit of code:
Traceback (most recent call last):
File "bluedot.py", line 1, in
from bluedot import BlueDot
File "/home/pi/bluedot/bluedot.py", line 1, in
from bluedot import BlueDot
ImportError: cannot import name BlueDot
minor issue but when_client_connects and disconnects should call the callbacks in separate threads to stop client blocking.
One copy of my program was running in the background (maybe in a screen) and I did notice.
While launching a second instance I got the error below.
Maybe the error message could be more explicit to help troubleshoot it by the user.
Traceback (most recent call last):
File "r.py", line 21, in <module>
bd = BlueDot()
File "/usr/local/lib/python3.4/dist-packages/bluedot/dot.py", line 401, in __init__
self.start()
File "/usr/local/lib/python3.4/dist-packages/bluedot/dot.py", line 600, in start
self._server.start()
File "/usr/local/lib/python3.4/dist-packages/bluedot/btcomm.py", line 340, in start
self._server_sock.bind((self.server_address, self.port))
OSError: [Errno 98] Address already in use
Bluedot is very useful to me. Thank you for your work.
Would you have a plan to develop a Bluedot client for iphone?
BlueDot.btcomm doesnt spawn threads for running the 'data_received' function. This results in potential backlog issues whereby BlueDot is still processing calls when new messages are received.
Hi Martin, could you upload built android apk to github when new version is released?
Most users from China can't access Google Play. Thank you very much.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.